Version Description
Requires BuddyPress 1.7 or higher, if using BuddyPress. WordPress VIP compatibility added
=
Download this release
Release Info
Developer | rtcamp |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 3.10.9 |
Comparing to | |
See all releases |
Code changes from version 3.10.8 to 3.10.9
- CONTRIBUTING.md +1 -1
- Gruntfile.js +134 -134
- app/admin/RTMediaAdmin.php +823 -728
- app/admin/RTMediaFormHandler.php +441 -389
- app/admin/templates/tmpl-rtm-album-favourites-importer.php +9 -0
- app/admin/templates/tmpl-rtm-image.php +5 -0
- app/admin/templates/tmpl-rtm-map-mapping-failure.php +1 -0
- app/admin/templates/tmpl-rtm-msg-div.php +3 -0
- app/admin/templates/tmpl-rtm-p-tag.php +5 -0
- app/admin/templates/tmpl-rtm-theme-overlay.php +4 -0
- app/assets/admin/css/admin.css +5 -1
- app/assets/admin/css/admin.min.css +1 -1
- app/assets/admin/css/sass/_addons.scss +5 -1
- app/assets/admin/js/admin.min.js +1 -1
- app/assets/admin/js/scripts.js +11 -2
- app/assets/admin/js/settings.js +185 -88
- app/assets/js/rtMedia.backbone.js +514 -509
- app/assets/js/rtMedia.js +195 -207
- app/assets/js/rtmedia.min.js +1 -1
- app/helper/BPMediaBranding.php +6 -7
- app/helper/RTMediaActivityModel.php +8 -6
- app/helper/RTMediaAddon.php +369 -364
- app/helper/RTMediaAdminWidget.php +13 -14
- app/helper/RTMediaCommentModel.php +7 -2
- app/helper/RTMediaCommentNotification.php +120 -111
- app/helper/RTMediaFeed.php +15 -19
- app/helper/RTMediaInteractionModel.php +16 -16
- app/helper/RTMediaLicense.php +45 -43
- app/helper/RTMediaLikeNotification.php +137 -128
- app/helper/RTMediaModel.php +115 -113
- app/helper/RTMediaNotification.php +68 -65
- app/helper/RTMediaSettings.php +151 -154
- app/helper/RTMediaSupport.php +258 -208
- app/helper/RTMediaThemes.php +169 -133
- app/helper/RTMediaUploadException.php +9 -9
- app/helper/db/RTDBModel.php +50 -51
- app/helper/db/RTDBUpdate.php +25 -27
- app/helper/db/rt_plugin_info.php +19 -14
- app/helper/rtDimensions.php +52 -30
- app/helper/rtForm.php +229 -202
- app/helper/rtFormInvalidArgumentsException.php +6 -5
- app/helper/rtPluginUpdateChecker.php +1 -1
- app/helper/rtProgress.php +12 -9
- app/importers/BPMediaAlbumimporter.php +136 -108
- app/importers/BPMediaBPActivityPlusImporter.php +0 -1
- app/importers/BPMediaImporter.php +28 -34
- app/importers/RTMediaActivityUpgrade.php +123 -103
- app/importers/RTMediaMediaSizeImporter.php +123 -110
- app/importers/RTMediaMigration.php +307 -290
- app/main/RTMedia.php +479 -408
- app/main/contexts/RTMediaContext.php +19 -20
- app/main/controllers/activity/RTMediaActivity.php +30 -32
- app/main/controllers/activity/RTMediaBuddyPressActivity.php +327 -282
- app/main/controllers/api/RTMediaApiLogin.php +6 -6
- app/main/controllers/api/RTMediaJsonApi.php +882 -842
CONTRIBUTING.md
CHANGED
@@ -12,7 +12,7 @@ For support-request/feature-request, please use - http://community.rtcamp.com/c/
|
|
12 |
|
13 |
Please do NOT send pull-request for translations.
|
14 |
|
15 |
-
You can contribute translations using web-interface here -
|
16 |
|
17 |
## Pull Requests
|
18 |
|
12 |
|
13 |
Please do NOT send pull-request for translations.
|
14 |
|
15 |
+
You can contribute translations using web-interface here - https://rtmedia.io/translate/projects/rtmedia
|
16 |
|
17 |
## Pull Requests
|
18 |
|
Gruntfile.js
CHANGED
@@ -1,89 +1,89 @@
|
|
1 |
'use strict';
|
2 |
module.exports = function ( grunt ) {
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
'app/assets/js/vendors/magnific-popup.js',
|
81 |
'app/assets/admin/js/vendors/tabs.js',
|
82 |
'app/assets/js/rtMedia.js'
|
83 |
-
|
84 |
dest: 'app/assets/js/rtmedia.min.js'
|
85 |
-
|
86 |
-
|
87 |
src: [
|
88 |
'app/assets/admin/js/vendors/tabs.js',
|
89 |
'app/assets/admin/js/scripts.js',
|
@@ -91,61 +91,61 @@ module.exports = function ( grunt ) {
|
|
91 |
],
|
92 |
dest: 'app/assets/admin/js/admin.min.js'
|
93 |
}
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
};
|
1 |
'use strict';
|
2 |
module.exports = function ( grunt ) {
|
3 |
|
4 |
+
// load all grunt tasks matching the `grunt-*` pattern
|
5 |
+
// Ref. https://npmjs.org/package/load-grunt-tasks
|
6 |
+
require( 'load-grunt-tasks' )( grunt );
|
7 |
|
8 |
+
grunt.initConfig( {
|
9 |
+
// watch for changes and trigger sass, jshint, uglify and livereload
|
10 |
+
watch: {
|
11 |
+
sass: {
|
12 |
+
files: [ 'app/assets/admin/css/sass/**/*.{scss,sass}', 'app/assets/css/sass/**/*.{scss,sass}' ],
|
13 |
+
tasks: [ 'sass' ]
|
14 |
+
},
|
15 |
+
autoprefixer: {
|
16 |
+
files: [ 'app/assets/admin/css/*.css', 'app/assets/css/*css' ],
|
17 |
+
tasks: [ 'autoprefixer' ]
|
18 |
+
},
|
19 |
+
js: {
|
20 |
+
files: [ '<%= uglify.frontend.src %>', '<%= uglify.backend.src %>' ],
|
21 |
+
tasks: [ 'uglify' ]
|
22 |
+
},
|
23 |
+
livereload: {
|
24 |
+
// Here we watch the files the sass task will compile to
|
25 |
+
// These files are sent to the live reload server after sass compiles to them
|
26 |
+
options: { livereload: true },
|
27 |
+
files: [ '*.php', '*.css' ]
|
28 |
+
}
|
29 |
+
},
|
30 |
+
// sass
|
31 |
+
sass: {
|
32 |
+
dist: {
|
33 |
+
options: {
|
34 |
+
style: 'expanded',
|
35 |
+
sourcemap: 'none'
|
36 |
+
},
|
37 |
+
files: {
|
38 |
+
'app/assets/admin/css/admin.css': 'app/assets/admin/css/sass/admin.scss',
|
39 |
+
'app/assets/admin/css/widget.css': 'app/assets/admin/css/sass/widget.scss',
|
40 |
+
'app/assets/css/rtmedia.css': 'app/assets/css/sass/rtmedia.scss',
|
41 |
+
}
|
42 |
+
},
|
43 |
+
minify: {
|
44 |
+
options: {
|
45 |
+
style: 'compressed',
|
46 |
+
sourcemap: 'none'
|
47 |
+
},
|
48 |
+
files: {
|
49 |
+
'app/assets/admin/css/admin.min.css': 'app/assets/admin/css/sass/admin.scss',
|
50 |
+
'app/assets/admin/css/widget.min.css': 'app/assets/admin/css/sass/widget.scss',
|
51 |
+
'app/assets/css/rtmedia.min.css': 'app/assets/css/sass/rtmedia.scss'
|
52 |
+
}
|
53 |
+
}
|
54 |
+
},
|
55 |
+
// autoprefixer
|
56 |
+
autoprefixer: {
|
57 |
+
dist: {
|
58 |
+
options: {
|
59 |
+
browsers: [ 'last 2 versions', 'ie 9', 'ios 6', 'android 4' ],
|
60 |
+
expand: true,
|
61 |
+
flatten: true
|
62 |
+
},
|
63 |
+
files: {
|
64 |
+
'app/assets/admin/css/admin.css': 'app/assets/admin/css/admin.css',
|
65 |
+
'app/assets/admin/css/admin.min.css': 'app/assets/admin/css/admin.min.css',
|
66 |
+
'app/assets/admin/css/widget.css': 'app/assets/admin/css/widget.css',
|
67 |
+
'app/assets/admin/css/widget.min.css': 'app/assets/admin/css/widget.min.css',
|
68 |
+
'app/assets/css/rtmedia.css': 'app/assets/css/rtmedia.css',
|
69 |
+
'app/assets/css/rtmedia.min.css': 'app/assets/css/rtmedia.min.css'
|
70 |
+
}
|
71 |
+
}
|
72 |
+
},
|
73 |
+
// Uglify Ref. https://npmjs.org/package/grunt-contrib-uglify
|
74 |
+
uglify: {
|
75 |
+
options: {
|
76 |
+
banner: '/*! \n * rtMedia JavaScript Library \n * @package rtMedia \n */\n',
|
77 |
+
},
|
78 |
+
frontend: {
|
79 |
+
src: [
|
80 |
'app/assets/js/vendors/magnific-popup.js',
|
81 |
'app/assets/admin/js/vendors/tabs.js',
|
82 |
'app/assets/js/rtMedia.js'
|
83 |
+
],
|
84 |
dest: 'app/assets/js/rtmedia.min.js'
|
85 |
+
},
|
86 |
+
backend: {
|
87 |
src: [
|
88 |
'app/assets/admin/js/vendors/tabs.js',
|
89 |
'app/assets/admin/js/scripts.js',
|
91 |
],
|
92 |
dest: 'app/assets/admin/js/admin.min.js'
|
93 |
}
|
94 |
+
},
|
95 |
+
checktextdomain: {
|
96 |
+
options: {
|
97 |
+
text_domain: 'buddypress-media', //Specify allowed domain(s)
|
98 |
+
keywords: [ //List keyword specifications
|
99 |
+
'__:1,2d',
|
100 |
+
'_e:1,2d',
|
101 |
+
'_x:1,2c,3d',
|
102 |
+
'esc_html__:1,2d',
|
103 |
+
'esc_html_e:1,2d',
|
104 |
+
'esc_html_x:1,2c,3d',
|
105 |
+
'esc_attr__:1,2d',
|
106 |
+
'esc_attr_e:1,2d',
|
107 |
+
'esc_attr_x:1,2c,3d',
|
108 |
+
'_ex:1,2c,3d',
|
109 |
+
'_n:1,2,4d',
|
110 |
+
'_nx:1,2,4c,5d',
|
111 |
+
'_n_noop:1,2,3d',
|
112 |
+
'_nx_noop:1,2,3c,4d'
|
113 |
+
]
|
114 |
+
},
|
115 |
+
target: {
|
116 |
+
files: [ {
|
117 |
+
src: [
|
118 |
+
'*.php',
|
119 |
+
'**/*.php',
|
120 |
+
'!node_modules/**',
|
121 |
+
'!tests/**'
|
122 |
+
], //all php
|
123 |
+
expand: true
|
124 |
+
} ]
|
125 |
+
}
|
126 |
+
},
|
127 |
+
makepot: {
|
128 |
+
target: {
|
129 |
+
options: {
|
130 |
+
cwd: '.', // Directory of files to internationalize.
|
131 |
+
domainPath: 'languages/', // Where to save the POT file.
|
132 |
+
exclude: [ 'node_modules/*' ], // List of files or directories to ignore.
|
133 |
+
mainFile: 'index.php', // Main project file.
|
134 |
+
potFilename: 'buddypress-media.po', // Name of the POT file.
|
135 |
+
potHeaders: { // Headers to add to the generated POT file.
|
136 |
+
poedit: true, // Includes common Poedit headers.
|
137 |
+
'Last-Translator': 'rtMedia <rtmedia@rtcamp.com>',
|
138 |
+
'Language-Team': 'rtMedia <rtmedia@rtcamp.com>',
|
139 |
+
'report-msgid-bugs-to': 'http://community.rtcamp.com/c/rtmedia/',
|
140 |
+
'x-poedit-keywordslist': true // Include a list of all possible gettext functions.
|
141 |
+
},
|
142 |
+
type: 'wp-plugin', // Type of project (wp-plugin or wp-theme).
|
143 |
+
updateTimestamp: true // Whether the POT-Creation-Date should be updated without other changes.
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
|
148 |
+
} );
|
149 |
+
// register task
|
150 |
+
grunt.registerTask( 'default', [ 'sass', 'autoprefixer', 'uglify', 'checktextdomain', 'makepot', 'watch' ] );
|
151 |
};
|
app/admin/RTMediaAdmin.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Description of RTMediaAdmin
|
4 |
*
|
@@ -23,37 +24,43 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
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 |
-
//$rtmedia_feed = new RTMediaFeed();
|
35 |
add_filter( 'plugin_action_links_' . RTMEDIA_BASE_NAME, array( &$this, 'plugin_add_settings_link' ) );
|
36 |
-
|
37 |
$this->rtmedia_support = new RTMediaSupport();
|
38 |
add_action( 'wp_ajax_rtmedia_select_request', array( $this->rtmedia_support, 'get_form' ), 1 );
|
39 |
-
add_action( 'wp_ajax_rtmedia_cancel_request',
|
|
|
|
|
|
|
40 |
add_action( 'wp_ajax_rtmedia_submit_request', array( $this->rtmedia_support, 'submit_request' ), 1 );
|
41 |
-
|
42 |
-
add_action( 'wp_ajax_rtmedia_linkback', array( $this, 'linkback' ), 1 );
|
43 |
add_action( 'wp_ajax_rtmedia_rt_album_deactivate', 'BPMediaAlbumimporter::bp_album_deactivate', 1 );
|
44 |
add_action( 'wp_ajax_rtmedia_rt_album_import', 'BPMediaAlbumimporter::bpmedia_ajax_import_callback', 1 );
|
45 |
add_action( 'wp_ajax_rtmedia_rt_album_import_favorites', 'BPMediaAlbumimporter::bpmedia_ajax_import_favorites', 1 );
|
46 |
add_action( 'wp_ajax_rtmedia_rt_album_import_step_favorites', 'BPMediaAlbumimporter::bpmedia_ajax_import_step_favorites', 1 );
|
47 |
add_action( 'wp_ajax_rtmedia_rt_album_cleanup', 'BPMediaAlbumimporter::cleanup_after_install' );
|
48 |
-
add_action( 'wp_ajax_rtmedia_convert_videos_form', array( $this, 'convert_videos_mailchimp_send' ), 1 );
|
49 |
add_action( 'wp_ajax_rtmedia_correct_upload_filetypes', array( $this, 'correct_upload_filetypes' ), 1 );
|
50 |
-
add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_premium_addon_link' ), 1,
|
51 |
-
add_action( 'wp_dashboard_setup', array(
|
52 |
add_filter( 'attachment_fields_to_edit', array( $this, 'edit_video_thumbnail' ), null, 2 );
|
53 |
-
add_filter( 'attachment_fields_to_save', array( $this, 'save_video_thumbnail' ), null,
|
54 |
-
add_action( 'wp_ajax_rtmedia_hide_video_thumb_admin_notice', array(
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
$obj_encoding = new RTMediaEncoding( true );
|
59 |
|
@@ -71,19 +78,19 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
71 |
$rtmedia->options = rtmedia_get_site_option( 'rtmedia-options' );
|
72 |
}
|
73 |
|
74 |
-
|
75 |
-
|
|
|
76 |
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 );
|
77 |
}
|
78 |
} else {
|
79 |
-
if ( 1
|
80 |
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 );
|
81 |
}
|
82 |
}
|
83 |
|
84 |
if ( is_admin() ) {
|
85 |
add_action( 'admin_enqueue_scripts', array( $this, 'ui' ) );
|
86 |
-
//bp_core_admin_hook();
|
87 |
add_action( 'admin_menu', array( $this, 'menu' ), 1 );
|
88 |
add_action( 'init', array( $this, 'bp_admin_tabs' ) );
|
89 |
|
@@ -94,44 +101,64 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
94 |
|
95 |
$this->rtmedia_settings = new RTMediaSettings();
|
96 |
$this->rtmedia_encoding = new RTMediaEncoding();
|
97 |
-
|
98 |
-
// if(! defined("RTMEDIA_PRO_VERSION") )
|
99 |
-
// add_action ( 'rtmedia_before_default_admin_widgets', array( $this, 'rtmedia_advertisement' ),1);
|
100 |
if ( ! class_exists( 'BuddyPress' ) ) {
|
101 |
add_action( 'admin_init', array( $this, 'check_permalink_admin_notice' ) );
|
102 |
}
|
103 |
|
104 |
-
add_action( 'wp_ajax_rtmedia_hide_template_override_notice', array(
|
|
|
|
|
|
|
105 |
add_action( 'admin_init', array( $this, 'rtmedia_bp_add_update_type' ) );
|
106 |
-
add_action( 'wp_ajax_rtmedia_hide_inspirebook_release_notice', array(
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
if ( class_exists( 'BuddyPress' ) ) {
|
111 |
-
|
112 |
}
|
113 |
add_action( 'admin_notices', array( $this, 'rtmedia_admin_notices' ) );
|
114 |
add_action( 'network_admin_notices', array( $this, 'rtmedia_network_admin_notices' ) );
|
115 |
add_action( 'admin_init', array( $this, 'rtmedia_addon_license_save_hook' ) );
|
116 |
add_action( 'admin_init', array( $this, 'rtmedia_migration' ) );
|
117 |
|
118 |
-
add_filter( 'removable_query_args', array( $this, 'removable_query_args'), 10, 1 );
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
function rtmedia_migration() {
|
134 |
-
|
135 |
}
|
136 |
|
137 |
function rtmedia_addon_license_save_hook() {
|
@@ -168,53 +195,61 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
168 |
$this->rtmedia_regenerate_thumbnail_notice();
|
169 |
$this->rtmedia_addon_update_notice();
|
170 |
$this->rtmedia_update_template_notice();
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
187 |
rtmedia_update_site_option( 'rtmedia_pro_split_release_notice', 'show' );
|
188 |
?>
|
189 |
<div class="updated rtmedia-pro-split-notice">
|
190 |
<p>
|
191 |
<span>
|
192 |
-
|
|
|
|
|
|
|
193 |
</span>
|
194 |
-
<a href="#"
|
|
|
|
|
195 |
</p>
|
196 |
</div>
|
197 |
<script type="text/javascript">
|
198 |
-
function rtmedia_hide_pro_split_notice() {
|
199 |
-
var data = {
|
200 |
-
jQuery.post(
|
201 |
response = response.trim();
|
202 |
-
|
203 |
-
|
204 |
-
jQuery(
|
205 |
-
}
|
206 |
}
|
207 |
</script>
|
208 |
<?php
|
209 |
}
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
* Hide pro split release notice
|
214 |
*/
|
215 |
|
216 |
function rtmedia_hide_pro_split_notice() {
|
217 |
-
if ( rtmedia_update_site_option( 'rtmedia_pro_split_release_notice', 'hide' ) ) {
|
218 |
echo '1';
|
219 |
} else {
|
220 |
echo '0';
|
@@ -227,31 +262,36 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
227 |
*/
|
228 |
|
229 |
function rtmedia_social_sync_release_notice() {
|
230 |
-
$site_option
|
231 |
$check_rtmedia_social_sync_installed = file_exists( trailingslashit( WP_PLUGIN_DIR ) . 'rtmedia-social-sync/index.php' );
|
232 |
|
233 |
-
if ( ( ! $site_option || 'hide'
|
234 |
rtmedia_update_site_option( 'rtmedia_social_sync_release_notice', 'show' );
|
235 |
?>
|
236 |
<div class="updated rtmedia-social-sync-notice">
|
237 |
<p>
|
238 |
<span>
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
243 |
</span>
|
244 |
-
<a href="#"
|
|
|
|
|
245 |
</p>
|
246 |
</div>
|
247 |
<script type="text/javascript">
|
248 |
-
function rtmedia_hide_social_sync_notice() {
|
249 |
-
var data = {
|
250 |
-
jQuery.post(
|
251 |
response = response.trim();
|
252 |
-
if (
|
253 |
-
jQuery(
|
254 |
-
}
|
255 |
}
|
256 |
</script>
|
257 |
<?php
|
@@ -263,7 +303,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
263 |
*/
|
264 |
|
265 |
function rtmedia_hide_social_sync_notice() {
|
266 |
-
if ( rtmedia_update_site_option( 'rtmedia_social_sync_release_notice', 'hide' ) ) {
|
267 |
echo '1';
|
268 |
} else {
|
269 |
echo '0';
|
@@ -282,24 +322,33 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
282 |
*/
|
283 |
public function rtmedia_inspirebook_release_notice() {
|
284 |
$site_option = rtmedia_get_site_option( 'rtmedia_inspirebook_release_notice' );
|
285 |
-
if ( ( ! $site_option || 'hide'
|
286 |
rtmedia_update_site_option( 'rtmedia_inspirebook_release_notice', 'show' );
|
287 |
?>
|
288 |
<div class="updated rtmedia-inspire-book-notice">
|
289 |
<p>
|
290 |
-
<span
|
291 |
-
|
|
|
|
|
|
|
|
|
|
|
292 |
<a href="#" onclick="rtmedia_hide_inspirebook_notice()" style="float:right">Dismiss</a>
|
|
|
293 |
</p>
|
294 |
</div>
|
295 |
<script type="text/javascript">
|
296 |
function rtmedia_hide_inspirebook_notice() {
|
297 |
-
var data = {
|
298 |
-
|
|
|
|
|
|
|
299 |
response = response.trim();
|
300 |
-
if (
|
301 |
-
jQuery(
|
302 |
-
}
|
303 |
}
|
304 |
</script>
|
305 |
<?php
|
@@ -316,7 +365,8 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
316 |
* @return void
|
317 |
*/
|
318 |
public function rtmedia_hide_inspirebook_release_notice() {
|
319 |
-
|
|
|
320 |
echo '1';
|
321 |
} else {
|
322 |
echo '0';
|
@@ -366,7 +416,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
366 |
*/
|
367 |
public function rtmedia_permalink_notice() {
|
368 |
echo '<div class="error rtmedia-permalink-change-notice">
|
369 |
-
<p> <b>rtMedia
|
370 |
</div>';
|
371 |
}
|
372 |
|
@@ -382,32 +432,38 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
382 |
public function rtmedia_addon_update_notice() {
|
383 |
|
384 |
$site_option = rtmedia_get_site_option( 'rtmedia-addon-update-notice-3_8' );
|
385 |
-
if( is_rt_admin()
|
386 |
-
&& ( ! $site_option || 'hide' != $site_option ) ){
|
387 |
|
388 |
if ( ! $this->check_for_addon_update_notice() ) {
|
389 |
return;
|
390 |
}
|
391 |
rtmedia_update_site_option( 'rtmedia-addon-update-notice-3_8', 'show' );
|
392 |
-
|
393 |
<div class="error rtmedia-addon-upate-notice">
|
394 |
<p>
|
395 |
-
<strong><?php
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
</p>
|
397 |
</div>
|
398 |
<script type="text/javascript">
|
399 |
function rtmedia_hide_addon_update_notice() {
|
400 |
var data = {
|
401 |
-
action: 'rtmedia_hide_addon_update_notice'
|
402 |
-
|
403 |
-
|
|
|
404 |
response = response.trim();
|
405 |
-
if (
|
406 |
-
jQuery(
|
407 |
-
}
|
408 |
}
|
409 |
</script>
|
410 |
-
|
411 |
}
|
412 |
}
|
413 |
|
@@ -426,49 +482,49 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
426 |
// check for rtMedia Instagram version
|
427 |
if ( defined( 'RTMEDIA_INSTAGRAM_PATH' ) ) {
|
428 |
$plugin_info = get_plugin_data( RTMEDIA_INSTAGRAM_PATH . 'index.php' );
|
429 |
-
if ( isset( $plugin_info[
|
430 |
$return_falg = true;
|
431 |
}
|
432 |
-
} elseif( defined( 'RTMEDIA_PHOTO_TAGGING_PATH' ) ){
|
433 |
// check for rtMedia Photo Tagging version
|
434 |
$plugin_info = get_plugin_data( RTMEDIA_PHOTO_TAGGING_PATH . 'index.php' );
|
435 |
-
if ( isset( $plugin_info[
|
436 |
$return_falg = true;
|
437 |
}
|
438 |
-
} elseif( defined( 'RTMEDIA_FFMPEG_PATH' ) ){
|
439 |
// check for rtMedia FFPMEG version
|
440 |
$plugin_info = get_plugin_data( RTMEDIA_FFMPEG_PATH . 'index.php' );
|
441 |
-
if ( isset( $plugin_info[
|
442 |
$return_falg = true;
|
443 |
}
|
444 |
-
} elseif( defined( 'RTMEDIA_KALTURA_PATH' ) ){
|
445 |
// check for rtMedia Kaltura version
|
446 |
$plugin_info = get_plugin_data( RTMEDIA_KALTURA_PATH . 'index.php' );
|
447 |
-
if ( isset( $plugin_info[
|
448 |
$return_falg = true;
|
449 |
}
|
450 |
-
} elseif( defined( 'RTMEDIA_PRO_PATH' ) ){
|
451 |
// check for rtMedia Pro version
|
452 |
$plugin_info = get_plugin_data( RTMEDIA_PRO_PATH . 'index.php' );
|
453 |
-
if ( isset( $plugin_info[
|
454 |
$return_falg = true;
|
455 |
}
|
456 |
-
} elseif( defined( 'RTMEDIA_SOCIAL_SYNC_PATH' ) ){
|
457 |
// check for rtMedia Social Sync version
|
458 |
$plugin_info = get_plugin_data( RTMEDIA_SOCIAL_SYNC_PATH . 'index.php' );
|
459 |
-
if ( isset( $plugin_info[
|
460 |
$return_falg = true;
|
461 |
}
|
462 |
-
} elseif( defined( 'RTMEDIA_MEMBERSHIP_PATH' ) ){
|
463 |
// check for rtMedia Membership version
|
464 |
$plugin_info = get_plugin_data( RTMEDIA_MEMBERSHIP_PATH . 'index.php' );
|
465 |
-
if ( isset( $plugin_info[
|
466 |
$return_falg = true;
|
467 |
}
|
468 |
-
} elseif( defined( 'RTMEDIA_WATERMARK_PATH' ) ){
|
469 |
// check for rtMedia Photo Watermak version
|
470 |
$plugin_info = get_plugin_data( RTMEDIA_WATERMARK_PATH . 'index.php' );
|
471 |
-
if ( isset( $plugin_info[
|
472 |
$return_falg = true;
|
473 |
}
|
474 |
}
|
@@ -505,7 +561,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
505 |
?>
|
506 |
<div class='rtmedia-admin-ad'>
|
507 |
<a href='https://rtmedia.io/products/rtmedia-pro/' target='_blank' title='rtMedia Pro'>
|
508 |
-
<img src='<?php echo $src; ?>' alt="<?php
|
509 |
</a>
|
510 |
</div>
|
511 |
<?php
|
@@ -526,69 +582,83 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
526 |
<div class="clearfix">
|
527 |
|
528 |
<div class="rtm-column alignleft">
|
529 |
-
<h4 class="sub"><?php
|
530 |
|
531 |
<table>
|
532 |
<tbody>
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
<?php
|
547 |
-
|
|
|
|
|
548 |
}
|
549 |
}
|
550 |
-
|
|
|
551 |
</tbody>
|
552 |
</table>
|
553 |
</div>
|
554 |
|
555 |
<div class="rtm-column alignright">
|
556 |
-
<h4 class="sub"><?php
|
557 |
|
558 |
<table>
|
559 |
<tbody> <?php
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
<?php
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
?>
|
579 |
-
<
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
$
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
592 |
</tbody>
|
593 |
</table>
|
594 |
</div>
|
@@ -597,10 +667,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
597 |
|
598 |
<div class="rtm-meta-container">
|
599 |
<ul class="rtm-meta-links">
|
600 |
-
<li><b><?php
|
601 |
-
<li><a href="https://rtmedia.io/"><?php
|
602 |
-
<li
|
603 |
-
|
|
|
|
|
|
|
|
|
604 |
</ul>
|
605 |
</div>
|
606 |
<?php
|
@@ -616,18 +690,21 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
616 |
* @return void
|
617 |
*/
|
618 |
public function add_dashboard_widgets() {
|
619 |
-
wp_add_dashboard_widget( 'rtmedia_dashboard_widget',
|
|
|
|
|
|
|
620 |
global $wp_meta_boxes;
|
621 |
|
622 |
// Get the regular dashboard widgets array
|
623 |
// (which has our new widget already but at the end)
|
624 |
|
625 |
-
$normal_dashboard = $wp_meta_boxes[
|
626 |
|
627 |
// Backup and delete our new dashboard widget from the end of the array
|
628 |
|
629 |
-
$example_widget_backup = array( 'rtmedia_dashboard_widget' => $normal_dashboard[
|
630 |
-
unset( $normal_dashboard[
|
631 |
|
632 |
// Merge the two arrays together so our widget is at the beginning
|
633 |
|
@@ -635,7 +712,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
635 |
|
636 |
// Save the sorted array back into the original metaboxes
|
637 |
|
638 |
-
$wp_meta_boxes[
|
639 |
}
|
640 |
|
641 |
/**
|
@@ -648,9 +725,9 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
648 |
* @return array $links
|
649 |
*/
|
650 |
public function plugin_add_settings_link( $links ) {
|
651 |
-
$settings_link = '<a href="' . admin_url( 'admin.php?page=rtmedia-settings' ) . '">Settings</a>';
|
652 |
array_push( $links, $settings_link );
|
653 |
-
$settings_link = '<a href="' . admin_url( 'admin.php?page=rtmedia-support' ) . '">Support</a>';
|
654 |
array_push( $links, $settings_link );
|
655 |
|
656 |
return $links;
|
@@ -661,7 +738,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
661 |
*
|
662 |
* @access public
|
663 |
*
|
664 |
-
* @param array
|
665 |
* @param object $post
|
666 |
*
|
667 |
* @return array $actions
|
@@ -669,8 +746,8 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
669 |
public function add_reencode_link( $actions, $post ) {
|
670 |
|
671 |
$mime_type_array = explode( '/', $post->post_mime_type );
|
672 |
-
if ( is_array( $mime_type_array ) && ''
|
673 |
-
$actions[
|
674 |
}
|
675 |
|
676 |
return $actions;
|
@@ -686,8 +763,10 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
686 |
* @return void
|
687 |
*/
|
688 |
public function bulk_action_handler() {
|
689 |
-
|
690 |
-
|
|
|
|
|
691 |
exit;
|
692 |
}
|
693 |
}
|
@@ -697,7 +776,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
697 |
*
|
698 |
* @access public
|
699 |
*
|
700 |
-
* @param
|
701 |
*
|
702 |
* @return void
|
703 |
*/
|
@@ -707,80 +786,86 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
707 |
}
|
708 |
|
709 |
$admin_bar->add_menu( array(
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
);
|
718 |
$admin_bar->add_menu( array(
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
);
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
|
|
738 |
)
|
739 |
-
|
|
|
740 |
$admin_bar->add_menu( array(
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
);
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
|
|
760 |
)
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
|
|
|
|
771 |
)
|
772 |
-
|
|
|
773 |
if ( has_filter( 'rtmedia_license_tabs' ) || has_action( 'rtmedia_addon_license_details' ) ) {
|
774 |
$admin_bar->add_menu( array(
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
);
|
785 |
}
|
786 |
}
|
@@ -813,33 +898,33 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
813 |
}
|
814 |
|
815 |
$admin_pages = apply_filters( 'rtmedia_filter_admin_pages_array', $admin_pages );
|
816 |
-
$suffix
|
817 |
|
818 |
-
if ( in_array( $hook, $admin_pages ) || strpos( $hook, 'rtmedia-migration' ) ) {
|
819 |
|
820 |
$admin_ajax = admin_url( 'admin-ajax.php' );
|
821 |
|
822 |
/* Only one JS file should enqueue */
|
823 |
-
if(
|
824 |
wp_enqueue_script( 'rtmedia-admin-tabs', RTMEDIA_URL . 'app/assets/admin/js/vendors/tabs.js', array( 'backbone' ), RTMEDIA_VERSION );
|
825 |
wp_enqueue_script( 'rtmedia-admin-scripts', RTMEDIA_URL . 'app/assets/admin/js/scripts.js', array( 'backbone' ), RTMEDIA_VERSION );
|
826 |
-
wp_enqueue_script( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/admin/js/settings.js', array( 'backbone' ), RTMEDIA_VERSION );
|
827 |
} else {
|
828 |
-
wp_enqueue_script( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/admin/js/admin.min.js', array( 'backbone' ), RTMEDIA_VERSION );
|
829 |
}
|
830 |
|
831 |
-
wp_localize_script( 'rtmedia-admin', 'rtmedia_on_label',
|
832 |
-
wp_localize_script( 'rtmedia-admin', 'rtmedia_off_label',
|
833 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_ajax', $admin_ajax );
|
834 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
|
835 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
|
836 |
|
837 |
$rtmedia_admin_strings = array(
|
838 |
-
'no_refresh'
|
839 |
-
'something_went_wrong' =>
|
840 |
-
'are_you_sure'
|
841 |
-
'disable_encoding'
|
842 |
-
'enable_encoding'
|
843 |
);
|
844 |
|
845 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_strings', $rtmedia_admin_strings );
|
@@ -866,20 +951,53 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
866 |
* @return void
|
867 |
*/
|
868 |
public function menu() {
|
869 |
-
add_menu_page( 'rtMedia', 'rtMedia', 'manage_options', 'rtmedia-settings', array(
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
add_submenu_page( 'rtmedia-settings',
|
874 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
875 |
if ( has_filter( 'rtmedia_license_tabs' ) || has_action( 'rtmedia_addon_license_details' ) ) {
|
876 |
-
add_submenu_page( 'rtmedia-settings',
|
|
|
|
|
|
|
877 |
}
|
878 |
|
879 |
$obj_encoding = new RTMediaEncoding( true );
|
880 |
|
881 |
if ( $obj_encoding->api_key ) {
|
882 |
-
add_submenu_page( 'rtmedia-settings',
|
|
|
|
|
|
|
883 |
}
|
884 |
}
|
885 |
|
@@ -894,28 +1012,53 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
894 |
*/
|
895 |
public function rt_regenerate_thumbnail() {
|
896 |
$prog = new rtProgress();
|
897 |
-
$done = 0;
|
898 |
?>
|
899 |
<div class="wrap">
|
900 |
-
<h2>
|
901 |
<?php
|
902 |
-
|
|
|
903 |
$requested = false;
|
904 |
-
$media_ids = explode( ',', $
|
905 |
-
$total
|
906 |
} else {
|
907 |
-
$media_ids =
|
908 |
-
|
|
|
|
|
909 |
}
|
910 |
?>
|
911 |
<script>
|
912 |
-
var rt_thumb_all_media = <?php echo
|
913 |
</script>
|
914 |
<?php
|
915 |
if ( ! isset( $requested ) ) {
|
916 |
?>
|
917 |
<br/>
|
918 |
-
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
919 |
<?php
|
920 |
}
|
921 |
?>
|
@@ -925,65 +1068,70 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
925 |
$temp = $prog->progress( $done, $total );
|
926 |
$prog->progress_ui( $temp, true );
|
927 |
?>
|
928 |
-
<p> <?php
|
|
|
929 |
</p>
|
930 |
|
931 |
-
<p> <?php
|
|
|
932 |
|
933 |
-
<p> <?php
|
|
|
934 |
|
935 |
</div>
|
936 |
<script>
|
937 |
|
938 |
var db_done = 0;
|
939 |
var db_fail = 0;
|
940 |
-
var db_total = <?php echo $total; ?>;
|
941 |
var indx = 0;
|
942 |
function db_start_regenrate() {
|
943 |
-
if (
|
944 |
-
jQuery.ajax(
|
945 |
url: rtmedia_admin_ajax,
|
946 |
type: 'post',
|
947 |
data: {
|
948 |
"action": "rt_media_regeneration",
|
949 |
-
"media_id": rt_thumb_all_media[indx
|
|
|
950 |
},
|
951 |
-
success: function (
|
952 |
-
data = JSON.parse(
|
953 |
|
954 |
-
if (
|
955 |
handle_regenrate_fail();
|
956 |
} else {
|
957 |
-
db_done
|
958 |
-
var progw = Math.ceil(
|
959 |
-
if (
|
960 |
progw = 100;
|
961 |
}
|
962 |
-
jQuery(
|
963 |
-
jQuery(
|
964 |
db_start_regenrate();
|
965 |
}
|
966 |
},
|
967 |
error: function () {
|
968 |
handle_regenrate_fail();
|
969 |
}
|
970 |
-
}
|
971 |
} else {
|
972 |
-
alert(
|
973 |
}
|
974 |
}
|
975 |
function handle_regenrate_fail() {
|
976 |
-
db_fail
|
977 |
-
jQuery(
|
978 |
db_start_regenrate();
|
979 |
}
|
980 |
-
|
981 |
-
|
982 |
-
jQuery(
|
983 |
-
|
984 |
-
jQuery(
|
|
|
985 |
db_start_regenrate();
|
986 |
-
}
|
987 |
} else {
|
988 |
db_start_regenrate();
|
989 |
}
|
@@ -1007,24 +1155,28 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1007 |
$obj_encoding = new RTMediaEncoding( true );
|
1008 |
if ( $obj_encoding->api_key ) {
|
1009 |
$site_option = rtmedia_get_site_option( 'rtmedia-video-thumb-notice' );
|
1010 |
-
if ( ! $site_option || 'hide'
|
1011 |
rtmedia_update_site_option( 'rtmedia-video-thumb-notice', 'show' );
|
1012 |
$videos_without_thumbs = get_video_without_thumbs();
|
1013 |
-
if ( isset( $videos_without_thumbs ) && is_array( $videos_without_thumbs ) &&
|
1014 |
-
echo '<div class="error rtmedia-regenerate-video-thumb-error">
|
1015 |
-
<p>
|
1016 |
-
' . sprintf( __( "You have %s videos without thumbnails. Click <a href='%s'> here </a> to generate thumbnails. <a href='#' onclick='rtmedia_hide_video_thumb_notice()' style='float:right'>Hide</a>", 'buddypress-media' ), sizeof( $videos_without_thumbs ), admin_url( 'admin.php?page=rtmedia-regenerate' ) ) . '
|
1017 |
-
</p>
|
1018 |
-
</div>';
|
1019 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1020 |
<script type="text/javascript">
|
1021 |
function rtmedia_hide_video_thumb_notice() {
|
1022 |
-
var data = {
|
1023 |
-
jQuery.post(
|
1024 |
response = response.trim();
|
1025 |
-
if (
|
1026 |
-
jQuery(
|
1027 |
-
}
|
1028 |
}
|
1029 |
</script>
|
1030 |
<?php
|
@@ -1043,7 +1195,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1043 |
* @return void
|
1044 |
*/
|
1045 |
public function rtmedia_hide_video_thumb_admin_notice() {
|
1046 |
-
if ( rtmedia_update_site_option( 'rtmedia-video-thumb-notice', 'hide' ) ) {
|
1047 |
echo '1';
|
1048 |
} else {
|
1049 |
echo '0';
|
@@ -1061,7 +1213,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1061 |
* @return void
|
1062 |
*/
|
1063 |
public function rtmedia_hide_addon_update_notice() {
|
1064 |
-
if ( rtmedia_update_site_option( 'rtmedia-addon-update-notice-3_8', 'hide' ) ) {
|
1065 |
echo '1';
|
1066 |
} else {
|
1067 |
echo '0';
|
@@ -1079,43 +1231,29 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1079 |
* @return void
|
1080 |
*/
|
1081 |
public function rt_media_regeneration() {
|
1082 |
-
if (
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
|
|
|
|
|
|
|
|
1092 |
} else {
|
1093 |
-
$response[
|
1094 |
-
$response[
|
1095 |
}
|
1096 |
-
echo
|
1097 |
die();
|
1098 |
}
|
1099 |
}
|
1100 |
|
1101 |
-
/**
|
1102 |
-
* Get video without thumbs.
|
1103 |
-
*
|
1104 |
-
* @access public
|
1105 |
-
*
|
1106 |
-
* @param void
|
1107 |
-
*
|
1108 |
-
* @return object $results
|
1109 |
-
*/
|
1110 |
-
public function get_video_without_thumbs() {
|
1111 |
-
$rtmedia_model = new RTMediaModel();
|
1112 |
-
$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";
|
1113 |
-
global $wpdb;
|
1114 |
-
$results = $wpdb->get_col( $sql );
|
1115 |
-
|
1116 |
-
return $results;
|
1117 |
-
}
|
1118 |
-
|
1119 |
/**
|
1120 |
* Render the BuddyPress Media Settings page.
|
1121 |
*
|
@@ -1231,10 +1369,11 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1231 |
*
|
1232 |
* @param void
|
1233 |
*
|
1234 |
-
* @return
|
1235 |
*/
|
1236 |
static function get_current_tab() {
|
1237 |
-
|
|
|
1238 |
}
|
1239 |
|
1240 |
/**
|
@@ -1243,21 +1382,24 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1243 |
* @access public
|
1244 |
* @global string 'buddypress-media'
|
1245 |
*
|
1246 |
-
* @param
|
1247 |
-
* @param
|
1248 |
*
|
1249 |
* @return void
|
1250 |
*/
|
1251 |
public function render_page( $page, $option_group = null ) {
|
1252 |
?>
|
1253 |
|
1254 |
-
<div class="wrap bp-media-admin <?php echo $this->get_current_tab(); ?>">
|
1255 |
<div id="icon-buddypress-media" class="icon32"><br></div>
|
1256 |
<div>
|
1257 |
<h2 class="nav-tab-wrapper"><?php $this->rtmedia_tabs(); ?>
|
1258 |
<span class="alignright by">
|
1259 |
-
<a class="rt-link"
|
1260 |
-
|
|
|
|
|
|
|
1261 |
</a>
|
1262 |
</span>
|
1263 |
</h2>
|
@@ -1268,57 +1410,67 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1268 |
<div id="bp-media-settings-boxes" class="bp-media-settings-boxes-container rtm-setting-container">
|
1269 |
|
1270 |
<?php
|
1271 |
-
|
1272 |
-
if ( $page == 'rtmedia-settings' ) {
|
1273 |
?>
|
1274 |
<form id="bp_media_settings_form" name="bp_media_settings_form" method="post"
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
<input type="submit" class="rtmedia-settings-submit button button-primary button-big" value="<?php _e( 'Save Settings', 'buddypress-media' ); ?>">
|
1283 |
-
</div>
|
1284 |
-
<?php
|
1285 |
-
settings_fields( $option_group );
|
1286 |
-
if ( 'rtmedia-settings' == $page ) {
|
1287 |
-
echo '<div id="rtm-settings-tabs">';
|
1288 |
-
$sub_tabs = $this->settings_sub_tabs();
|
1289 |
-
RTMediaFormHandler::rtForm_settings_tabs_content( $page, $sub_tabs );
|
1290 |
-
echo '</div>';
|
1291 |
-
} else {
|
1292 |
-
do_settings_sections( $page );
|
1293 |
-
}
|
1294 |
-
?>
|
1295 |
-
|
1296 |
-
<div class="rtm-button-container bottom">
|
1297 |
-
<div class="rtm-social-links alignleft">
|
1298 |
-
<a href="http://twitter.com/rtMediaWP" class="twitter" target= "_blank"><span class="dashicons dashicons-twitter"></span></a>
|
1299 |
-
<a href="https://www.facebook.com/rtmediawp" class="facebook" target="_blank"><span class="dashicons dashicons-facebook"></span></a>
|
1300 |
-
<a href="http://profiles.wordpress.org/rtcamp" class="wordpress" target= "_blank"><span class="dashicons dashicons-wordpress"></span></a>
|
1301 |
-
<a href="https://rtmedia.io/feed/" class="rss" target="_blank"><span class="dashicons dashicons-rss"></span></a>
|
1302 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1303 |
|
1304 |
-
|
1305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1306 |
</div>
|
|
|
|
|
|
|
|
|
|
|
1307 |
</div>
|
|
|
1308 |
</form><?php
|
1309 |
} else {
|
1310 |
?>
|
1311 |
<div class="bp-media-metabox-holder">
|
1312 |
<?php
|
1313 |
-
if ( 'rtmedia-addons'
|
1314 |
RTMediaAddon::render_addons( $page );
|
1315 |
-
} else if ( 'rtmedia-support'
|
1316 |
$rtmedia_support = new RTMediaSupport( false );
|
1317 |
$rtmedia_support->render_support( $page );
|
1318 |
-
} else if ( 'rtmedia-themes'
|
1319 |
RTMediaThemes::render_themes( $page );
|
1320 |
} else {
|
1321 |
-
if ( 'rtmedia-license'
|
1322 |
RTMediaLicense::render_license( $page );
|
1323 |
} else {
|
1324 |
do_settings_sections( $page );
|
@@ -1346,34 +1498,32 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1346 |
* Adds a tab for Media settings in the BuddyPress settings page
|
1347 |
*
|
1348 |
* @access public
|
1349 |
-
* @global type $bp_media
|
1350 |
*
|
1351 |
* @param void
|
1352 |
* @param void
|
1353 |
*
|
1354 |
-
* @return
|
1355 |
*/
|
1356 |
public function tab() {
|
1357 |
|
1358 |
-
$tabs_html
|
1359 |
-
$idle_class
|
1360 |
$active_class = 'nav-tab nav-tab-active';
|
1361 |
-
$tabs
|
1362 |
|
1363 |
// Check to see which tab we are on
|
1364 |
$tab = $this->get_current_tab();
|
1365 |
/* rtMedia */
|
1366 |
$tabs[] = array(
|
1367 |
-
'href'
|
1368 |
-
'title' =>
|
1369 |
-
'name'
|
1370 |
-
'class' => (
|
1371 |
);
|
1372 |
|
1373 |
foreach ( $tabs as $tab ) {
|
1374 |
-
|
1375 |
}
|
1376 |
-
echo $tabs_html;
|
1377 |
}
|
1378 |
|
1379 |
/**
|
@@ -1381,45 +1531,53 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1381 |
*
|
1382 |
* @access public
|
1383 |
*
|
1384 |
-
* @param
|
1385 |
*
|
1386 |
* @return void
|
1387 |
*/
|
1388 |
-
public function rtmedia_tabs(
|
1389 |
// Declare local variables
|
1390 |
-
$
|
1391 |
-
$idle_class = 'nav-tab';
|
1392 |
$active_class = 'nav-tab nav-tab-active';
|
1393 |
|
1394 |
// Setup core admin tabs
|
1395 |
$tabs = array(
|
1396 |
array(
|
1397 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-settings' ), 'admin.php' ) ) ),
|
1398 |
-
'name' =>
|
1399 |
'slug' => 'rtmedia-settings',
|
1400 |
-
),
|
|
|
1401 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-addons' ), 'admin.php' ) ) ),
|
1402 |
-
'name' =>
|
1403 |
'slug' => 'rtmedia-addons',
|
1404 |
-
),
|
|
|
|
|
|
|
|
|
1405 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-themes' ), 'admin.php' ) ) ),
|
1406 |
-
'name' =>
|
1407 |
'slug' => 'rtmedia-themes',
|
1408 |
-
)
|
|
|
|
|
1409 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-hire-us' ), 'admin.php' ) ) ),
|
1410 |
-
'name' =>
|
1411 |
'slug' => 'rtmedia-hire-us',
|
1412 |
-
)
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
),
|
|
|
|
|
1417 |
);
|
1418 |
|
1419 |
if ( has_filter( 'rtmedia_license_tabs' ) || has_action( 'rtmedia_addon_license_details' ) ) {
|
1420 |
$tabs[] = array(
|
1421 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-license' ), 'admin.php' ) ) ),
|
1422 |
-
'name' =>
|
1423 |
'slug' => 'rtmedia-license',
|
1424 |
);
|
1425 |
}
|
@@ -1428,21 +1586,15 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1428 |
|
1429 |
// Loop through tabs and build navigation
|
1430 |
foreach ( array_values( $tabs ) as $tab_data ) {
|
1431 |
-
$is_current = (
|
1432 |
-
$tab_class
|
1433 |
|
1434 |
-
if ( isset( $tab_data[
|
1435 |
-
$tab_class .= ' ' . implode( ' ', $tab_data[
|
1436 |
}
|
1437 |
|
1438 |
-
|
1439 |
}
|
1440 |
-
|
1441 |
-
// Output the tabs
|
1442 |
-
echo $tabs_html;
|
1443 |
-
|
1444 |
-
// // Do other fun things
|
1445 |
-
// do_action('bp_media_admin_tabs');
|
1446 |
}
|
1447 |
|
1448 |
/**
|
@@ -1450,7 +1602,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1450 |
*
|
1451 |
* @access public
|
1452 |
*
|
1453 |
-
* @param
|
1454 |
*
|
1455 |
* @return void
|
1456 |
*/
|
@@ -1461,21 +1613,21 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1461 |
return;
|
1462 |
}
|
1463 |
|
1464 |
-
foreach ( (
|
1465 |
-
if ( $section[
|
1466 |
-
|
1467 |
}
|
1468 |
|
1469 |
-
if ( $section[
|
1470 |
-
call_user_func( $section[
|
1471 |
}
|
1472 |
|
1473 |
-
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section[
|
1474 |
continue;
|
1475 |
}
|
1476 |
|
1477 |
echo '<table class="form-table">';
|
1478 |
-
do_settings_fields( $page, $section[
|
1479 |
echo '</table>';
|
1480 |
}
|
1481 |
}
|
@@ -1484,131 +1636,80 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1484 |
* Adds a sub tabs to the BuddyPress Media settings page
|
1485 |
*
|
1486 |
* @access public
|
1487 |
-
* @global type $bp_media
|
1488 |
*
|
1489 |
* @param void
|
1490 |
*
|
1491 |
* @return array $tabs
|
1492 |
*/
|
1493 |
public function settings_sub_tabs() {
|
1494 |
-
$
|
1495 |
-
$tabs = array();
|
1496 |
|
1497 |
// Check to see which tab we are on
|
1498 |
$tab = $this->get_current_tab();
|
1499 |
/* rtMedia */
|
1500 |
|
1501 |
-
$tabs[
|
1502 |
-
'href'
|
1503 |
-
'icon'
|
1504 |
-
'title'
|
1505 |
-
'name'
|
1506 |
-
'callback' => array( 'RTMediaFormHandler', 'display_content' )
|
1507 |
);
|
1508 |
|
1509 |
if ( class_exists( 'BuddyPress' ) ) {
|
1510 |
-
$tabs[
|
1511 |
-
'href'
|
1512 |
-
'icon'
|
1513 |
-
'title'
|
1514 |
-
'name'
|
1515 |
-
'callback' => array( 'RTMediaFormHandler', 'buddypress_content' ) //change it to BuddyPress Content
|
1516 |
);
|
1517 |
}
|
1518 |
|
1519 |
-
$tabs[
|
1520 |
-
'href'
|
1521 |
-
'icon'
|
1522 |
-
'title'
|
1523 |
-
'name'
|
1524 |
-
'callback' => array( 'RTMediaFormHandler', 'types_content' )
|
1525 |
);
|
1526 |
|
1527 |
-
$tabs[
|
1528 |
-
'href'
|
1529 |
-
'icon'
|
1530 |
-
'title'
|
1531 |
-
'name'
|
1532 |
-
'callback' => array( 'RTMediaFormHandler', 'sizes_content' )
|
1533 |
);
|
1534 |
|
1535 |
-
$tabs[
|
1536 |
-
'href'
|
1537 |
-
'icon'
|
1538 |
-
'title'
|
1539 |
-
'name'
|
1540 |
-
'callback' => array( 'RTMediaFormHandler', 'privacy_content' )
|
1541 |
);
|
1542 |
-
$tabs[
|
1543 |
-
'href'
|
1544 |
-
'icon'
|
1545 |
-
'title'
|
1546 |
-
'name'
|
1547 |
-
'callback' => array( 'RTMediaFormHandler', 'custom_css_content' )
|
1548 |
);
|
1549 |
|
1550 |
$tabs = apply_filters( 'rtmedia_add_settings_sub_tabs', $tabs, $tab );
|
1551 |
|
1552 |
$tabs[] = array(
|
1553 |
-
'href'
|
1554 |
-
'icon'
|
1555 |
-
'title'
|
1556 |
-
'name'
|
1557 |
-
'callback' => array( 'RTMediaFormHandler', 'general_content' )
|
1558 |
);
|
1559 |
|
1560 |
return $tabs;
|
1561 |
}
|
1562 |
|
1563 |
-
/**
|
1564 |
-
* Updates the media count of all users.
|
1565 |
-
*
|
1566 |
-
* @access public
|
1567 |
-
* @global type $wpdb
|
1568 |
-
*
|
1569 |
-
* @param void
|
1570 |
-
*
|
1571 |
-
* @return boolean
|
1572 |
-
*/
|
1573 |
-
public function update_count() {
|
1574 |
-
global $wpdb;
|
1575 |
-
|
1576 |
-
$query = "SELECT
|
1577 |
-
p.post_author,pmp.meta_value,
|
1578 |
-
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
|
1579 |
-
SUM(CASE WHEN post_mime_type LIKE 'music%' THEN 1 ELSE 0 END) as Music,
|
1580 |
-
SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
|
1581 |
-
SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums
|
1582 |
-
FROM
|
1583 |
-
$wpdb->posts p inner join $wpdb->postmeta pm on pm.post_id = p.id INNER JOIN $wpdb->postmeta pmp
|
1584 |
-
on pmp.post_id = p.id WHERE
|
1585 |
-
pm.meta_key = 'bp-media-key' AND
|
1586 |
-
pm.meta_value > 0 AND
|
1587 |
-
pmp.meta_key = 'bp_media_privacy' AND
|
1588 |
-
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'music%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
|
1589 |
-
GROUP BY p.post_author,pmp.meta_value order by p.post_author";
|
1590 |
-
|
1591 |
-
$result = $wpdb->get_results( $query );
|
1592 |
-
|
1593 |
-
if ( ! is_array( $result ) ) {
|
1594 |
-
return false;
|
1595 |
-
}
|
1596 |
-
|
1597 |
-
$formatted = array();
|
1598 |
-
|
1599 |
-
foreach ( $result as $obj ) {
|
1600 |
-
$formatted[ $obj->post_author ][ $obj->meta_value ] = array(
|
1601 |
-
'image' => $obj->Images, 'video' => $obj->Videos, 'music' => $obj->Music, 'album' => $obj->Albums,
|
1602 |
-
);
|
1603 |
-
}
|
1604 |
-
|
1605 |
-
foreach ( $formatted as $user => $obj ) {
|
1606 |
-
update_user_meta( $user, 'rtmedia_count', $obj );
|
1607 |
-
}
|
1608 |
-
|
1609 |
-
return true;
|
1610 |
-
}
|
1611 |
-
|
1612 |
/**
|
1613 |
* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503
|
1614 |
*
|
@@ -1621,16 +1722,18 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1621 |
*/
|
1622 |
public function save_multisite_options() {
|
1623 |
global $rtmedia_admin;
|
1624 |
-
|
1625 |
-
$rtmedia_admin->update_count();
|
1626 |
-
}
|
1627 |
-
do_action( 'rtmedia_sanitize_settings', $_POST );
|
1628 |
|
1629 |
-
|
1630 |
-
|
|
|
|
|
1631 |
//
|
1632 |
// redirect to settings page in network
|
1633 |
-
wp_redirect( esc_url_raw( add_query_arg( array(
|
|
|
|
|
|
|
1634 |
exit;
|
1635 |
}
|
1636 |
}
|
@@ -1639,7 +1742,6 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1639 |
* Admin Sidebar
|
1640 |
*
|
1641 |
* @access public
|
1642 |
-
* @global type $bp_media
|
1643 |
*
|
1644 |
* @param void
|
1645 |
*
|
@@ -1648,62 +1750,72 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1648 |
public function admin_sidebar() {
|
1649 |
do_action( 'rtmedia_before_default_admin_widgets' );
|
1650 |
$current_user = wp_get_current_user();
|
1651 |
-
$message
|
1652 |
-
$addons
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
|
1659 |
-
new RTMediaAdminWidget( 'spread-the-word',
|
1660 |
|
1661 |
$branding = '<form action="http://rtcamp.us1.list-manage1.com/subscribe/post?u=85b65c9c71e2ba3fab8cb1950&id=9e8ded4470" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
new RTMediaAdminWidget( 'branding',
|
1673 |
-
|
1674 |
-
$news = '<img src ="' . admin_url( '/images/wpspin_light.gif' ) . '" /> Loading...';
|
1675 |
-
//new RTMediaAdminWidget ( 'latest-news', __( 'Latest News', 'buddypress-media' ), $news );
|
1676 |
do_action( 'rtmedia_after_default_admin_widgets' );
|
1677 |
}
|
1678 |
|
1679 |
public function linkback() {
|
1680 |
-
|
|
|
|
|
1681 |
return rtmedia_update_site_option( 'rtmedia-add-linkback', true );
|
1682 |
} else {
|
1683 |
return rtmedia_update_site_option( 'rtmedia-add-linkback', false );
|
1684 |
}
|
1685 |
-
die;
|
1686 |
}
|
1687 |
|
1688 |
public function convert_videos_mailchimp_send() {
|
1689 |
-
|
1690 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1691 |
} else {
|
1692 |
rtmedia_update_site_option( 'rtmedia-survey', 0 );
|
1693 |
}
|
1694 |
-
|
1695 |
-
|
1696 |
}
|
1697 |
|
1698 |
public function video_transcoding_survey_response() {
|
1699 |
-
|
|
|
1700 |
rtmedia_update_site_option( 'rtmedia-survey', 0 );
|
1701 |
}
|
1702 |
}
|
1703 |
|
1704 |
-
public function plugin_meta_premium_addon_link( $plugin_meta, $plugin_file
|
1705 |
-
if ( plugin_basename( RTMEDIA_PATH . 'index.php' )
|
1706 |
-
$plugin_meta[] = '<a href="https://rtmedia.io/products/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media" title="' .
|
1707 |
}
|
1708 |
|
1709 |
return $plugin_meta;
|
@@ -1713,63 +1825,90 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1713 |
global $rtmedia;
|
1714 |
$upload_filetypes = rtmedia_get_site_option( 'upload_filetypes', 'jpg jpeg png gif' );
|
1715 |
$upload_filetypes = explode( ' ', $upload_filetypes );
|
1716 |
-
$flag
|
1717 |
-
if ( isset( $rtmedia->options[
|
1718 |
$not_supported_image = array_diff( array( 'jpg', 'jpeg', 'png', 'gif' ), $upload_filetypes );
|
1719 |
if ( ! empty( $not_supported_image ) ) {
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1726 |
$flag = true;
|
1727 |
}
|
1728 |
}
|
1729 |
-
if ( isset( $rtmedia->options[
|
1730 |
-
if ( ! in_array( 'mp4', $upload_filetypes ) ) {
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1737 |
$flag = true;
|
1738 |
}
|
1739 |
}
|
1740 |
-
if ( isset( $rtmedia->options[
|
1741 |
-
if ( ! in_array( 'mp3', $upload_filetypes ) ) {
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1746 |
$flag = true;
|
1747 |
}
|
1748 |
}
|
1749 |
if ( $flag ) {
|
1750 |
?>
|
1751 |
<script type="text/javascript">
|
1752 |
-
jQuery(
|
1753 |
-
jQuery(
|
1754 |
-
jQuery(
|
1755 |
-
jQuery.post(
|
1756 |
-
if (
|
1757 |
-
jQuery(
|
1758 |
-
jQuery(
|
1759 |
-
jQuery(
|
1760 |
}
|
1761 |
-
}
|
1762 |
-
}
|
1763 |
</script>
|
1764 |
<?php
|
1765 |
}
|
1766 |
}
|
1767 |
|
1768 |
public function correct_upload_filetypes() {
|
|
|
|
|
|
|
1769 |
global $rtmedia;
|
1770 |
$upload_filetypes_orig = $upload_filetypes = rtmedia_get_site_option( 'upload_filetypes', 'jpg jpeg png gif' );
|
1771 |
-
$upload_filetypes
|
1772 |
-
if ( isset( $rtmedia->options[
|
1773 |
$not_supported_image = array_diff( array( 'jpg', 'jpeg', 'png', 'gif' ), $upload_filetypes );
|
1774 |
if ( ! empty( $not_supported_image ) ) {
|
1775 |
$update_image_support = null;
|
@@ -1782,48 +1921,49 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1782 |
}
|
1783 |
}
|
1784 |
}
|
1785 |
-
if ( isset( $rtmedia->options[
|
1786 |
-
if ( ! in_array( 'mp4', $upload_filetypes ) ) {
|
1787 |
$upload_filetypes_orig .= ' mp4';
|
1788 |
rtmedia_update_site_option( 'upload_filetypes', $upload_filetypes_orig );
|
1789 |
}
|
1790 |
}
|
1791 |
-
if ( isset( $rtmedia->options[
|
1792 |
-
if ( ! in_array( 'mp3', $upload_filetypes ) ) {
|
1793 |
$upload_filetypes_orig .= ' mp3';
|
1794 |
rtmedia_update_site_option( 'upload_filetypes', $upload_filetypes_orig );
|
1795 |
}
|
1796 |
}
|
1797 |
echo true;
|
1798 |
-
|
1799 |
}
|
1800 |
|
1801 |
function edit_video_thumbnail( $form_fields, $post ) {
|
1802 |
if ( isset( $post->post_mime_type ) ) {
|
1803 |
$media_type = explode( '/', $post->post_mime_type );
|
1804 |
-
if ( is_array( $media_type ) && 'video'
|
1805 |
-
$media_id
|
1806 |
-
$thumbnail_array
|
1807 |
-
$rtmedia_model
|
1808 |
-
$rtmedia_media
|
1809 |
$video_thumb_html = '';
|
1810 |
if ( is_array( $thumbnail_array ) ) {
|
1811 |
$video_thumb_html .= '<ul> ';
|
1812 |
|
1813 |
foreach ( $thumbnail_array as $key => $thumbnail_src ) {
|
1814 |
-
$checked = checked( $thumbnail_src, $rtmedia_media[
|
1815 |
-
$count
|
1816 |
$video_thumb_html .= '<li style="width: 150px;display: inline-block;">
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
</li> ';
|
1822 |
}
|
1823 |
|
1824 |
$video_thumb_html .= ' </ul>';
|
1825 |
-
$form_fields[
|
1826 |
-
'label' => 'Video Thumbnails',
|
|
|
|
|
1827 |
);
|
1828 |
}
|
1829 |
}
|
@@ -1832,13 +1972,15 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1832 |
return $form_fields;
|
1833 |
}
|
1834 |
|
1835 |
-
function save_video_thumbnail( $post
|
1836 |
-
|
|
|
|
|
1837 |
$rtmedia_model = new RTMediaModel();
|
1838 |
-
$model
|
1839 |
-
$media
|
1840 |
-
$media_id
|
1841 |
-
$rtmedia_model->update( array( 'cover_art' => $
|
1842 |
update_activity_after_thumb_set( $media_id );
|
1843 |
}
|
1844 |
|
@@ -1848,23 +1990,23 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1848 |
function rtmedia_regenerate_thumb_js() {
|
1849 |
global $pagenow;
|
1850 |
|
1851 |
-
if ( 'upload.php'
|
1852 |
?>
|
1853 |
<script type="text/javascript">
|
1854 |
-
function rtmedia_regenerate_thumbs(
|
1855 |
-
if (
|
1856 |
var data = {
|
1857 |
action: 'rt_media_regeneration',
|
1858 |
media_id: post_id
|
1859 |
};
|
1860 |
-
jQuery.post(
|
1861 |
-
data = JSON.parse(
|
1862 |
-
if (
|
1863 |
-
alert(
|
1864 |
} else {
|
1865 |
-
alert(
|
1866 |
}
|
1867 |
-
}
|
1868 |
}
|
1869 |
}
|
1870 |
</script>
|
@@ -1875,82 +2017,29 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1875 |
function add_bulk_actions_regenerate() {
|
1876 |
?>
|
1877 |
<script type="text/javascript">
|
1878 |
-
jQuery(
|
1879 |
-
$(
|
1880 |
-
}
|
1881 |
</script>
|
1882 |
<?php
|
1883 |
}
|
1884 |
|
1885 |
-
function presstrends_plugin() {
|
1886 |
-
global $rtmedia;
|
1887 |
-
$option = $rtmedia->options;
|
1888 |
-
if ( ! isset( $option[ 'general_AllowUserData' ] ) ) {
|
1889 |
-
return;
|
1890 |
-
}
|
1891 |
-
if ( '0' == $option[ 'general_AllowUserData' ] ) {
|
1892 |
-
return;
|
1893 |
-
}
|
1894 |
-
// PressTrends Account API Key
|
1895 |
-
$api_key = 'djbzu1no2tdz4qq4u2fpgaemuup2zzmtjulb';
|
1896 |
-
$auth = 'o3w063qppl7ha022jyc3bjpi7usrmczho';
|
1897 |
-
// Start of Metrics
|
1898 |
-
global $wpdb;
|
1899 |
-
$data = get_transient( 'presstrends_cache_data' );
|
1900 |
-
|
1901 |
-
if ( ! $data || $data == '' ) {
|
1902 |
-
$api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update?auth=';
|
1903 |
-
$url = $api_base . $auth . '&api=' . $api_key . '';
|
1904 |
-
$count_posts = wp_count_posts();
|
1905 |
-
$count_pages = wp_count_posts( 'page' );
|
1906 |
-
$comments_count = wp_count_comments();
|
1907 |
-
|
1908 |
-
if ( function_exists( 'wp_get_theme' ) ) {
|
1909 |
-
$theme_data = wp_get_theme();
|
1910 |
-
$theme_name = urlencode( $theme_data->Name );
|
1911 |
-
} else {
|
1912 |
-
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
|
1913 |
-
$theme_name = $theme_data[ 'Name' ];
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
$plugin_name = '&';
|
1917 |
-
|
1918 |
-
foreach ( get_plugins() as $plugin_info ) {
|
1919 |
-
$plugin_name .= $plugin_info[ 'Name' ] . '&';
|
1920 |
-
}
|
1921 |
-
|
1922 |
-
// CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
|
1923 |
-
$plugin_data = get_plugin_data( __FILE__ );
|
1924 |
-
$posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
|
1925 |
-
$data = array(
|
1926 |
-
'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' ),
|
1927 |
-
);
|
1928 |
-
|
1929 |
-
foreach ( $data as $k => $v ) {
|
1930 |
-
$url .= '&' . $k . '=' . $v . '';
|
1931 |
-
}
|
1932 |
-
|
1933 |
-
wp_remote_get( $url );
|
1934 |
-
set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
|
1935 |
-
}
|
1936 |
-
}
|
1937 |
-
|
1938 |
function rtmedia_update_template_notice() {
|
1939 |
$site_option = rtmedia_get_site_option( 'rtmedia-update-template-notice-v3_9_4' );
|
1940 |
|
1941 |
-
if ( ! $site_option || 'hide'
|
1942 |
rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_4', 'show' );
|
1943 |
if ( is_dir( get_template_directory() . '/rtmedia' ) ) {
|
1944 |
-
echo '<div class="error rtmedia-update-template-notice"><p>' .
|
1945 |
?>
|
1946 |
<script type="text/javascript">
|
1947 |
function rtmedia_hide_template_override_notice() {
|
1948 |
-
var data = {
|
1949 |
-
jQuery.post(
|
1950 |
response = response.trim();
|
1951 |
-
if (
|
1952 |
-
jQuery(
|
1953 |
-
}
|
1954 |
}
|
1955 |
</script>
|
1956 |
<?php
|
@@ -1960,7 +2049,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1960 |
|
1961 |
function rtmedia_hide_template_override_notice() {
|
1962 |
|
1963 |
-
if ( rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_4', 'hide' ) ) {
|
1964 |
echo '1';
|
1965 |
} else {
|
1966 |
echo '0';
|
@@ -1972,22 +2061,23 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1972 |
|
1973 |
// wrapper class
|
1974 |
$wrapper_class = '';
|
1975 |
-
if ( ! empty( $args[
|
1976 |
-
$wrapper_class = implode( ' ', $args[
|
1977 |
}
|
1978 |
|
1979 |
// tabs
|
1980 |
-
if (
|
1981 |
$sub_tabs = apply_filters( 'rtmedia_pro_settings_tabs_content', $sub_tabs );
|
1982 |
ksort( $sub_tabs );
|
1983 |
}
|
1984 |
$tab_position_class = 'rtm-vertical-tabs';
|
1985 |
-
if(
|
1986 |
$tab_position_class = 'rtm-horizotanl-tabs';
|
1987 |
}
|
1988 |
?>
|
1989 |
|
1990 |
-
<div
|
|
|
1991 |
<ul class="rtm-tabs">
|
1992 |
<?php
|
1993 |
$i = 1;
|
@@ -1995,19 +2085,21 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
1995 |
|
1996 |
// tab status
|
1997 |
$active_class = '';
|
1998 |
-
if ( 1
|
1999 |
$active_class = 'active';
|
2000 |
}
|
2001 |
|
2002 |
// tab icon
|
2003 |
$icon = '';
|
2004 |
-
if ( isset( $tab[
|
2005 |
-
$icon = '<i class="' . $tab[
|
2006 |
}
|
2007 |
?>
|
2008 |
-
<li class="<?php echo $active_class ?>">
|
2009 |
-
<a id="tab-<?php echo substr( $tab[
|
2010 |
-
|
|
|
|
|
2011 |
</a>
|
2012 |
</li>
|
2013 |
<?php
|
@@ -2021,20 +2113,20 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
2021 |
$k = 1;
|
2022 |
foreach ( $sub_tabs as $tab ) {
|
2023 |
$active_class = '';
|
2024 |
-
if ( 1
|
2025 |
$active_class = ' active';
|
2026 |
}
|
2027 |
$k ++;
|
2028 |
-
if ( isset( $tab[
|
2029 |
-
$icon = '<i class="' . $tab[
|
2030 |
}
|
2031 |
-
$tab_without_hash = explode( '#', $tab[
|
2032 |
-
$tab_without_hash = $tab_without_hash[
|
2033 |
-
echo '<div class="rtm-content' . $active_class . '" id="' . $tab_without_hash . '">';
|
2034 |
-
if ( isset( $tab[
|
2035 |
-
call_user_func( $tab[
|
2036 |
} else {
|
2037 |
-
call_user_func( $tab[
|
2038 |
}
|
2039 |
echo '</div>';
|
2040 |
}
|
@@ -2048,16 +2140,19 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
|
|
2048 |
/**
|
2049 |
* To remove setting saved parameter from url once satting saved
|
2050 |
* Add parameter to this array WP will remove variable from Query string
|
|
|
2051 |
* @param $removable_query_args
|
|
|
2052 |
* @return array $removable_query_args
|
2053 |
*/
|
2054 |
function removable_query_args( $removable_query_args ) {
|
2055 |
-
|
|
|
2056 |
$removable_query_args[] = 'settings-saved';
|
2057 |
}
|
|
|
2058 |
return $removable_query_args;
|
2059 |
}
|
2060 |
-
|
2061 |
}
|
2062 |
|
2063 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Description of RTMediaAdmin
|
5 |
*
|
24 |
* Constructor - get the plugin hooked in and ready
|
25 |
*
|
26 |
* @access public
|
|
|
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_filter( 'plugin_action_links_' . RTMEDIA_BASE_NAME, array( &$this, 'plugin_add_settings_link' ) );
|
34 |
+
|
35 |
$this->rtmedia_support = new RTMediaSupport();
|
36 |
add_action( 'wp_ajax_rtmedia_select_request', array( $this->rtmedia_support, 'get_form' ), 1 );
|
37 |
+
add_action( 'wp_ajax_rtmedia_cancel_request', function () {
|
38 |
+
do_settings_sections( 'rtmedia-support' );
|
39 |
+
die();
|
40 |
+
}, 1 );
|
41 |
add_action( 'wp_ajax_rtmedia_submit_request', array( $this->rtmedia_support, 'submit_request' ), 1 );
|
42 |
+
|
43 |
+
add_action( 'wp_ajax_rtmedia_linkback', array( $this, 'linkback' ), 1 ); //fixme : is it being used ?
|
44 |
add_action( 'wp_ajax_rtmedia_rt_album_deactivate', 'BPMediaAlbumimporter::bp_album_deactivate', 1 );
|
45 |
add_action( 'wp_ajax_rtmedia_rt_album_import', 'BPMediaAlbumimporter::bpmedia_ajax_import_callback', 1 );
|
46 |
add_action( 'wp_ajax_rtmedia_rt_album_import_favorites', 'BPMediaAlbumimporter::bpmedia_ajax_import_favorites', 1 );
|
47 |
add_action( 'wp_ajax_rtmedia_rt_album_import_step_favorites', 'BPMediaAlbumimporter::bpmedia_ajax_import_step_favorites', 1 );
|
48 |
add_action( 'wp_ajax_rtmedia_rt_album_cleanup', 'BPMediaAlbumimporter::cleanup_after_install' );
|
49 |
+
add_action( 'wp_ajax_rtmedia_convert_videos_form', array( $this, 'convert_videos_mailchimp_send' ), 1 ); //fixme : is it being used ?
|
50 |
add_action( 'wp_ajax_rtmedia_correct_upload_filetypes', array( $this, 'correct_upload_filetypes' ), 1 );
|
51 |
+
add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_premium_addon_link' ), 1, 2 );
|
52 |
+
add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widgets' ), 0 );
|
53 |
add_filter( 'attachment_fields_to_edit', array( $this, 'edit_video_thumbnail' ), null, 2 );
|
54 |
+
add_filter( 'attachment_fields_to_save', array( $this, 'save_video_thumbnail' ), null, 1 );
|
55 |
+
add_action( 'wp_ajax_rtmedia_hide_video_thumb_admin_notice', array(
|
56 |
+
$this,
|
57 |
+
'rtmedia_hide_video_thumb_admin_notice',
|
58 |
+
), 1 );
|
59 |
+
add_action( 'wp_ajax_rtmedia_hide_addon_update_notice', array(
|
60 |
+
$this,
|
61 |
+
'rtmedia_hide_addon_update_notice',
|
62 |
+
), 1 );
|
63 |
+
add_filter( 'media_row_actions', array( $this, 'modify_medialibrary_permalink' ), 10, 2 );
|
64 |
|
65 |
$obj_encoding = new RTMediaEncoding( true );
|
66 |
|
78 |
$rtmedia->options = rtmedia_get_site_option( 'rtmedia-options' );
|
79 |
}
|
80 |
|
81 |
+
$rtmedia_option = filter_input( INPUT_POST, 'rtmedia-options', FILTER_DEFAULT, FILTER_SANITIZE_NUMBER_INT );
|
82 |
+
if ( isset( $rtmedia_option ) ) {
|
83 |
+
if ( isset( $rtmedia_option['general_showAdminMenu'] ) && 1 === intval( $rtmedia_option['general_showAdminMenu'] ) ) {
|
84 |
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 );
|
85 |
}
|
86 |
} else {
|
87 |
+
if ( 1 === intval( $rtmedia->options['general_showAdminMenu'] ) ) {
|
88 |
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 );
|
89 |
}
|
90 |
}
|
91 |
|
92 |
if ( is_admin() ) {
|
93 |
add_action( 'admin_enqueue_scripts', array( $this, 'ui' ) );
|
|
|
94 |
add_action( 'admin_menu', array( $this, 'menu' ), 1 );
|
95 |
add_action( 'init', array( $this, 'bp_admin_tabs' ) );
|
96 |
|
101 |
|
102 |
$this->rtmedia_settings = new RTMediaSettings();
|
103 |
$this->rtmedia_encoding = new RTMediaEncoding();
|
104 |
+
|
|
|
|
|
105 |
if ( ! class_exists( 'BuddyPress' ) ) {
|
106 |
add_action( 'admin_init', array( $this, 'check_permalink_admin_notice' ) );
|
107 |
}
|
108 |
|
109 |
+
add_action( 'wp_ajax_rtmedia_hide_template_override_notice', array(
|
110 |
+
$this,
|
111 |
+
'rtmedia_hide_template_override_notice',
|
112 |
+
), 1 );
|
113 |
add_action( 'admin_init', array( $this, 'rtmedia_bp_add_update_type' ) );
|
114 |
+
add_action( 'wp_ajax_rtmedia_hide_inspirebook_release_notice', array(
|
115 |
+
$this,
|
116 |
+
'rtmedia_hide_inspirebook_release_notice',
|
117 |
+
), 1 );
|
118 |
+
add_action( 'wp_ajax_rtmedia_hide_social_sync_notice', array(
|
119 |
+
$this,
|
120 |
+
'rtmedia_hide_social_sync_notice',
|
121 |
+
), 1 );
|
122 |
+
add_action( 'wp_ajax_rtmedia_hide_pro_split_notice', array( $this, 'rtmedia_hide_pro_split_notice' ), 1 );
|
123 |
+
|
124 |
+
new RTMediaMediaSizeImporter(); // do not delete this line. We only need to create object of this class if we are in admin section
|
125 |
if ( class_exists( 'BuddyPress' ) ) {
|
126 |
+
new RTMediaActivityUpgrade();
|
127 |
}
|
128 |
add_action( 'admin_notices', array( $this, 'rtmedia_admin_notices' ) );
|
129 |
add_action( 'network_admin_notices', array( $this, 'rtmedia_network_admin_notices' ) );
|
130 |
add_action( 'admin_init', array( $this, 'rtmedia_addon_license_save_hook' ) );
|
131 |
add_action( 'admin_init', array( $this, 'rtmedia_migration' ) );
|
132 |
|
133 |
+
add_filter( 'removable_query_args', array( $this, 'removable_query_args' ), 10, 1 );
|
134 |
+
|
135 |
+
add_action( 'admin_footer', array( $this, 'rtm_admin_templates' ) );
|
136 |
+
}
|
137 |
+
|
138 |
+
function rtm_admin_templates() {
|
139 |
+
foreach ( glob( RTMEDIA_PATH . 'app/admin/templates/*.php' ) as $filename ) {
|
140 |
+
$slug = rtrim( basename( $filename ), '.php' );
|
141 |
+
|
142 |
+
echo '<script type="text/html" id="' . esc_attr( $slug ) . '">';
|
143 |
+
include $filename;
|
144 |
+
echo '</script>';
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
function modify_medialibrary_permalink( $action, $post ) {
|
149 |
+
$rtm_id = rtmedia_id( $post->ID );
|
150 |
+
|
151 |
+
if ( $rtm_id ) {
|
152 |
+
$link = get_rtmedia_permalink( $rtm_id );
|
153 |
+
$title = _draft_or_post_title( $post->post_parent );
|
154 |
+
$action['view'] = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( sprintf( esc_html__( 'View “%s”', 'buddypress-media' ), $title ) ) . '" rel="permalink">' . esc_html__( 'View', 'buddypress-media' ) . '</a>';
|
155 |
+
}
|
156 |
+
|
157 |
+
return $action;
|
158 |
+
}
|
159 |
|
160 |
function rtmedia_migration() {
|
161 |
+
new RTMediaMigration();
|
162 |
}
|
163 |
|
164 |
function rtmedia_addon_license_save_hook() {
|
195 |
$this->rtmedia_regenerate_thumbnail_notice();
|
196 |
$this->rtmedia_addon_update_notice();
|
197 |
$this->rtmedia_update_template_notice();
|
198 |
+
|
199 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
200 |
+
$this->rtmedia_inspirebook_release_notice();
|
201 |
+
$this->rtmedia_social_sync_release_notice();
|
202 |
+
|
203 |
+
if ( ! defined( 'RTMEDIA_PRO_PATH' ) ) {
|
204 |
+
$this->rtmedia_pro_split_release_notice();
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
/*
|
211 |
+
* rtMedia Pro split release admin notice
|
212 |
+
*/
|
213 |
+
public function rtmedia_pro_split_release_notice() {
|
214 |
+
$site_option = rtmedia_get_site_option( 'rtmedia_pro_split_release_notice' );
|
215 |
+
|
216 |
+
if ( ( ! $site_option || 'hide' !== $site_option ) ) {
|
217 |
rtmedia_update_site_option( 'rtmedia_pro_split_release_notice', 'show' );
|
218 |
?>
|
219 |
<div class="updated rtmedia-pro-split-notice">
|
220 |
<p>
|
221 |
<span>
|
222 |
+
<b><?php esc_html_e( 'rtMedia: ', 'buddypress-media' ); ?></b>
|
223 |
+
<?php esc_html_e( 'We have released 30+ premium add-ons for rtMedia plugin. Read more about it ', 'buddypress-media' ); ?>
|
224 |
+
<a href="https://rtmedia.io/blog/rtmedia-pro-splitting-major-change/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media"
|
225 |
+
target="_blank"><?php esc_html_e( 'here', 'buddypress-media' ) ?></a>.
|
226 |
</span>
|
227 |
+
<a href="#"
|
228 |
+
onclick="rtmedia_hide_pro_split_notice('<?php echo esc_js( wp_create_nonce( 'rtcamp_pro_split' ) ); ?>');"
|
229 |
+
style="float:right">Dismiss</a>
|
230 |
</p>
|
231 |
</div>
|
232 |
<script type="text/javascript">
|
233 |
+
function rtmedia_hide_pro_split_notice(nonce) {
|
234 |
+
var data = {action: 'rtmedia_hide_pro_split_notice', _rtm_nonce: nonce };
|
235 |
+
jQuery.post(ajaxurl, data, function (response) {
|
236 |
response = response.trim();
|
237 |
+
|
238 |
+
if (response === "1")
|
239 |
+
jQuery('.rtmedia-pro-split-notice').remove();
|
240 |
+
});
|
241 |
}
|
242 |
</script>
|
243 |
<?php
|
244 |
}
|
245 |
+
}
|
246 |
+
|
247 |
+
/*
|
248 |
* Hide pro split release notice
|
249 |
*/
|
250 |
|
251 |
function rtmedia_hide_pro_split_notice() {
|
252 |
+
if ( check_ajax_referer( 'rtcamp_pro_split', '_rtm_nonce' ) && rtmedia_update_site_option( 'rtmedia_pro_split_release_notice', 'hide' ) ) {
|
253 |
echo '1';
|
254 |
} else {
|
255 |
echo '0';
|
262 |
*/
|
263 |
|
264 |
function rtmedia_social_sync_release_notice() {
|
265 |
+
$site_option = rtmedia_get_site_option( 'rtmedia_social_sync_release_notice' );
|
266 |
$check_rtmedia_social_sync_installed = file_exists( trailingslashit( WP_PLUGIN_DIR ) . 'rtmedia-social-sync/index.php' );
|
267 |
|
268 |
+
if ( ( ! $site_option || 'hide' !== $site_option ) && ! $check_rtmedia_social_sync_installed ) {
|
269 |
rtmedia_update_site_option( 'rtmedia_social_sync_release_notice', 'show' );
|
270 |
?>
|
271 |
<div class="updated rtmedia-social-sync-notice">
|
272 |
<p>
|
273 |
<span>
|
274 |
+
<b><?php esc_html_e( 'rtMedia: ', 'buddypress-media' ); ?></b>
|
275 |
+
<?php esc_html_e( 'Meet ', 'buddypress-media' ); ?>
|
276 |
+
<a href="https://rtmedia.io/products/rtmedia-social-sync/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media"
|
277 |
+
target="_blank">
|
278 |
+
<b><?php esc_html_e( 'rtMedia Social Sync', 'buddypress-media' ) ?></b>
|
279 |
+
</a>
|
280 |
+
<?php esc_html_e( ' which allows you to import media from your Facebook account.', 'buddypress-media' ); ?>
|
281 |
</span>
|
282 |
+
<a href="#"
|
283 |
+
onclick="rtmedia_hide_social_sync_notice('<?php echo esc_js( wp_create_nonce( 'social_sync' ) ); ?>')"
|
284 |
+
style="float:right">Dismiss</a>
|
285 |
</p>
|
286 |
</div>
|
287 |
<script type="text/javascript">
|
288 |
+
function rtmedia_hide_social_sync_notice(nonce) {
|
289 |
+
var data = {action: 'rtmedia_hide_social_sync_notice', _rtm_nonce: nonce};
|
290 |
+
jQuery.post(ajaxurl, data, function (response) {
|
291 |
response = response.trim();
|
292 |
+
if (response === "1")
|
293 |
+
jQuery('.rtmedia-social-sync-notice').remove();
|
294 |
+
});
|
295 |
}
|
296 |
</script>
|
297 |
<?php
|
303 |
*/
|
304 |
|
305 |
function rtmedia_hide_social_sync_notice() {
|
306 |
+
if ( check_ajax_referer( 'social_sync', '_rtm_nonce' ) && rtmedia_update_site_option( 'rtmedia_social_sync_release_notice', 'hide' ) ) {
|
307 |
echo '1';
|
308 |
} else {
|
309 |
echo '0';
|
322 |
*/
|
323 |
public function rtmedia_inspirebook_release_notice() {
|
324 |
$site_option = rtmedia_get_site_option( 'rtmedia_inspirebook_release_notice' );
|
325 |
+
if ( ( ! $site_option || 'hide' !== $site_option ) && ( 'inspirebook' !== get_stylesheet() ) ) {
|
326 |
rtmedia_update_site_option( 'rtmedia_inspirebook_release_notice', 'show' );
|
327 |
?>
|
328 |
<div class="updated rtmedia-inspire-book-notice">
|
329 |
<p>
|
330 |
+
<span>
|
331 |
+
<a href="https://rtmedia.io/products/inspirebook/"
|
332 |
+
target="_blank">
|
333 |
+
<b><?php esc_html_e( 'Meet InspireBook', 'buddypress-media' ) ?></b>
|
334 |
+
</a>
|
335 |
+
<?php esc_html_e( ' - First official rtMedia premium theme.', 'buddypress-media' ); ?>
|
336 |
+
</span>
|
337 |
<a href="#" onclick="rtmedia_hide_inspirebook_notice()" style="float:right">Dismiss</a>
|
338 |
+
<?php wp_nonce_field( '_rtmedia_hide_inspirebook_notice_','rtmedia_hide_inspirebook_nonce' ); ?>
|
339 |
</p>
|
340 |
</div>
|
341 |
<script type="text/javascript">
|
342 |
function rtmedia_hide_inspirebook_notice() {
|
343 |
+
var data = {
|
344 |
+
action: 'rtmedia_hide_inspirebook_release_notice',
|
345 |
+
_rtm_nonce: jQuery('#rtmedia_hide_inspirebook_nonce').val()
|
346 |
+
};
|
347 |
+
jQuery.post(ajaxurl, data, function (response) {
|
348 |
response = response.trim();
|
349 |
+
if (response === "1")
|
350 |
+
jQuery('.rtmedia-inspire-book-notice').remove();
|
351 |
+
});
|
352 |
}
|
353 |
</script>
|
354 |
<?php
|
365 |
* @return void
|
366 |
*/
|
367 |
public function rtmedia_hide_inspirebook_release_notice() {
|
368 |
+
|
369 |
+
if ( check_ajax_referer( '_rtmedia_hide_inspirebook_notice_', '_rtm_nonce' ) && rtmedia_update_site_option( 'rtmedia_inspirebook_release_notice', 'hide' ) ) {
|
370 |
echo '1';
|
371 |
} else {
|
372 |
echo '0';
|
416 |
*/
|
417 |
public function rtmedia_permalink_notice() {
|
418 |
echo '<div class="error rtmedia-permalink-change-notice">
|
419 |
+
<p> <b>' . esc_html__( 'rtMedia:', 'buddypress-media' ) . '</b> ' . esc_html__( ' You must', 'buddypress-media' ) . ' <a href="' . esc_url( admin_url( 'options-permalink.php' ) ) . '">' . esc_html__( 'update permalink structure', 'buddypress-media' ) . '</a> ' . esc_html__( 'to something other than the default for it to work.', 'buddypress-media' ) . ' </p>
|
420 |
</div>';
|
421 |
}
|
422 |
|
432 |
public function rtmedia_addon_update_notice() {
|
433 |
|
434 |
$site_option = rtmedia_get_site_option( 'rtmedia-addon-update-notice-3_8' );
|
435 |
+
if ( is_rt_admin() && ( ! $site_option || 'hide' !== $site_option ) ) {
|
|
|
436 |
|
437 |
if ( ! $this->check_for_addon_update_notice() ) {
|
438 |
return;
|
439 |
}
|
440 |
rtmedia_update_site_option( 'rtmedia-addon-update-notice-3_8', 'show' );
|
441 |
+
?>
|
442 |
<div class="error rtmedia-addon-upate-notice">
|
443 |
<p>
|
444 |
+
<strong><?php esc_html_e( 'rtMedia:', 'buddypress-media' ) ?></strong>
|
445 |
+
<?php esc_html_e( 'Please update all premium add-ons that you have purchased from rtCamp from', 'buddypress-media' ) ?>
|
446 |
+
<a href="https://rtmedia.io/my-account/"
|
447 |
+
target="_blank"><?php esc_html_e( 'your account', 'buddypress-media' ) ?></a>.
|
448 |
+
<a href="#" onclick="rtmedia_hide_addon_update_notice()"
|
449 |
+
style="float:right"><?php esc_html_e( 'Dismiss', 'buddypress-media' ) ?></a>
|
450 |
+
<?php wp_nonce_field( 'rtmedia-addon-update-notice-3_8', 'rtmedia-addon-notice' ); ?>
|
451 |
</p>
|
452 |
</div>
|
453 |
<script type="text/javascript">
|
454 |
function rtmedia_hide_addon_update_notice() {
|
455 |
var data = {
|
456 |
+
action: 'rtmedia_hide_addon_update_notice',
|
457 |
+
_rtm_nonce: jQuery('#rtmedia-addon-notice').val();
|
458 |
+
};
|
459 |
+
jQuery.post(ajaxurl, data, function (response) {
|
460 |
response = response.trim();
|
461 |
+
if (response === "1")
|
462 |
+
jQuery('.rtmedia-addon-upate-notice').remove();
|
463 |
+
});
|
464 |
}
|
465 |
</script>
|
466 |
+
<?php
|
467 |
}
|
468 |
}
|
469 |
|
482 |
// check for rtMedia Instagram version
|
483 |
if ( defined( 'RTMEDIA_INSTAGRAM_PATH' ) ) {
|
484 |
$plugin_info = get_plugin_data( RTMEDIA_INSTAGRAM_PATH . 'index.php' );
|
485 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '2.1.14' ) ) ) {
|
486 |
$return_falg = true;
|
487 |
}
|
488 |
+
} elseif ( defined( 'RTMEDIA_PHOTO_TAGGING_PATH' ) ) {
|
489 |
// check for rtMedia Photo Tagging version
|
490 |
$plugin_info = get_plugin_data( RTMEDIA_PHOTO_TAGGING_PATH . 'index.php' );
|
491 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '2.2.14' ) ) ) {
|
492 |
$return_falg = true;
|
493 |
}
|
494 |
+
} elseif ( defined( 'RTMEDIA_FFMPEG_PATH' ) ) {
|
495 |
// check for rtMedia FFPMEG version
|
496 |
$plugin_info = get_plugin_data( RTMEDIA_FFMPEG_PATH . 'index.php' );
|
497 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '2.1.14' ) ) ) {
|
498 |
$return_falg = true;
|
499 |
}
|
500 |
+
} elseif ( defined( 'RTMEDIA_KALTURA_PATH' ) ) {
|
501 |
// check for rtMedia Kaltura version
|
502 |
$plugin_info = get_plugin_data( RTMEDIA_KALTURA_PATH . 'index.php' );
|
503 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '3.0.16' ) ) ) {
|
504 |
$return_falg = true;
|
505 |
}
|
506 |
+
} elseif ( defined( 'RTMEDIA_PRO_PATH' ) ) {
|
507 |
// check for rtMedia Pro version
|
508 |
$plugin_info = get_plugin_data( RTMEDIA_PRO_PATH . 'index.php' );
|
509 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '2.6' ) ) ) {
|
510 |
$return_falg = true;
|
511 |
}
|
512 |
+
} elseif ( defined( 'RTMEDIA_SOCIAL_SYNC_PATH' ) ) {
|
513 |
// check for rtMedia Social Sync version
|
514 |
$plugin_info = get_plugin_data( RTMEDIA_SOCIAL_SYNC_PATH . 'index.php' );
|
515 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '1.3.1' ) ) ) {
|
516 |
$return_falg = true;
|
517 |
}
|
518 |
+
} elseif ( defined( 'RTMEDIA_MEMBERSHIP_PATH' ) ) {
|
519 |
// check for rtMedia Membership version
|
520 |
$plugin_info = get_plugin_data( RTMEDIA_MEMBERSHIP_PATH . 'index.php' );
|
521 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '2.1.5' ) ) ) {
|
522 |
$return_falg = true;
|
523 |
}
|
524 |
+
} elseif ( defined( 'RTMEDIA_WATERMARK_PATH' ) ) {
|
525 |
// check for rtMedia Photo Watermak version
|
526 |
$plugin_info = get_plugin_data( RTMEDIA_WATERMARK_PATH . 'index.php' );
|
527 |
+
if ( isset( $plugin_info['Version'] ) && ( - 1 === version_compare( $plugin_info['Version'], '1.1.8' ) ) ) {
|
528 |
$return_falg = true;
|
529 |
}
|
530 |
}
|
561 |
?>
|
562 |
<div class='rtmedia-admin-ad'>
|
563 |
<a href='https://rtmedia.io/products/rtmedia-pro/' target='_blank' title='rtMedia Pro'>
|
564 |
+
<img src='<?php echo esc_url( $src ); ?>' alt="<?php esc_attr_e( 'rtMedia Pro is released', 'buddypress-media' ); ?>"/>
|
565 |
</a>
|
566 |
</div>
|
567 |
<?php
|
582 |
<div class="clearfix">
|
583 |
|
584 |
<div class="rtm-column alignleft">
|
585 |
+
<h4 class="sub"><?php esc_html_e( 'Media Stats', 'buddypress-media' ); ?></h4>
|
586 |
|
587 |
<table>
|
588 |
<tbody>
|
589 |
+
<?php
|
590 |
+
$rtmedia_model = new RTMediaModel();
|
591 |
+
global $wpdb;
|
592 |
+
$results = wp_cache_get( 'rt-stats', 'rt-dashboard' );
|
593 |
+
if ( false === $results ) {
|
594 |
+
$results = $wpdb->get_results( $wpdb->prepare( "select media_type, count(id) as count from {$rtmedia_model->table_name} where blog_id=%d group by media_type", get_current_blog_id() ) ); // @codingStandardsIgnoreLine
|
595 |
+
wp_cache_set( 'stats', $results, 'rt-dashboard', HOUR_IN_SECONDS );
|
596 |
+
}
|
597 |
+
if ( $results ) {
|
598 |
+
foreach ( $results as $media ) {
|
599 |
+
if ( defined( strtoupper( 'RTMEDIA_' . $media->media_type . '_PLURAL_LABEL' ) ) ) {
|
600 |
+
?>
|
601 |
+
<tr>
|
602 |
+
<td class="b"> <?php echo esc_html( $media->count ); ?> </td>
|
603 |
+
<td class="t"><?php echo esc_html( constant( strtoupper( 'RTMEDIA_' . $media->media_type . '_PLURAL_LABEL' ) ) ); ?></td>
|
604 |
+
</tr>
|
605 |
+
<?php
|
606 |
}
|
607 |
}
|
608 |
+
}
|
609 |
+
?>
|
610 |
</tbody>
|
611 |
</table>
|
612 |
</div>
|
613 |
|
614 |
<div class="rtm-column alignright">
|
615 |
+
<h4 class="sub"><?php esc_html_e( 'Usage Stats', 'buddypress-media' ); ?></h4>
|
616 |
|
617 |
<table>
|
618 |
<tbody> <?php
|
619 |
+
$total_count = wp_cache_get( 'total_count', 'rt-dashboard' );
|
620 |
+
if ( false === $total_count ) {
|
621 |
+
$total_count = $wpdb->get_var( "select count(*) from {$wpdb->users}" );
|
622 |
+
wp_cache_set( 'total_count', $total_count, 'rt-dashboard', HOUR_IN_SECONDS );
|
623 |
+
}
|
624 |
+
?>
|
625 |
+
<tr>
|
626 |
+
<td class="b"> <?php echo esc_html( $total_count ); ?> </td>
|
627 |
+
<td class="t"><?php esc_html_e( 'Total ', 'buddypress-media' ) ?></td>
|
628 |
+
</tr>
|
629 |
+
<?php
|
630 |
+
$with_media_count = wp_cache_get( 'with_media', 'rt-dashboard' );
|
631 |
+
if ( false === $with_media_count ) {
|
632 |
+
$with_media_count = $wpdb->get_var( "select count(distinct media_author) from {$rtmedia_model->table_name}" ); // @codingStandardsIgnoreLine
|
633 |
+
wp_cache_set( 'with_media', $with_media_count, 'rt-dashboard', HOUR_IN_SECONDS );
|
634 |
+
}
|
635 |
+
?>
|
636 |
+
<tr>
|
637 |
+
<td class="b"> <?php echo esc_html( $with_media_count ); ?> </td>
|
638 |
+
<td class="t"><?php esc_html_e( 'With Media', 'buddypress-media' ) ?></td>
|
639 |
+
</tr>
|
640 |
+
<?php
|
641 |
+
$comments = wp_cache_get( 'comments', 'rt-dashboard' );
|
642 |
+
if ( false === $comments ) {
|
643 |
+
$comments = $wpdb->get_var( "select count(*) from {$wpdb->comments} where comment_post_ID in ( select media_id from {$rtmedia_model->table_name} )" ); // @codingStandardsIgnoreLine
|
644 |
+
wp_cache_set( 'comments', $comments, 'rt-dashboard', HOUR_IN_SECONDS );
|
645 |
+
}
|
646 |
+
?>
|
647 |
+
<tr>
|
648 |
+
<td class="b"> <?php echo esc_html( $comments ); ?> </td>
|
649 |
+
<td class="t"><?php esc_html_e( 'Comments ', 'buddypress-media' ) ?></td>
|
650 |
+
</tr>
|
651 |
+
<?php
|
652 |
+
$likes = wp_cache_get( 'likes', 'rt-dashboard' );
|
653 |
+
if ( false === $likes ) {
|
654 |
+
$likes = $wpdb->get_var( "select sum(likes) from {$rtmedia_model->table_name}" ); // @codingStandardsIgnoreLine
|
655 |
+
wp_cache_set( 'likes', $likes, 'rt-dashboard', HOUR_IN_SECONDS );
|
656 |
+
}
|
657 |
+
?>
|
658 |
+
<tr>
|
659 |
+
<td class="b"> <?php echo esc_html( $likes ); ?> </td>
|
660 |
+
<td class="t"><?php esc_html_e( 'Likes', 'buddypress-media' ) ?></td>
|
661 |
+
</tr>
|
662 |
</tbody>
|
663 |
</table>
|
664 |
</div>
|
667 |
|
668 |
<div class="rtm-meta-container">
|
669 |
<ul class="rtm-meta-links">
|
670 |
+
<li><b><?php esc_html_e( 'rtMedia Links:', 'buddypress-media' ); ?></b></li>
|
671 |
+
<li><a href="https://rtmedia.io/"><?php esc_html_e( 'Homepage', 'buddypress-media' ); ?></a></li>
|
672 |
+
<li>
|
673 |
+
<a href="<?php echo esc_url( admin_url( 'admin.php?page=rtmedia-support#rtmedia-general' ) ); ?>"><?php esc_html_e( 'Free Support', 'buddypress-media' ); ?></a>
|
674 |
+
</li>
|
675 |
+
<li>
|
676 |
+
<a href="https://rtmedia.io/products/category/rtmedia/"><?php esc_html_e( 'Premium Addons', 'buddypress-media' ); ?></a>
|
677 |
+
</li>
|
678 |
</ul>
|
679 |
</div>
|
680 |
<?php
|
690 |
* @return void
|
691 |
*/
|
692 |
public function add_dashboard_widgets() {
|
693 |
+
wp_add_dashboard_widget( 'rtmedia_dashboard_widget', esc_html__( 'Right Now in rtMedia', 'buddypress-media' ), array(
|
694 |
+
&$this,
|
695 |
+
'rtmedia_dashboard_widget_function',
|
696 |
+
) );
|
697 |
global $wp_meta_boxes;
|
698 |
|
699 |
// Get the regular dashboard widgets array
|
700 |
// (which has our new widget already but at the end)
|
701 |
|
702 |
+
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
|
703 |
|
704 |
// Backup and delete our new dashboard widget from the end of the array
|
705 |
|
706 |
+
$example_widget_backup = array( 'rtmedia_dashboard_widget' => $normal_dashboard['rtmedia_dashboard_widget'] );
|
707 |
+
unset( $normal_dashboard['rtmedia_dashboard_widget'] );
|
708 |
|
709 |
// Merge the two arrays together so our widget is at the beginning
|
710 |
|
712 |
|
713 |
// Save the sorted array back into the original metaboxes
|
714 |
|
715 |
+
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
|
716 |
}
|
717 |
|
718 |
/**
|
725 |
* @return array $links
|
726 |
*/
|
727 |
public function plugin_add_settings_link( $links ) {
|
728 |
+
$settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=rtmedia-settings' ) ) . '">' . esc_html__( 'Settings', 'buddypress-media' ) . '</a>';
|
729 |
array_push( $links, $settings_link );
|
730 |
+
$settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=rtmedia-support' ) ) . '">' . esc_html__( 'Support', 'buddypress-media' ) . '</a>';
|
731 |
array_push( $links, $settings_link );
|
732 |
|
733 |
return $links;
|
738 |
*
|
739 |
* @access public
|
740 |
*
|
741 |
+
* @param array $actions
|
742 |
* @param object $post
|
743 |
*
|
744 |
* @return array $actions
|
746 |
public function add_reencode_link( $actions, $post ) {
|
747 |
|
748 |
$mime_type_array = explode( '/', $post->post_mime_type );
|
749 |
+
if ( is_array( $mime_type_array ) && '' !== $mime_type_array && 'video' === $mime_type_array[0] ) {
|
750 |
+
$actions['reencode'] = '<a class="submitdelete" onclick="return rtmedia_regenerate_thumbs(' . esc_attr( $post->ID ) . ')" href="#">' . esc_html_e( 'Regenerate Thumbnail', 'buddypress-media' ) . '</a>';
|
751 |
}
|
752 |
|
753 |
return $actions;
|
763 |
* @return void
|
764 |
*/
|
765 |
public function bulk_action_handler() {
|
766 |
+
$action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING );
|
767 |
+
$request_media = filter_input( INPUT_GET, 'media', FILTER_DEFAULT, FILTER_SANITIZE_NUMBER_INT );
|
768 |
+
if ( 'bulk_video_regenerate_thumbnails' === $action && '' !== $request_media ) {
|
769 |
+
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'media_ids' => urlencode( implode( ',', $request_media ) ) ), admin_url( 'admin.php?page=rtmedia-regenerate' ) ) ) );
|
770 |
exit;
|
771 |
}
|
772 |
}
|
776 |
*
|
777 |
* @access public
|
778 |
*
|
779 |
+
* @param object $admin_bar
|
780 |
*
|
781 |
* @return void
|
782 |
*/
|
786 |
}
|
787 |
|
788 |
$admin_bar->add_menu( array(
|
789 |
+
'id' => 'rtMedia',
|
790 |
+
'title' => 'rtMedia',
|
791 |
+
'href' => admin_url( 'admin.php?page=rtmedia-settings' ),
|
792 |
+
'meta' => array(
|
793 |
+
'title' => esc_html__( 'rtMedia', 'buddypress-media' ),
|
794 |
+
),
|
795 |
+
)
|
796 |
);
|
797 |
$admin_bar->add_menu( array(
|
798 |
+
'id' => 'rt-media-dashborad',
|
799 |
+
'parent' => 'rtMedia',
|
800 |
+
'title' => esc_html__( 'Settings', 'buddypress-media' ),
|
801 |
+
'href' => admin_url( 'admin.php?page=rtmedia-settings' ),
|
802 |
+
'meta' => array(
|
803 |
+
'title' => esc_html__( 'Settings', 'buddypress-media' ),
|
804 |
+
'target' => '_self',
|
805 |
+
),
|
806 |
+
)
|
807 |
);
|
808 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
809 |
+
$admin_bar->add_menu( array(
|
810 |
+
'id' => 'rt-media-addons',
|
811 |
+
'parent' => 'rtMedia',
|
812 |
+
'title' => esc_html__( 'Addons', 'buddypress-media' ),
|
813 |
+
'href' => admin_url( 'admin.php?page=rtmedia-addons' ),
|
814 |
+
'meta' => array(
|
815 |
+
'title' => esc_html__( 'Addons', 'buddypress-media' ),
|
816 |
+
'target' => '_self',
|
817 |
+
),
|
818 |
)
|
819 |
+
);
|
820 |
+
}
|
821 |
$admin_bar->add_menu( array(
|
822 |
+
'id' => 'rt-media-support',
|
823 |
+
'parent' => 'rtMedia',
|
824 |
+
'title' => esc_html__( 'Support', 'buddypress-media' ),
|
825 |
+
'href' => admin_url( 'admin.php?page=rtmedia-support' ),
|
826 |
+
'meta' => array(
|
827 |
+
'title' => esc_html__( 'Support', 'buddypress-media' ),
|
828 |
+
'target' => '_self',
|
829 |
+
),
|
830 |
+
)
|
831 |
);
|
832 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
833 |
+
$admin_bar->add_menu( array(
|
834 |
+
'id' => 'rt-media-themes',
|
835 |
+
'parent' => 'rtMedia',
|
836 |
+
'title' => esc_html__( 'Themes', 'buddypress-media' ),
|
837 |
+
'href' => admin_url( 'admin.php?page=rtmedia-themes' ),
|
838 |
+
'meta' => array(
|
839 |
+
'title' => esc_html__( 'Themes', 'buddypress-media' ),
|
840 |
+
'target' => '_self',
|
841 |
+
),
|
842 |
)
|
843 |
+
);
|
844 |
+
}
|
845 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
846 |
+
$admin_bar->add_menu( array(
|
847 |
+
'id' => 'rt-media-hire-us',
|
848 |
+
'parent' => 'rtMedia',
|
849 |
+
'title' => esc_html__( 'Hire Us', 'buddypress-media' ),
|
850 |
+
'href' => admin_url( 'admin.php?page=rtmedia-hire-us' ),
|
851 |
+
'meta' => array(
|
852 |
+
'title' => esc_html__( 'Hire Us', 'buddypress-media' ),
|
853 |
+
'target' => '_self',
|
854 |
+
),
|
855 |
)
|
856 |
+
);
|
857 |
+
}
|
858 |
if ( has_filter( 'rtmedia_license_tabs' ) || has_action( 'rtmedia_addon_license_details' ) ) {
|
859 |
$admin_bar->add_menu( array(
|
860 |
+
'id' => 'rt-media-license',
|
861 |
+
'parent' => 'rtMedia',
|
862 |
+
'title' => esc_html__( 'Licenses', 'buddypress-media' ),
|
863 |
+
'href' => admin_url( 'admin.php?page=rtmedia-license' ),
|
864 |
+
'meta' => array(
|
865 |
+
'title' => esc_html__( 'Licenses', 'buddypress-media' ),
|
866 |
+
'target' => '_self',
|
867 |
+
),
|
868 |
+
)
|
869 |
);
|
870 |
}
|
871 |
}
|
898 |
}
|
899 |
|
900 |
$admin_pages = apply_filters( 'rtmedia_filter_admin_pages_array', $admin_pages );
|
901 |
+
$suffix = ( function_exists( 'rtm_get_script_style_suffix' ) ) ? rtm_get_script_style_suffix() : '.min';
|
902 |
|
903 |
+
if ( in_array( $hook, $admin_pages, true ) || strpos( $hook, 'rtmedia-migration' ) ) {
|
904 |
|
905 |
$admin_ajax = admin_url( 'admin-ajax.php' );
|
906 |
|
907 |
/* Only one JS file should enqueue */
|
908 |
+
if ( '' === $suffix ) {
|
909 |
wp_enqueue_script( 'rtmedia-admin-tabs', RTMEDIA_URL . 'app/assets/admin/js/vendors/tabs.js', array( 'backbone' ), RTMEDIA_VERSION );
|
910 |
wp_enqueue_script( 'rtmedia-admin-scripts', RTMEDIA_URL . 'app/assets/admin/js/scripts.js', array( 'backbone' ), RTMEDIA_VERSION );
|
911 |
+
wp_enqueue_script( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/admin/js/settings.js', array( 'backbone', 'wp-util' ), RTMEDIA_VERSION );
|
912 |
} else {
|
913 |
+
wp_enqueue_script( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/admin/js/admin.min.js', array( 'backbone', 'wp-util' ), RTMEDIA_VERSION );
|
914 |
}
|
915 |
|
916 |
+
wp_localize_script( 'rtmedia-admin', 'rtmedia_on_label', esc_html__( 'ON', 'buddypress-media' ) );
|
917 |
+
wp_localize_script( 'rtmedia-admin', 'rtmedia_off_label', esc_html__( 'OFF', 'buddypress-media' ) );
|
918 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_ajax', $admin_ajax );
|
919 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
|
920 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
|
921 |
|
922 |
$rtmedia_admin_strings = array(
|
923 |
+
'no_refresh' => esc_html__( 'Please do not refresh this page.', 'buddypress-media' ),
|
924 |
+
'something_went_wrong' => esc_html__( 'Something went wrong. Please ', 'buddypress-media' ) . '<a href onclick="location.reload();">' . esc_html__( 'refresh', 'buddypress-media' ) . '</a>' . esc_html__( ' page.', 'buddypress-media' ),
|
925 |
+
'are_you_sure' => esc_html__( 'This will subscribe you to the free plan.', 'buddypress-media' ),
|
926 |
+
'disable_encoding' => esc_html__( 'Are you sure you want to disable the encoding service?', 'buddypress-media' ),
|
927 |
+
'enable_encoding' => esc_html__( 'Are you sure you want to enable the encoding service?', 'buddypress-media' ),
|
928 |
);
|
929 |
|
930 |
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_strings', $rtmedia_admin_strings );
|
951 |
* @return void
|
952 |
*/
|
953 |
public function menu() {
|
954 |
+
add_menu_page( 'rtMedia', 'rtMedia', 'manage_options', 'rtmedia-settings', array(
|
955 |
+
$this,
|
956 |
+
'settings_page',
|
957 |
+
), RTMEDIA_URL . 'app/assets/admin/img/rtmedia-logo.png', '40.1111' );
|
958 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Settings', 'buddypress-media' ), esc_html__( 'Settings', 'buddypress-media' ), 'manage_options', 'rtmedia-settings', array(
|
959 |
+
$this,
|
960 |
+
'settings_page',
|
961 |
+
) );
|
962 |
+
|
963 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Addons', 'buddypress-media' ), esc_html__( 'Addons', 'buddypress-media' ), 'manage_options', 'rtmedia-addons', array(
|
964 |
+
$this,
|
965 |
+
'addons_page',
|
966 |
+
) );
|
967 |
+
|
968 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Support', 'buddypress-media' ), esc_html__( 'Support', 'buddypress-media' ), 'manage_options', 'rtmedia-support', array(
|
969 |
+
$this,
|
970 |
+
'support_page',
|
971 |
+
) );
|
972 |
+
|
973 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
974 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Themes', 'buddypress-media' ), esc_html__( 'Themes', 'buddypress-media' ), 'manage_options', 'rtmedia-themes', array(
|
975 |
+
$this,
|
976 |
+
'theme_page',
|
977 |
+
) );
|
978 |
+
}
|
979 |
+
|
980 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
981 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Hire Us', 'buddypress-media' ), esc_html__( 'Hire Us', 'buddypress-media' ), 'manage_options', 'rtmedia-hire-us', array(
|
982 |
+
$this,
|
983 |
+
'hire_us_page',
|
984 |
+
) );
|
985 |
+
}
|
986 |
+
|
987 |
if ( has_filter( 'rtmedia_license_tabs' ) || has_action( 'rtmedia_addon_license_details' ) ) {
|
988 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Licenses', 'buddypress-media' ), esc_html__( 'Licenses', 'buddypress-media' ), 'manage_options', 'rtmedia-license', array(
|
989 |
+
$this,
|
990 |
+
'license_page',
|
991 |
+
) );
|
992 |
}
|
993 |
|
994 |
$obj_encoding = new RTMediaEncoding( true );
|
995 |
|
996 |
if ( $obj_encoding->api_key ) {
|
997 |
+
add_submenu_page( 'rtmedia-settings', esc_html__( 'Regenerate Thumbnail', 'buddypress-media' ), esc_html__( 'Regen. Thumbnail ', 'buddypress-media' ), 'manage_options', 'rtmedia-regenerate', array(
|
998 |
+
$this,
|
999 |
+
'rt_regenerate_thumbnail',
|
1000 |
+
) );
|
1001 |
}
|
1002 |
}
|
1003 |
|
1012 |
*/
|
1013 |
public function rt_regenerate_thumbnail() {
|
1014 |
$prog = new rtProgress();
|
1015 |
+
$done = $total = 0;
|
1016 |
?>
|
1017 |
<div class="wrap">
|
1018 |
+
<h2> <?php esc_html_e( 'rtMedia: Regenerate Video Thumbnails', 'buddypress-media' ); ?> </h2>
|
1019 |
<?php
|
1020 |
+
$request_mediaids = filter_input( INPUT_GET, 'media', FILTER_DEFAULT, FILTER_SANITIZE_STRING );
|
1021 |
+
if ( isset( $request_mediaids ) && trim( $request_mediaids ) !== '' ) {
|
1022 |
$requested = false;
|
1023 |
+
$media_ids = explode( ',', $request_mediaids );
|
1024 |
+
$total = count( $media_ids );
|
1025 |
} else {
|
1026 |
+
$media_ids = get_video_without_thumbs();
|
1027 |
+
if ( is_array( $media_ids ) ) {
|
1028 |
+
$total = count( $media_ids );
|
1029 |
+
}
|
1030 |
}
|
1031 |
?>
|
1032 |
<script>
|
1033 |
+
var rt_thumb_all_media = <?php echo wp_json_encode( $media_ids ); ?>;
|
1034 |
</script>
|
1035 |
<?php
|
1036 |
if ( ! isset( $requested ) ) {
|
1037 |
?>
|
1038 |
<br/>
|
1039 |
+
<p>
|
1040 |
+
<?php esc_html_e( 'You can see this page because you have ', 'buddypress-media' ) ?>
|
1041 |
+
<a href='<?php echo esc_url( admin_url( 'admin.php?page=rtmedia-addons' ) ); ?>'><?php esc_html_e( 'subscribed', 'buddypress-media' ) ?></a>
|
1042 |
+
<?php esc_html_e( ' for ', 'buddypress-media' ) ?>
|
1043 |
+
<a href='<?php echo esc_url( 'https://rtmedia.io/audio-video-encoding-service/' ); ?>' target='_blank'><?php esc_html_e( 'rtMedia audio/video encoding service', 'buddypress-media' ) ?></a>.
|
1044 |
+
</p>
|
1045 |
+
<p>
|
1046 |
+
<?php esc_html_e( 'You can regenerate thumbnails of a specific video by visiting ', 'buddypress-media' ) ?>
|
1047 |
+
<a href='<?php echo esc_url( admin_url( 'upload.php?post_mime_type=video' ) ); ?>'><?php esc_html_e( 'media page', 'buddypress-media' ); ?></a>
|
1048 |
+
<?php esc_html_e( ' and clicking the ', 'buddypress-media' ) ?>
|
1049 |
+
<b><?php esc_html_e( 'Regenerate Thumbnail', 'buddypress-media' ) ?></b>
|
1050 |
+
<?php esc_html_e( ' option for that particular video.', 'buddypress-media' ) ?>
|
1051 |
+
</p>
|
1052 |
+
<p>
|
1053 |
+
<?php esc_html_e( 'Click ', 'buddypress-media' ) ?>
|
1054 |
+
<b><?php esc_html_e( 'Regenerate Pending Thumbnails', 'buddypress-media' ) ?></b>
|
1055 |
+
<?php esc_html_e( ' to regenerate thumbnails of pending videos.', 'buddypress-media' ) ?>
|
1056 |
+
</p>
|
1057 |
+
<p>
|
1058 |
+
<input type="button" class="button button-primary" id="rt-start-media-regenerate"
|
1059 |
+
value="<?php echo esc_attr__( 'Regenerate Pending Thumbnails', 'buddypress-media' ) . ' (' . esc_attr( $total ) . ')'; ?>"/>
|
1060 |
+
<?php wp_nonce_field( '_rt-start-media-regenerate_', 'rt-regenerate-nonce' ); ?>
|
1061 |
+
</p>
|
1062 |
<?php
|
1063 |
}
|
1064 |
?>
|
1068 |
$temp = $prog->progress( $done, $total );
|
1069 |
$prog->progress_ui( $temp, true );
|
1070 |
?>
|
1071 |
+
<p> <?php esc_html_e( 'Total Videos', 'buddypress-media' ) ?> : <span
|
1072 |
+
class='rt-total'><?php echo esc_html( $total ); ?></span>
|
1073 |
</p>
|
1074 |
|
1075 |
+
<p> <?php esc_html_e( 'Sent of regenerate thumbails', 'buddypress-media' ) ?> : <span
|
1076 |
+
class='rt-done'>0</span></p>
|
1077 |
|
1078 |
+
<p> <?php esc_html_e( 'Fail to regenerate thumbails', 'buddypress-media' ) ?> : <span
|
1079 |
+
class='rt-fail'>0</span></p>
|
1080 |
|
1081 |
</div>
|
1082 |
<script>
|
1083 |
|
1084 |
var db_done = 0;
|
1085 |
var db_fail = 0;
|
1086 |
+
var db_total = <?php echo esc_js( $total ); ?>;
|
1087 |
var indx = 0;
|
1088 |
function db_start_regenrate() {
|
1089 |
+
if (indx < db_total) {
|
1090 |
+
jQuery.ajax({
|
1091 |
url: rtmedia_admin_ajax,
|
1092 |
type: 'post',
|
1093 |
data: {
|
1094 |
"action": "rt_media_regeneration",
|
1095 |
+
"media_id": rt_thumb_all_media[indx++],
|
1096 |
+
"_rtm_nonce": jQuery('#rt-regenerate-nonce').val()
|
1097 |
},
|
1098 |
+
success: function (data) {
|
1099 |
+
data = JSON.parse(data);
|
1100 |
|
1101 |
+
if (data.status == false) {
|
1102 |
handle_regenrate_fail();
|
1103 |
} else {
|
1104 |
+
db_done++;
|
1105 |
+
var progw = Math.ceil(( db_done / db_total ) * 100);
|
1106 |
+
if (progw > 100) {
|
1107 |
progw = 100;
|
1108 |
}
|
1109 |
+
jQuery('#rtprogressbar>div').css('width', progw + '%');
|
1110 |
+
jQuery('span.rt-done').html(db_done);
|
1111 |
db_start_regenrate();
|
1112 |
}
|
1113 |
},
|
1114 |
error: function () {
|
1115 |
handle_regenrate_fail();
|
1116 |
}
|
1117 |
+
});
|
1118 |
} else {
|
1119 |
+
alert("<?php esc_html_e( 'Regenerate Video Thumbnails Done', 'buddypress-media' ); ?>");
|
1120 |
}
|
1121 |
}
|
1122 |
function handle_regenrate_fail() {
|
1123 |
+
db_fail++;
|
1124 |
+
jQuery('span.rt-fail').html(db_fail);
|
1125 |
db_start_regenrate();
|
1126 |
}
|
1127 |
+
$media_regenerate = jQuery("#rt-start-media-regenerate");
|
1128 |
+
if ($media_regenerate.length > 0) {
|
1129 |
+
jQuery("#rt-migration-progress").hide();
|
1130 |
+
$media_regenerate.click(function () {
|
1131 |
+
jQuery(this).hide();
|
1132 |
+
jQuery("#rt-migration-progress").show();
|
1133 |
db_start_regenrate();
|
1134 |
+
})
|
1135 |
} else {
|
1136 |
db_start_regenrate();
|
1137 |
}
|
1155 |
$obj_encoding = new RTMediaEncoding( true );
|
1156 |
if ( $obj_encoding->api_key ) {
|
1157 |
$site_option = rtmedia_get_site_option( 'rtmedia-video-thumb-notice' );
|
1158 |
+
if ( ! $site_option || 'hide' !== $site_option ) {
|
1159 |
rtmedia_update_site_option( 'rtmedia-video-thumb-notice', 'show' );
|
1160 |
$videos_without_thumbs = get_video_without_thumbs();
|
1161 |
+
if ( isset( $videos_without_thumbs ) && is_array( $videos_without_thumbs ) && count( $videos_without_thumbs ) > 0 ) {
|
|
|
|
|
|
|
|
|
|
|
1162 |
?>
|
1163 |
+
<div class="error rtmedia-regenerate-video-thumb-error">
|
1164 |
+
<p>
|
1165 |
+
<?php printf( esc_html__( 'You have %s videos without thumbnails. Click ', 'buddypress-media' ), esc_html( count( $videos_without_thumbs ) ) );?>
|
1166 |
+
<a href='<?php echo esc_url( admin_url( 'admin.php?page=rtmedia-regenerate' ) ); ?>'><?php esc_html_e( 'here', 'buddypress-media' ); ?></a>
|
1167 |
+
<?php esc_html_e( ' to generate thumbnails.', 'buddypress-media' ) ?>
|
1168 |
+
<a href='#' onclick='rtmedia_hide_video_thumb_notice()' style='float:right'>Hide</a>.
|
1169 |
+
<?php wp_nonce_field( '_rtmedia_hide_video_thumb_notice_', 'rtm_hide_video_thumb_notice' ); ?>
|
1170 |
+
</p>
|
1171 |
+
</div>
|
1172 |
<script type="text/javascript">
|
1173 |
function rtmedia_hide_video_thumb_notice() {
|
1174 |
+
var data = {action: 'rtmedia_hide_video_thumb_admin_notice', _rtm_nonce:jQuery('#rtm_hide_video_thumb_notice').val()};
|
1175 |
+
jQuery.post(ajaxurl, data, function (response) {
|
1176 |
response = response.trim();
|
1177 |
+
if (response === "1")
|
1178 |
+
jQuery('.rtmedia-regenerate-video-thumb-error').remove();
|
1179 |
+
});
|
1180 |
}
|
1181 |
</script>
|
1182 |
<?php
|
1195 |
* @return void
|
1196 |
*/
|
1197 |
public function rtmedia_hide_video_thumb_admin_notice() {
|
1198 |
+
if ( check_ajax_referer( '_rtmedia_hide_video_thumb_notice_', '_rtm_nonce' ) && rtmedia_update_site_option( 'rtmedia-video-thumb-notice', 'hide' ) ) {
|
1199 |
echo '1';
|
1200 |
} else {
|
1201 |
echo '0';
|
1213 |
* @return void
|
1214 |
*/
|
1215 |
public function rtmedia_hide_addon_update_notice() {
|
1216 |
+
if ( check_ajax_referer( 'rtmedia-addon-update-notice-3_8', '_rtm_nonce' ) && rtmedia_update_site_option( 'rtmedia-addon-update-notice-3_8', 'hide' ) ) {
|
1217 |
echo '1';
|
1218 |
} else {
|
1219 |
echo '0';
|
1231 |
* @return void
|
1232 |
*/
|
1233 |
public function rt_media_regeneration() {
|
1234 |
+
if ( ! check_ajax_referer( '_rt-start-media-regenerate_', '_rtm_nonce' ) ) {
|
1235 |
+
wp_send_json( false );
|
1236 |
+
}
|
1237 |
+
$media_id = sanitize_text_field( intval( $_POST['media_id'] ) );
|
1238 |
+
if ( isset( $media_id ) ) {
|
1239 |
+
$model = new RTMediaModel();
|
1240 |
+
$media = $model->get_media( array( 'media_id' => $media_id ), 0, 1 );
|
1241 |
+
$media_type = $media[0]->media_type;
|
1242 |
+
$response = array();
|
1243 |
+
if ( 'video' === $media_type ) {
|
1244 |
+
$obj_rtmedia_encoding = new RTMediaEncoding( true );
|
1245 |
+
$autoformat = 'thumbnails';
|
1246 |
+
$obj_rtmedia_encoding->reencoding( $media_id, $autoformat );
|
1247 |
+
$response['status'] = true;
|
1248 |
} else {
|
1249 |
+
$response['status'] = false;
|
1250 |
+
$response['message'] = esc_html__( 'not a video ...', 'buddypress-media' );
|
1251 |
}
|
1252 |
+
echo wp_json_encode( $response );
|
1253 |
die();
|
1254 |
}
|
1255 |
}
|
1256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1257 |
/**
|
1258 |
* Render the BuddyPress Media Settings page.
|
1259 |
*
|
1369 |
*
|
1370 |
* @param void
|
1371 |
*
|
1372 |
+
* @return string | array
|
1373 |
*/
|
1374 |
static function get_current_tab() {
|
1375 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
1376 |
+
return isset( $page ) ? $page : 'rtmedia-settings';
|
1377 |
}
|
1378 |
|
1379 |
/**
|
1382 |
* @access public
|
1383 |
* @global string 'buddypress-media'
|
1384 |
*
|
1385 |
+
* @param string $page
|
1386 |
+
* @param array $option_group
|
1387 |
*
|
1388 |
* @return void
|
1389 |
*/
|
1390 |
public function render_page( $page, $option_group = null ) {
|
1391 |
?>
|
1392 |
|
1393 |
+
<div class="wrap bp-media-admin <?php echo esc_attr( $this->get_current_tab() ); ?>">
|
1394 |
<div id="icon-buddypress-media" class="icon32"><br></div>
|
1395 |
<div>
|
1396 |
<h2 class="nav-tab-wrapper"><?php $this->rtmedia_tabs(); ?>
|
1397 |
<span class="alignright by">
|
1398 |
+
<a class="rt-link"
|
1399 |
+
href="https://rtmedia.io/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media"
|
1400 |
+
target="_blank"
|
1401 |
+
title="rtCamp : <?php esc_attr_e( 'Empowering The Web With WordPress', 'buddypress-media' ); ?>">
|
1402 |
+
<img src="<?php echo esc_url( RTMEDIA_URL ); ?>app/assets/admin/img/rtcamp-logo.png" alt="rtCamp"/>
|
1403 |
</a>
|
1404 |
</span>
|
1405 |
</h2>
|
1410 |
<div id="bp-media-settings-boxes" class="bp-media-settings-boxes-container rtm-setting-container">
|
1411 |
|
1412 |
<?php
|
1413 |
+
if ( 'rtmedia-settings' === $page ) {
|
|
|
1414 |
?>
|
1415 |
<form id="bp_media_settings_form" name="bp_media_settings_form" method="post"
|
1416 |
+
enctype="multipart/form-data">
|
1417 |
+
<div class="bp-media-metabox-holder">
|
1418 |
+
<div class="rtm-button-container top">
|
1419 |
+
<?php $is_setting_save = filter_input( INPUT_GET, 'settings-saved', FILTER_VALIDATE_BOOLEAN );
|
1420 |
+
if ( ! empty( $is_setting_save ) ) { ?>
|
1421 |
+
<div class="rtm-success rtm-fly-warning rtm-save-settings-msg">
|
1422 |
+
<?php esc_html_e( 'Settings saved successfully!', 'buddypress-media' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1423 |
</div>
|
1424 |
+
<?php } ?>
|
1425 |
+
<input type="hidden" name="rtmedia-options-save" value="true">
|
1426 |
+
<input type="submit"
|
1427 |
+
class="rtmedia-settings-submit button button-primary button-big"
|
1428 |
+
value="<?php esc_attr_e( 'Save Settings', 'buddypress-media' ); ?>">
|
1429 |
+
</div>
|
1430 |
+
<?php
|
1431 |
+
settings_fields( $option_group );
|
1432 |
+
if ( 'rtmedia-settings' === $page ) {
|
1433 |
+
echo '<div id="rtm-settings-tabs">';
|
1434 |
+
$sub_tabs = $this->settings_sub_tabs();
|
1435 |
+
RTMediaFormHandler::rtForm_settings_tabs_content( $page, $sub_tabs );
|
1436 |
+
echo '</div>';
|
1437 |
+
} else {
|
1438 |
+
do_settings_sections( $page );
|
1439 |
+
}
|
1440 |
+
?>
|
1441 |
|
1442 |
+
<div class="rtm-button-container bottom">
|
1443 |
+
<div class="rtm-social-links alignleft">
|
1444 |
+
<a href="http://twitter.com/rtcamp" class="twitter" target="_blank"><span
|
1445 |
+
class="dashicons dashicons-twitter"></span></a>
|
1446 |
+
<a href="https://www.facebook.com/rtCamp.solutions" class="facebook"
|
1447 |
+
target="_blank"><span class="dashicons dashicons-facebook"></span></a>
|
1448 |
+
<a href="http://profiles.wordpress.org/rtcamp" class="wordpress"
|
1449 |
+
target="_blank"><span class="dashicons dashicons-wordpress"></span></a>
|
1450 |
+
<a href="https://rtmedia.io/feed/" class="rss" target="_blank"><span
|
1451 |
+
class="dashicons dashicons-rss"></span></a>
|
1452 |
</div>
|
1453 |
+
|
1454 |
+
<input type="hidden" name="rtmedia-options-save" value="true">
|
1455 |
+
<input type="submit"
|
1456 |
+
class="rtmedia-settings-submit button button-primary button-big"
|
1457 |
+
value="<?php esc_attr_e( 'Save Settings', 'buddypress-media' ); ?>">
|
1458 |
</div>
|
1459 |
+
</div>
|
1460 |
</form><?php
|
1461 |
} else {
|
1462 |
?>
|
1463 |
<div class="bp-media-metabox-holder">
|
1464 |
<?php
|
1465 |
+
if ( 'rtmedia-addons' === $page ) {
|
1466 |
RTMediaAddon::render_addons( $page );
|
1467 |
+
} else if ( 'rtmedia-support' === $page ) {
|
1468 |
$rtmedia_support = new RTMediaSupport( false );
|
1469 |
$rtmedia_support->render_support( $page );
|
1470 |
+
} else if ( 'rtmedia-themes' === $page ) {
|
1471 |
RTMediaThemes::render_themes( $page );
|
1472 |
} else {
|
1473 |
+
if ( 'rtmedia-license' === $page ) {
|
1474 |
RTMediaLicense::render_license( $page );
|
1475 |
} else {
|
1476 |
do_settings_sections( $page );
|
1498 |
* Adds a tab for Media settings in the BuddyPress settings page
|
1499 |
*
|
1500 |
* @access public
|
|
|
1501 |
*
|
1502 |
* @param void
|
1503 |
* @param void
|
1504 |
*
|
1505 |
+
* @return string $tabs_html
|
1506 |
*/
|
1507 |
public function tab() {
|
1508 |
|
1509 |
+
$tabs_html = '';
|
1510 |
+
$idle_class = 'nav-tab';
|
1511 |
$active_class = 'nav-tab nav-tab-active';
|
1512 |
+
$tabs = array();
|
1513 |
|
1514 |
// Check to see which tab we are on
|
1515 |
$tab = $this->get_current_tab();
|
1516 |
/* rtMedia */
|
1517 |
$tabs[] = array(
|
1518 |
+
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-settings' ), 'admin.php' ) ) ),
|
1519 |
+
'title' => esc_html__( 'rtMedia', 'buddypress-media' ),
|
1520 |
+
'name' => esc_html__( 'rtMedia', 'buddypress-media' ),
|
1521 |
+
'class' => ( 'rtmedia-settings' === $tab || 'rtmedia-addons' === $tab || 'rtmedia-support' === $tab || 'rtmedia-importer' === $tab ) ? $active_class : $idle_class,
|
1522 |
);
|
1523 |
|
1524 |
foreach ( $tabs as $tab ) {
|
1525 |
+
echo '<a id="bp-media" title= "' . esc_attr( $tab['title'] ) . '" href="' . esc_url( $tab['href'] ) . '" class="' . esc_attr( $tab['class'] ) . '">' . esc_html( $tab['name'] ) . '</a>';
|
1526 |
}
|
|
|
1527 |
}
|
1528 |
|
1529 |
/**
|
1531 |
*
|
1532 |
* @access public
|
1533 |
*
|
1534 |
+
* @param void
|
1535 |
*
|
1536 |
* @return void
|
1537 |
*/
|
1538 |
+
public function rtmedia_tabs() {
|
1539 |
// Declare local variables
|
1540 |
+
$idle_class = 'nav-tab';
|
|
|
1541 |
$active_class = 'nav-tab nav-tab-active';
|
1542 |
|
1543 |
// Setup core admin tabs
|
1544 |
$tabs = array(
|
1545 |
array(
|
1546 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-settings' ), 'admin.php' ) ) ),
|
1547 |
+
'name' => esc_html__( 'Settings', 'buddypress-media' ),
|
1548 |
'slug' => 'rtmedia-settings',
|
1549 |
+
),
|
1550 |
+
array(
|
1551 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-addons' ), 'admin.php' ) ) ),
|
1552 |
+
'name' => esc_html__( 'Addons', 'buddypress-media' ),
|
1553 |
'slug' => 'rtmedia-addons',
|
1554 |
+
),
|
1555 |
+
);
|
1556 |
+
|
1557 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
1558 |
+
$tabs[] = array(
|
1559 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-themes' ), 'admin.php' ) ) ),
|
1560 |
+
'name' => esc_html__( 'Themes', 'buddypress-media' ),
|
1561 |
'slug' => 'rtmedia-themes',
|
1562 |
+
);
|
1563 |
+
|
1564 |
+
$tabs[] = array(
|
1565 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-hire-us' ), 'admin.php' ) ) ),
|
1566 |
+
'name' => esc_html__( 'Hire Us', 'buddypress-media' ),
|
1567 |
'slug' => 'rtmedia-hire-us',
|
1568 |
+
);
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
$tabs[] = array(
|
1572 |
+
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-support' ), 'admin.php' ) ) ),
|
1573 |
+
'name' => esc_html__( 'Support', 'buddypress-media' ),
|
1574 |
+
'slug' => 'rtmedia-support',
|
1575 |
);
|
1576 |
|
1577 |
if ( has_filter( 'rtmedia_license_tabs' ) || has_action( 'rtmedia_addon_license_details' ) ) {
|
1578 |
$tabs[] = array(
|
1579 |
'href' => get_admin_url( null, esc_url( add_query_arg( array( 'page' => 'rtmedia-license' ), 'admin.php' ) ) ),
|
1580 |
+
'name' => esc_html__( 'Licenses', 'buddypress-media' ),
|
1581 |
'slug' => 'rtmedia-license',
|
1582 |
);
|
1583 |
}
|
1586 |
|
1587 |
// Loop through tabs and build navigation
|
1588 |
foreach ( array_values( $tabs ) as $tab_data ) {
|
1589 |
+
$is_current = (bool) ( $tab_data['slug'] === $this->get_current_tab() );
|
1590 |
+
$tab_class = $is_current ? $active_class : $idle_class;
|
1591 |
|
1592 |
+
if ( isset( $tab_data['class'] ) && is_array( $tab_data['class'] ) ) {
|
1593 |
+
$tab_class .= ' ' . implode( ' ', $tab_data['class'] );
|
1594 |
}
|
1595 |
|
1596 |
+
echo '<a href="' . esc_url( $tab_data['href'] ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab_data['name'] ) . '</a>';
|
1597 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1598 |
}
|
1599 |
|
1600 |
/**
|
1602 |
*
|
1603 |
* @access public
|
1604 |
*
|
1605 |
+
* @param string $page
|
1606 |
*
|
1607 |
* @return void
|
1608 |
*/
|
1613 |
return;
|
1614 |
}
|
1615 |
|
1616 |
+
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
|
1617 |
+
if ( $section['title'] ) {
|
1618 |
+
?><h3><?php esc_html( $section['title'] ); ?></h3><?php
|
1619 |
}
|
1620 |
|
1621 |
+
if ( $section['callback'] ) {
|
1622 |
+
call_user_func( $section['callback'], $section );
|
1623 |
}
|
1624 |
|
1625 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
|
1626 |
continue;
|
1627 |
}
|
1628 |
|
1629 |
echo '<table class="form-table">';
|
1630 |
+
do_settings_fields( $page, $section['id'] );
|
1631 |
echo '</table>';
|
1632 |
}
|
1633 |
}
|
1636 |
* Adds a sub tabs to the BuddyPress Media settings page
|
1637 |
*
|
1638 |
* @access public
|
|
|
1639 |
*
|
1640 |
* @param void
|
1641 |
*
|
1642 |
* @return array $tabs
|
1643 |
*/
|
1644 |
public function settings_sub_tabs() {
|
1645 |
+
$tabs = array();
|
|
|
1646 |
|
1647 |
// Check to see which tab we are on
|
1648 |
$tab = $this->get_current_tab();
|
1649 |
/* rtMedia */
|
1650 |
|
1651 |
+
$tabs[7] = array(
|
1652 |
+
'href' => '#rtmedia-display',
|
1653 |
+
'icon' => 'dashicons-desktop',
|
1654 |
+
'title' => esc_html__( 'Display', 'buddypress-media' ),
|
1655 |
+
'name' => esc_html__( 'Display', 'buddypress-media' ),
|
1656 |
+
'callback' => array( 'RTMediaFormHandler', 'display_content' ),
|
1657 |
);
|
1658 |
|
1659 |
if ( class_exists( 'BuddyPress' ) ) {
|
1660 |
+
$tabs[20] = array(
|
1661 |
+
'href' => '#rtmedia-bp',
|
1662 |
+
'icon' => 'dashicons-groups',
|
1663 |
+
'title' => esc_html__( 'rtMedia BuddyPress', 'buddypress-media' ),
|
1664 |
+
'name' => esc_html__( 'BuddyPress', 'buddypress-media' ),
|
1665 |
+
'callback' => array( 'RTMediaFormHandler', 'buddypress_content' ), //change it to BuddyPress Content
|
1666 |
);
|
1667 |
}
|
1668 |
|
1669 |
+
$tabs[30] = array(
|
1670 |
+
'href' => '#rtmedia-types',
|
1671 |
+
'icon' => 'dashicons-editor-video',
|
1672 |
+
'title' => esc_html__( 'rtMedia Types', 'buddypress-media' ),
|
1673 |
+
'name' => esc_html__( 'Types', 'buddypress-media' ),
|
1674 |
+
'callback' => array( 'RTMediaFormHandler', 'types_content' ),
|
1675 |
);
|
1676 |
|
1677 |
+
$tabs[40] = array(
|
1678 |
+
'href' => '#rtmedia-sizes',
|
1679 |
+
'icon' => 'dashicons-editor-expand',
|
1680 |
+
'title' => esc_html__( 'rtMedia Sizes', 'buddypress-media' ),
|
1681 |
+
'name' => esc_html__( 'Media Sizes', 'buddypress-media' ),
|
1682 |
+
'callback' => array( 'RTMediaFormHandler', 'sizes_content' ),
|
1683 |
);
|
1684 |
|
1685 |
+
$tabs[50] = array(
|
1686 |
+
'href' => '#rtmedia-privacy',
|
1687 |
+
'icon' => 'dashicons-lock',
|
1688 |
+
'title' => esc_html__( 'rtMedia Privacy', 'buddypress-media' ),
|
1689 |
+
'name' => esc_html__( 'Privacy', 'buddypress-media' ),
|
1690 |
+
'callback' => array( 'RTMediaFormHandler', 'privacy_content' ),
|
1691 |
);
|
1692 |
+
$tabs[60] = array(
|
1693 |
+
'href' => '#rtmedia-custom-css-settings',
|
1694 |
+
'icon' => 'dashicons-clipboard',
|
1695 |
+
'title' => esc_html__( 'rtMedia Custom CSS', 'buddypress-media' ),
|
1696 |
+
'name' => esc_html__( 'Custom CSS', 'buddypress-media' ),
|
1697 |
+
'callback' => array( 'RTMediaFormHandler', 'custom_css_content' ),
|
1698 |
);
|
1699 |
|
1700 |
$tabs = apply_filters( 'rtmedia_add_settings_sub_tabs', $tabs, $tab );
|
1701 |
|
1702 |
$tabs[] = array(
|
1703 |
+
'href' => '#rtmedia-general',
|
1704 |
+
'icon' => 'dashicons-admin-tools',
|
1705 |
+
'title' => esc_html__( 'Other Settings', 'buddypress-media' ),
|
1706 |
+
'name' => esc_html__( 'Other Settings', 'buddypress-media' ),
|
1707 |
+
'callback' => array( 'RTMediaFormHandler', 'general_content' ),
|
1708 |
);
|
1709 |
|
1710 |
return $tabs;
|
1711 |
}
|
1712 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1713 |
/**
|
1714 |
* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503
|
1715 |
*
|
1722 |
*/
|
1723 |
public function save_multisite_options() {
|
1724 |
global $rtmedia_admin;
|
1725 |
+
do_action( 'rtmedia_sanitize_settings', wp_unslash( $_POST ) ); // @codingStandardsIgnoreLine
|
|
|
|
|
|
|
1726 |
|
1727 |
+
$rtmedia_options = filter_input( INPUT_POST, 'rtmedia_options' );
|
1728 |
+
if ( isset( $rtmedia_options ) ) {
|
1729 |
+
//todo: How we can sanitize array?
|
1730 |
+
rtmedia_update_site_option( 'rtmedia_options', $rtmedia_options );
|
1731 |
//
|
1732 |
// redirect to settings page in network
|
1733 |
+
wp_redirect( esc_url_raw( add_query_arg( array(
|
1734 |
+
'page' => 'rtmedia-settings',
|
1735 |
+
'updated' => 'true',
|
1736 |
+
), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) ) );
|
1737 |
exit;
|
1738 |
}
|
1739 |
}
|
1742 |
* Admin Sidebar
|
1743 |
*
|
1744 |
* @access public
|
|
|
1745 |
*
|
1746 |
* @param void
|
1747 |
*
|
1750 |
public function admin_sidebar() {
|
1751 |
do_action( 'rtmedia_before_default_admin_widgets' );
|
1752 |
$current_user = wp_get_current_user();
|
1753 |
+
$message = sprintf( esc_html__( 'I use @rtMediaWP http://rt.cx/rtmedia on %s', 'buddypress-media' ), home_url() );
|
1754 |
+
$addons = '<div id="social" class="rtm-social-share">
|
1755 |
+
<p><a href="http://twitter.com/home/?status=' . esc_attr( $message ) . '" class="button twitter" target= "_blank" title="' . esc_attr__( 'Post to Twitter Now', 'buddypress-media' ) . '">' . esc_html__( 'Post to Twitter', 'buddypress-media' ) . '<span class="dashicons dashicons-twitter"></span></a></p>
|
1756 |
+
<p><a href="https://www.facebook.com/sharer/sharer.php?u=https://rtmedia.io/" class="button facebook" target="_blank" title="' . esc_attr__( 'Share on Facebook Now', 'buddypress-media' ) . '">' . esc_html__( 'Share on Facebook', 'buddypress-media' ) . '<span class="dashicons dashicons-facebook"></span></a></p>
|
1757 |
+
<p><a href="http://wordpress.org/support/view/plugin-reviews/buddypress-media?rate=5#postform" class="button wordpress" target= "_blank" title="' . esc_attr__( 'Rate rtMedia on Wordpress.org', 'buddypress-media' ) . '">' . esc_html__( 'Rate on Wordpress.org', 'buddypress-media' ) . '<span class="dashicons dashicons-wordpress"></span></a></p>
|
1758 |
+
<p><a href="' . sprintf( '%s', 'https://rtmedia.io/feed/' ) . '" class="button rss" target="_blank" title="' . esc_attr__( 'Subscribe to our Feeds', 'buddypress-media' ) . '">' . esc_html__( 'Subscribe to our Feeds', 'buddypress-media' ) . '<span class="dashicons dashicons-rss"></span></a></p>
|
1759 |
+
</div>';
|
1760 |
|
1761 |
+
new RTMediaAdminWidget( 'spread-the-word', esc_html__( 'Spread the Word', 'buddypress-media' ), $addons );
|
1762 |
|
1763 |
$branding = '<form action="http://rtcamp.us1.list-manage1.com/subscribe/post?u=85b65c9c71e2ba3fab8cb1950&id=9e8ded4470" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
|
1764 |
+
<div class="mc-field-group">
|
1765 |
+
<input type="email" value="' . esc_attr( $current_user->user_email ) . '" name="EMAIL" placeholder="Email" class="required email" id="mce-EMAIL">
|
1766 |
+
<input style="display:none;" type="checkbox" checked="checked" value="1" name="group[1721][1]" id="mce-group[1721]-1721-0">
|
1767 |
+
<input type="submit" value="' . esc_attr__( 'Subscribe', 'buddypress-media' ) . '" name="subscribe" id="mc-embedded-subscribe" class="button">
|
1768 |
+
<div id="mce-responses" class="clear">
|
1769 |
+
<div class="response" id="mce-error-response" style="display:none"></div>
|
1770 |
+
<div class="response" id="mce-success-response" style="display:none"></div>
|
1771 |
+
</div>
|
1772 |
+
</div>
|
1773 |
+
</form>';
|
1774 |
+
new RTMediaAdminWidget( 'branding', esc_html__( 'Subscribe', 'buddypress-media' ), $branding );
|
1775 |
+
|
|
|
|
|
1776 |
do_action( 'rtmedia_after_default_admin_widgets' );
|
1777 |
}
|
1778 |
|
1779 |
public function linkback() {
|
1780 |
+
//Fixme: remove code looks like old setting save code new code at app/helper/RTMediaSettings.php
|
1781 |
+
$linkback = filter_input( INPUT_POST, 'linkback' );
|
1782 |
+
if ( isset( $linkback ) && $linkback ) {
|
1783 |
return rtmedia_update_site_option( 'rtmedia-add-linkback', true );
|
1784 |
} else {
|
1785 |
return rtmedia_update_site_option( 'rtmedia-add-linkback', false );
|
1786 |
}
|
|
|
1787 |
}
|
1788 |
|
1789 |
public function convert_videos_mailchimp_send() {
|
1790 |
+
//todo: nonce required
|
1791 |
+
$interested = filter_input( INPUT_POST, 'linkback', FILTER_SANITIZE_STRING );
|
1792 |
+
$choice = filter_input( INPUT_POST, 'choice', FILTER_SANITIZE_STRING );
|
1793 |
+
$url = filter_input( INPUT_POST, 'url', FILTER_SANITIZE_URL );
|
1794 |
+
$email = filter_input( INPUT_POST, 'email', FILTER_SANITIZE_EMAIL );
|
1795 |
+
if ( 'Yes' === $interested && ! empty( $choice ) ) {
|
1796 |
+
wp_remote_get( esc_url_raw( add_query_arg( array(
|
1797 |
+
'rtmedia-convert-videos-form' => 1,
|
1798 |
+
'choice' => $choice,
|
1799 |
+
'url' => $url,
|
1800 |
+
'email' => $email,
|
1801 |
+
), 'https://rtmedia.io/' ) ) );
|
1802 |
} else {
|
1803 |
rtmedia_update_site_option( 'rtmedia-survey', 0 );
|
1804 |
}
|
1805 |
+
esc_html_e( 'Thank you for your time.', 'buddypress-media' );
|
1806 |
+
wp_die();
|
1807 |
}
|
1808 |
|
1809 |
public function video_transcoding_survey_response() {
|
1810 |
+
$survey_done = filter_input( INPUT_GET, 'survey-done', FILTER_SANITIZE_STRING );
|
1811 |
+
if ( isset( $survey_done ) && ( md5( 'survey-done' ) === $survey_done ) ) {
|
1812 |
rtmedia_update_site_option( 'rtmedia-survey', 0 );
|
1813 |
}
|
1814 |
}
|
1815 |
|
1816 |
+
public function plugin_meta_premium_addon_link( $plugin_meta, $plugin_file ) {
|
1817 |
+
if ( plugin_basename( RTMEDIA_PATH . 'index.php' ) === $plugin_file ) {
|
1818 |
+
$plugin_meta[] = '<a href="https://rtmedia.io/products/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media" title="' . esc_attr__( 'Premium Add-ons', 'buddypress-media' ) . '">' . esc_html__( 'Premium Add-ons', 'buddypress-media' ) . '</a>';
|
1819 |
}
|
1820 |
|
1821 |
return $plugin_meta;
|
1825 |
global $rtmedia;
|
1826 |
$upload_filetypes = rtmedia_get_site_option( 'upload_filetypes', 'jpg jpeg png gif' );
|
1827 |
$upload_filetypes = explode( ' ', $upload_filetypes );
|
1828 |
+
$flag = false;
|
1829 |
+
if ( isset( $rtmedia->options['images_enabled'] ) && $rtmedia->options['images_enabled'] ) {
|
1830 |
$not_supported_image = array_diff( array( 'jpg', 'jpeg', 'png', 'gif' ), $upload_filetypes );
|
1831 |
if ( ! empty( $not_supported_image ) ) {
|
1832 |
+
?>
|
1833 |
+
<div class="error upload-filetype-network-settings-error">
|
1834 |
+
<p>
|
1835 |
+
<?php wp_nonce_field( '_rtm_file_type_error_', 'rtm-file-type-error' ); ?>
|
1836 |
+
<?php printf( esc_html__( 'You have images enabled on rtMedia but your network allowed filetypes do not permit uploading of %s. Click ', 'buddypress-media' ), esc_html( implode( ', ', $not_supported_image ) ) ) ?>
|
1837 |
+
<a href='<?php echo esc_url( network_admin_url( 'settings.php#upload_filetypes' ) );?>'><?php esc_html_e( 'here', 'buddypress-media' ) ?></a>
|
1838 |
+
<?php esc_html_e( ' to change your settings manually.', 'buddypress-media' ) ?>
|
1839 |
+
<br />
|
1840 |
+
<strong><?php esc_html_e( 'Recommended:', 'buddypress-media' ); ?></strong>
|
1841 |
+
<input type="button" class="button update-network-settings-upload-filetypes" value="<?php esc_attr_e( 'Update Network Settings Automatically', 'buddypress-media' );?>">
|
1842 |
+
<img style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
|
1843 |
+
</p>
|
1844 |
+
</div>
|
1845 |
+
<?php
|
1846 |
$flag = true;
|
1847 |
}
|
1848 |
}
|
1849 |
+
if ( isset( $rtmedia->options['videos_enabled'] ) && $rtmedia->options['videos_enabled'] ) {
|
1850 |
+
if ( ! in_array( 'mp4', $upload_filetypes, true ) ) {
|
1851 |
+
?>
|
1852 |
+
<div class="error upload-filetype-network-settings-error">
|
1853 |
+
<p>
|
1854 |
+
<?php esc_html_e( 'You have video enabled on BuddyPress Media but your network allowed filetypes do not permit uploading of mp4. Click ', 'buddypress-media' ) ?>
|
1855 |
+
<a href='<?php echo esc_url( network_admin_url( 'settings.php#upload_filetypes' ) );?>'><?php esc_html_e( 'here', 'buddypress-media' ) ?></a>
|
1856 |
+
<?php esc_html_e( ' to change your settings manually.', 'buddypress-media' ) ?>
|
1857 |
+
<br />
|
1858 |
+
<strong><?php esc_html_e( 'Recommended:', 'buddypress-media' );?></strong>
|
1859 |
+
<input type="button" class="button update-network-settings-upload-filetypes" value="<?php esc_attr_e( 'Update Network Settings Automatically', 'buddypress-media' ); ?>">
|
1860 |
+
<img style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
|
1861 |
+
</p>
|
1862 |
+
</div>
|
1863 |
+
<?php
|
1864 |
$flag = true;
|
1865 |
}
|
1866 |
}
|
1867 |
+
if ( isset( $rtmedia->options['audio_enabled'] ) && $rtmedia->options['audio_enabled'] ) {
|
1868 |
+
if ( ! in_array( 'mp3', $upload_filetypes, true ) ) {
|
1869 |
+
?>
|
1870 |
+
<div class="error upload-filetype-network-settings-error">
|
1871 |
+
<p>
|
1872 |
+
<?php esc_html_e( 'You have audio enabled on BuddyPress Media but your network allowed filetypes do not permit uploading of mp3. Click ', 'buddypress-media' ) ?>
|
1873 |
+
<a href='<?php echo esc_url( network_admin_url( 'settings.php#upload_filetypes' ) );?>'><?php esc_html_e( 'here', 'buddypress-media' ) ?></a>
|
1874 |
+
<?php esc_html_e( ' to change your settings manually.', 'buddypress-media' ) ?>
|
1875 |
+
<br />
|
1876 |
+
<strong><?php esc_html_e( 'Recommended:', 'buddypress-media' ); ?></strong>
|
1877 |
+
<input type="button" class="button update-network-settings-upload-filetypes" value="<?php esc_attr_e( 'Update Network Settings Automatically', 'buddypress-media' ); ?>">
|
1878 |
+
<img style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
|
1879 |
+
</p>
|
1880 |
+
</div>
|
1881 |
+
<?php
|
1882 |
$flag = true;
|
1883 |
}
|
1884 |
}
|
1885 |
if ( $flag ) {
|
1886 |
?>
|
1887 |
<script type="text/javascript">
|
1888 |
+
jQuery('.upload-filetype-network-settings-error').on('click', '.update-network-settings-upload-filetypes', function () {
|
1889 |
+
jQuery('.update-network-settings-upload-filetypes').siblings('img').show();
|
1890 |
+
jQuery('.update-network-settings-upload-filetypes').prop('disabled', true);
|
1891 |
+
jQuery.post(ajaxurl, {action: 'rtmedia_correct_upload_filetypes', _rtm_nonce: jQuery('rtm-file-type-error').val()}, function (response) {
|
1892 |
+
if (response) {
|
1893 |
+
jQuery('.upload-filetype-network-settings-error:first').after('<div style="display: none;" class="updated rtmedia-network-settings-updated-successfully"><p><?php esc_html_e( 'Network settings updated successfully.', 'buddypress-media' ); ?></p></div>');
|
1894 |
+
jQuery('.upload-filetype-network-settings-error').remove();
|
1895 |
+
jQuery('.bp-media-network-settings-updated-successfully').show();
|
1896 |
}
|
1897 |
+
});
|
1898 |
+
});
|
1899 |
</script>
|
1900 |
<?php
|
1901 |
}
|
1902 |
}
|
1903 |
|
1904 |
public function correct_upload_filetypes() {
|
1905 |
+
if ( ! check_ajax_referer( '_rtm_file_type_error_', '_rtm_nonce' ) ) {
|
1906 |
+
wp_send_json( false );
|
1907 |
+
}
|
1908 |
global $rtmedia;
|
1909 |
$upload_filetypes_orig = $upload_filetypes = rtmedia_get_site_option( 'upload_filetypes', 'jpg jpeg png gif' );
|
1910 |
+
$upload_filetypes = explode( ' ', $upload_filetypes );
|
1911 |
+
if ( isset( $rtmedia->options['images_enabled'] ) && $rtmedia->options['images_enabled'] ) {
|
1912 |
$not_supported_image = array_diff( array( 'jpg', 'jpeg', 'png', 'gif' ), $upload_filetypes );
|
1913 |
if ( ! empty( $not_supported_image ) ) {
|
1914 |
$update_image_support = null;
|
1921 |
}
|
1922 |
}
|
1923 |
}
|
1924 |
+
if ( isset( $rtmedia->options['videos_enabled'] ) && $rtmedia->options['videos_enabled'] ) {
|
1925 |
+
if ( ! in_array( 'mp4', $upload_filetypes, true ) ) {
|
1926 |
$upload_filetypes_orig .= ' mp4';
|
1927 |
rtmedia_update_site_option( 'upload_filetypes', $upload_filetypes_orig );
|
1928 |
}
|
1929 |
}
|
1930 |
+
if ( isset( $rtmedia->options['audio_enabled'] ) && $rtmedia->options['audio_enabled'] ) {
|
1931 |
+
if ( ! in_array( 'mp3', $upload_filetypes, true ) ) {
|
1932 |
$upload_filetypes_orig .= ' mp3';
|
1933 |
rtmedia_update_site_option( 'upload_filetypes', $upload_filetypes_orig );
|
1934 |
}
|
1935 |
}
|
1936 |
echo true;
|
1937 |
+
wp_die();
|
1938 |
}
|
1939 |
|
1940 |
function edit_video_thumbnail( $form_fields, $post ) {
|
1941 |
if ( isset( $post->post_mime_type ) ) {
|
1942 |
$media_type = explode( '/', $post->post_mime_type );
|
1943 |
+
if ( is_array( $media_type ) && 'video' === $media_type[0] ) {
|
1944 |
+
$media_id = $post->ID;
|
1945 |
+
$thumbnail_array = get_post_meta( $media_id, 'rtmedia_media_thumbnails', true );
|
1946 |
+
$rtmedia_model = new RTMediaModel();
|
1947 |
+
$rtmedia_media = $rtmedia_model->get( array( 'media_id' => $media_id ) );
|
1948 |
$video_thumb_html = '';
|
1949 |
if ( is_array( $thumbnail_array ) ) {
|
1950 |
$video_thumb_html .= '<ul> ';
|
1951 |
|
1952 |
foreach ( $thumbnail_array as $key => $thumbnail_src ) {
|
1953 |
+
$checked = checked( $thumbnail_src, $rtmedia_media[0]->cover_art, false );
|
1954 |
+
$count = $key + 1;
|
1955 |
$video_thumb_html .= '<li style="width: 150px;display: inline-block;">
|
1956 |
+
<label for="rtmedia-upload-select-thumbnail-' . esc_attr( $count ) . '">
|
1957 |
+
<input type="radio" ' . esc_attr( $checked ) . ' id="rtmedia-upload-select-thumbnail-' . esc_attr( $count ) . '" value="' . esc_url( $thumbnail_src ) . '" name="rtmedia-thumbnail" />
|
1958 |
+
<img src=" ' . esc_url( $thumbnail_src ) . '" style="max-height: 120px;max-width: 120px; vertical-align: middle;" />
|
1959 |
+
</label></li> ';
|
|
|
1960 |
}
|
1961 |
|
1962 |
$video_thumb_html .= ' </ul>';
|
1963 |
+
$form_fields['rtmedia_video_thumbnail'] = array(
|
1964 |
+
'label' => 'Video Thumbnails',
|
1965 |
+
'input' => 'html',
|
1966 |
+
'html' => $video_thumb_html,
|
1967 |
);
|
1968 |
}
|
1969 |
}
|
1972 |
return $form_fields;
|
1973 |
}
|
1974 |
|
1975 |
+
function save_video_thumbnail( $post ) {
|
1976 |
+
$rtmedia_thumbnail = filter_input( INPUT_POST, 'rtmedia-thumbnail', FILTER_SANITIZE_STRING );
|
1977 |
+
$id = filter_input( INPUT_POST, 'ID', FILTER_SANITIZE_NUMBER_INT );
|
1978 |
+
if ( isset( $rtmedia_thumbnail ) ) {
|
1979 |
$rtmedia_model = new RTMediaModel();
|
1980 |
+
$model = new RTMediaModel();
|
1981 |
+
$media = $model->get( array( 'media_id' => $id ) );
|
1982 |
+
$media_id = $media[0]->id;
|
1983 |
+
$rtmedia_model->update( array( 'cover_art' => $rtmedia_thumbnail ), array( 'media_id' => $id ) );
|
1984 |
update_activity_after_thumb_set( $media_id );
|
1985 |
}
|
1986 |
|
1990 |
function rtmedia_regenerate_thumb_js() {
|
1991 |
global $pagenow;
|
1992 |
|
1993 |
+
if ( 'upload.php' === $pagenow ) {
|
1994 |
?>
|
1995 |
<script type="text/javascript">
|
1996 |
+
function rtmedia_regenerate_thumbs(post_id) {
|
1997 |
+
if (post_id != "") {
|
1998 |
var data = {
|
1999 |
action: 'rt_media_regeneration',
|
2000 |
media_id: post_id
|
2001 |
};
|
2002 |
+
jQuery.post(ajaxurl, data, function (data) {
|
2003 |
+
data = JSON.parse(data);
|
2004 |
+
if (data.status === true) {
|
2005 |
+
alert("<?php esc_html_e( 'Video is sent to generate thumbnails.', 'buddypress-media' ) ?>");
|
2006 |
} else {
|
2007 |
+
alert("<?php esc_html_e( 'Video cannot be sent to generate thumbnails.', 'buddypress-media' ) ?>");
|
2008 |
}
|
2009 |
+
});
|
2010 |
}
|
2011 |
}
|
2012 |
</script>
|
2017 |
function add_bulk_actions_regenerate() {
|
2018 |
?>
|
2019 |
<script type="text/javascript">
|
2020 |
+
jQuery(document).ready(function ($) {
|
2021 |
+
$('select[name^="action"] option:last-child').before('<option value="bulk_video_regenerate_thumbnails"><?php esc_html_e( 'Regenerate Video Thumbnails', 'buddypress-media' ); ?></option>');
|
2022 |
+
});
|
2023 |
</script>
|
2024 |
<?php
|
2025 |
}
|
2026 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2027 |
function rtmedia_update_template_notice() {
|
2028 |
$site_option = rtmedia_get_site_option( 'rtmedia-update-template-notice-v3_9_4' );
|
2029 |
|
2030 |
+
if ( ! $site_option || 'hide' !== $site_option ) {
|
2031 |
rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_4', 'show' );
|
2032 |
if ( is_dir( get_template_directory() . '/rtmedia' ) ) {
|
2033 |
+
echo '<div class="error rtmedia-update-template-notice"><p>' . esc_html__( '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.', 'buddypress-media' ) . '<a href="#" onclick="rtmedia_hide_template_override_notice()" style="float:right">' . esc_html__( 'Hide', 'buddypress-media' ) . '</a></p></div>';
|
2034 |
?>
|
2035 |
<script type="text/javascript">
|
2036 |
function rtmedia_hide_template_override_notice() {
|
2037 |
+
var data = {action: 'rtmedia_hide_template_override_notice', _rtm_nonce: jQuery('#rtmedia-update-template-notice-nonce').val()};
|
2038 |
+
jQuery.post(ajaxurl, data, function (response) {
|
2039 |
response = response.trim();
|
2040 |
+
if ('1' === response)
|
2041 |
+
jQuery('.rtmedia-update-template-notice').remove();
|
2042 |
+
});
|
2043 |
}
|
2044 |
</script>
|
2045 |
<?php
|
2049 |
|
2050 |
function rtmedia_hide_template_override_notice() {
|
2051 |
|
2052 |
+
if ( check_ajax_referer( '_rtmedia-update-template-notice_', '_rtm_nonce' ) && rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_4', 'hide' ) ) {
|
2053 |
echo '1';
|
2054 |
} else {
|
2055 |
echo '0';
|
2061 |
|
2062 |
// wrapper class
|
2063 |
$wrapper_class = '';
|
2064 |
+
if ( ! empty( $args['wrapper_class'] ) && is_array( $args['wrapper_class'] ) ) {
|
2065 |
+
$wrapper_class = implode( ' ', $args['wrapper_class'] );
|
2066 |
}
|
2067 |
|
2068 |
// tabs
|
2069 |
+
if ( 'rtmedia-settings' === $page ) {
|
2070 |
$sub_tabs = apply_filters( 'rtmedia_pro_settings_tabs_content', $sub_tabs );
|
2071 |
ksort( $sub_tabs );
|
2072 |
}
|
2073 |
$tab_position_class = 'rtm-vertical-tabs';
|
2074 |
+
if ( 'rtmedia-addons' === $page ) {
|
2075 |
$tab_position_class = 'rtm-horizotanl-tabs';
|
2076 |
}
|
2077 |
?>
|
2078 |
|
2079 |
+
<div
|
2080 |
+
class="clearfix <?php echo esc_attr( $tab_position_class ); ?> rtm-admin-tab-container <?php echo esc_attr( $wrapper_class ); ?>">
|
2081 |
<ul class="rtm-tabs">
|
2082 |
<?php
|
2083 |
$i = 1;
|
2085 |
|
2086 |
// tab status
|
2087 |
$active_class = '';
|
2088 |
+
if ( 1 === $i ) {
|
2089 |
$active_class = 'active';
|
2090 |
}
|
2091 |
|
2092 |
// tab icon
|
2093 |
$icon = '';
|
2094 |
+
if ( isset( $tab['icon'] ) && ! empty( $tab['icon'] ) ) {
|
2095 |
+
$icon = '<i class="' . esc_attr( $tab['icon'] ) . ' dashicons rtmicon"></i>';
|
2096 |
}
|
2097 |
?>
|
2098 |
+
<li class="<?php echo esc_attr( $active_class ) ?>">
|
2099 |
+
<a id="tab-<?php echo esc_attr( substr( $tab['href'], 1 ) ) ?>" title="<?php echo esc_attr( $tab['title'] ); ?>"
|
2100 |
+
href="<?php echo esc_url( $tab['href'] ); ?>"
|
2101 |
+
class="rtmedia-tab-title <?php echo esc_attr( sanitize_title( $tab['name'] ) ); ?>">
|
2102 |
+
<?php echo $icon ; // @codingStandardsIgnoreLine ?><span><?php echo esc_html( $tab['name'] ); ?></span>
|
2103 |
</a>
|
2104 |
</li>
|
2105 |
<?php
|
2113 |
$k = 1;
|
2114 |
foreach ( $sub_tabs as $tab ) {
|
2115 |
$active_class = '';
|
2116 |
+
if ( 1 === $k ) {
|
2117 |
$active_class = ' active';
|
2118 |
}
|
2119 |
$k ++;
|
2120 |
+
if ( isset( $tab['icon'] ) && ! empty( $tab['icon'] ) ) {
|
2121 |
+
$icon = '<i class="' . esc_attr( $tab['icon'] ) . '"></i>';
|
2122 |
}
|
2123 |
+
$tab_without_hash = explode( '#', $tab['href'] );
|
2124 |
+
$tab_without_hash = $tab_without_hash[1];
|
2125 |
+
echo '<div class="rtm-content' . esc_attr( $active_class ) . '" id="' . esc_attr( $tab_without_hash ) . '">';
|
2126 |
+
if ( isset( $tab['args'] ) ) {
|
2127 |
+
call_user_func( $tab['callback'], $page, $tab['args'] );
|
2128 |
} else {
|
2129 |
+
call_user_func( $tab['callback'], $page );
|
2130 |
}
|
2131 |
echo '</div>';
|
2132 |
}
|
2140 |
/**
|
2141 |
* To remove setting saved parameter from url once satting saved
|
2142 |
* Add parameter to this array WP will remove variable from Query string
|
2143 |
+
*
|
2144 |
* @param $removable_query_args
|
2145 |
+
*
|
2146 |
* @return array $removable_query_args
|
2147 |
*/
|
2148 |
function removable_query_args( $removable_query_args ) {
|
2149 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
2150 |
+
if ( isset( $page ) && 'rtmedia-settings' === $page ) {
|
2151 |
$removable_query_args[] = 'settings-saved';
|
2152 |
}
|
2153 |
+
|
2154 |
return $removable_query_args;
|
2155 |
}
|
|
|
2156 |
}
|
2157 |
|
2158 |
}
|
app/admin/RTMediaFormHandler.php
CHANGED
@@ -12,32 +12,30 @@
|
|
12 |
class RTMediaFormHandler {
|
13 |
|
14 |
public static function selectBox( $args ) {
|
15 |
-
global $rtmedia;
|
16 |
-
$options = $rtmedia->options;
|
17 |
$defaults = array(
|
18 |
-
'key'
|
19 |
-
'desc'
|
20 |
-
'default'
|
21 |
'show_desc' => false,
|
22 |
-
'selects'
|
23 |
);
|
24 |
-
$args
|
25 |
extract( $args );
|
26 |
|
27 |
if ( ! empty( $key ) ) {
|
28 |
-
$args[
|
29 |
}
|
30 |
|
31 |
-
$args[
|
32 |
foreach ( $selects as $value => $key ) {
|
33 |
-
$args[
|
34 |
-
$key
|
35 |
'selected' => ( $default == $value ) ? true : false,
|
36 |
);
|
37 |
}
|
38 |
|
39 |
$chkObj = new rtForm();
|
40 |
-
|
41 |
}
|
42 |
|
43 |
/**
|
@@ -46,40 +44,39 @@ class RTMediaFormHandler {
|
|
46 |
* @access static
|
47 |
*
|
48 |
* @param array $args
|
49 |
-
* @param bool
|
50 |
*
|
51 |
* @return string $chkObj->get_textarea( $args )
|
52 |
*/
|
53 |
public static function textarea( $args, $echo = true ) {
|
54 |
-
global $rtmedia;
|
55 |
-
$options = $rtmedia->options;
|
56 |
$defaults = array(
|
57 |
-
'key'
|
58 |
-
'desc'
|
59 |
'show_desc' => false,
|
60 |
);
|
61 |
-
$args
|
62 |
extract( $args );
|
63 |
|
64 |
if ( ! isset( $value ) ) {
|
65 |
-
trigger_error(
|
66 |
|
67 |
return;
|
68 |
}
|
69 |
|
70 |
if ( ! empty( $key ) ) {
|
71 |
-
$args[
|
72 |
}
|
73 |
|
74 |
-
$args[
|
75 |
|
76 |
$chkObj = new rtForm();
|
77 |
|
78 |
if ( $echo ) {
|
79 |
-
|
80 |
} else {
|
81 |
-
return $chkObj->get_textarea( $args );
|
82 |
}
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
@@ -88,41 +85,39 @@ class RTMediaFormHandler {
|
|
88 |
* @access static
|
89 |
*
|
90 |
* @param array $args
|
91 |
-
* @param bool
|
92 |
*
|
93 |
* @return string $chkObj->get_switch( $args )
|
94 |
*/
|
95 |
public static function checkbox( $args, $echo = true ) {
|
96 |
-
global $rtmedia;
|
97 |
-
$options = $rtmedia->options;
|
98 |
$defaults = array(
|
99 |
-
'key'
|
100 |
-
'desc'
|
101 |
'show_desc' => false,
|
102 |
);
|
103 |
-
$args
|
104 |
extract( $args );
|
105 |
|
106 |
if ( ! isset( $value ) ) {
|
107 |
-
trigger_error(
|
108 |
|
109 |
return;
|
110 |
}
|
111 |
|
112 |
if ( ! empty( $key ) ) {
|
113 |
-
$args[
|
114 |
}
|
115 |
|
116 |
-
$args[
|
117 |
|
118 |
$chkObj = new rtForm();
|
119 |
-
|
120 |
if ( $echo ) {
|
121 |
-
|
122 |
} else {
|
123 |
return $chkObj->get_switch( $args );
|
124 |
}
|
125 |
-
|
126 |
}
|
127 |
|
128 |
/**
|
@@ -135,37 +130,35 @@ class RTMediaFormHandler {
|
|
135 |
* @return void
|
136 |
*/
|
137 |
public static function radio( $args ) {
|
138 |
-
global $rtmedia;
|
139 |
-
$options = $rtmedia->options;
|
140 |
$defaults = array(
|
141 |
-
'key'
|
142 |
-
'radios'
|
143 |
-
'default'
|
144 |
'show_desc' => false,
|
145 |
);
|
146 |
-
$args
|
147 |
extract( $args );
|
148 |
|
149 |
if ( 2 > count( $radios ) ) {
|
150 |
-
trigger_error(
|
151 |
|
152 |
return;
|
153 |
}
|
154 |
|
155 |
if ( ! empty( $key ) ) {
|
156 |
-
$args[
|
157 |
}
|
158 |
|
159 |
-
$args[
|
160 |
foreach ( $radios as $value => $key ) {
|
161 |
-
$args[
|
162 |
-
$key
|
163 |
'checked' => ( $default == $value ) ? true : false,
|
164 |
);
|
165 |
}
|
166 |
|
167 |
$objRad = new rtForm();
|
168 |
-
|
169 |
}
|
170 |
|
171 |
/**
|
@@ -176,7 +169,7 @@ class RTMediaFormHandler {
|
|
176 |
*/
|
177 |
public static function dimensions( $args ) {
|
178 |
$dmnObj = new rtDimensions();
|
179 |
-
|
180 |
}
|
181 |
|
182 |
/**
|
@@ -190,28 +183,28 @@ class RTMediaFormHandler {
|
|
190 |
*/
|
191 |
public static function number( $args ) {
|
192 |
global $rtmedia;
|
193 |
-
$options
|
194 |
$defaults = array(
|
195 |
-
'key'
|
196 |
'desc' => '',
|
197 |
);
|
198 |
-
$args
|
199 |
extract( $args );
|
200 |
|
201 |
if ( ! isset( $value ) ) {
|
202 |
-
trigger_error(
|
203 |
|
204 |
return;
|
205 |
}
|
206 |
|
207 |
if ( ! empty( $key ) ) {
|
208 |
-
$args[
|
209 |
}
|
210 |
|
211 |
-
$args[
|
212 |
|
213 |
$numObj = new rtForm();
|
214 |
-
|
215 |
}
|
216 |
|
217 |
/**
|
@@ -225,28 +218,28 @@ class RTMediaFormHandler {
|
|
225 |
*/
|
226 |
public static function textbox( $args ) {
|
227 |
global $rtmedia;
|
228 |
-
$options
|
229 |
$defaults = array(
|
230 |
-
'key'
|
231 |
'desc' => '',
|
232 |
);
|
233 |
-
$args
|
234 |
extract( $args );
|
235 |
|
236 |
if ( ! isset( $value ) ) {
|
237 |
-
trigger_error(
|
238 |
|
239 |
return;
|
240 |
}
|
241 |
|
242 |
if ( ! empty( $key ) ) {
|
243 |
-
$args[
|
244 |
}
|
245 |
|
246 |
-
$args[
|
247 |
|
248 |
$numObj = new rtForm();
|
249 |
-
|
250 |
}
|
251 |
|
252 |
/**
|
@@ -254,7 +247,7 @@ class RTMediaFormHandler {
|
|
254 |
*
|
255 |
* @access static
|
256 |
*
|
257 |
-
* @param array
|
258 |
* @param string $section_name
|
259 |
*
|
260 |
* @return array $section
|
@@ -263,7 +256,7 @@ class RTMediaFormHandler {
|
|
263 |
$section = array();
|
264 |
foreach ( $options as $key => $value ) {
|
265 |
$compare = strncmp( $key, $section_name, strlen( $section_name ) );
|
266 |
-
if ( 0
|
267 |
$section[ $key ] = $value;
|
268 |
}
|
269 |
}
|
@@ -280,10 +273,10 @@ class RTMediaFormHandler {
|
|
280 |
*
|
281 |
* @return array $render
|
282 |
*/
|
283 |
-
static function display_render_options( $options ){
|
284 |
-
$radios
|
285 |
-
$radios['load_more'] = '<strong>' .
|
286 |
-
$radios['pagination'] = '<strong>' .
|
287 |
|
288 |
if ( is_plugin_active( 'regenerate-thumbnails/regenerate-thumbnails.php' ) ) {
|
289 |
$regenerate_link = admin_url( '/tools.php?page=regenerate-thumbnails' );
|
@@ -295,69 +288,70 @@ class RTMediaFormHandler {
|
|
295 |
|
296 |
$render = array(
|
297 |
'general_enableComments' => array(
|
298 |
-
'title'
|
299 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
300 |
-
'args'
|
301 |
-
'key'
|
302 |
-
'value' => $options[
|
303 |
-
'desc'
|
304 |
),
|
305 |
-
'group'
|
306 |
),
|
307 |
'general_enableLightbox' => array(
|
308 |
-
'title'
|
309 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
310 |
-
'args'
|
311 |
-
'key'
|
312 |
-
'value' => $options[
|
313 |
-
'desc'
|
314 |
),
|
315 |
-
'group'
|
316 |
),
|
317 |
-
'general_perPageMedia'
|
318 |
-
'title'
|
319 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
320 |
-
'args'
|
321 |
-
'key'
|
322 |
-
'value' => $options[
|
323 |
'class' => array( 'rtmedia-setting-text-box' ),
|
324 |
-
'desc'
|
325 |
-
'min'
|
326 |
),
|
327 |
-
'group'
|
328 |
),
|
329 |
-
'general_display_media'
|
330 |
-
'title'
|
331 |
'callback' => array( 'RTMediaFormHandler', 'radio' ),
|
332 |
-
'args'
|
333 |
-
'key'
|
334 |
-
'radios'
|
335 |
-
'default' => $options[
|
336 |
-
'desc'
|
337 |
-
'class'
|
338 |
),
|
339 |
-
'group'
|
340 |
-
),
|
341 |
-
|
342 |
-
'
|
343 |
-
'
|
344 |
-
|
345 |
-
'
|
346 |
-
'
|
|
|
347 |
'class' => array( 'rtm_enable_masonry_view' ),
|
348 |
),
|
349 |
-
'group'
|
350 |
-
'after_content' =>
|
351 |
),
|
352 |
-
|
353 |
-
'title'
|
354 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
355 |
-
'args'
|
356 |
-
'key'
|
357 |
-
'value' => $options[
|
358 |
-
'desc'
|
359 |
),
|
360 |
-
'group'
|
361 |
),
|
362 |
);
|
363 |
|
@@ -375,17 +369,15 @@ class RTMediaFormHandler {
|
|
375 |
*/
|
376 |
public static function display_content() {
|
377 |
global $rtmedia;
|
378 |
-
|
379 |
-
$options = $rtmedia->options;
|
380 |
$render_options = self::display_render_options( $options );
|
381 |
-
|
382 |
-
$
|
383 |
-
$general_group
|
384 |
-
$general_group[
|
385 |
-
$general_group[
|
386 |
-
$general_group[
|
387 |
-
|
388 |
-
$general_group = apply_filters( 'rtmedia_display_content_groups', $general_group );
|
389 |
ksort( $general_group );
|
390 |
self::render_tab_content( $render_options, $general_group, 20 );
|
391 |
}
|
@@ -402,56 +394,56 @@ class RTMediaFormHandler {
|
|
402 |
static function render_general_content( $options ) {
|
403 |
$render = array(
|
404 |
'general_AllowUserData' => array(
|
405 |
-
'title'
|
406 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
407 |
-
'args'
|
408 |
-
'key'
|
409 |
-
'value' => $options[
|
410 |
-
'desc'
|
411 |
-
)
|
412 |
),
|
413 |
'general_showAdminMenu' => array(
|
414 |
-
'title'
|
415 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
416 |
-
'args'
|
417 |
-
'key'
|
418 |
-
'value' => $options[
|
419 |
-
'desc'
|
420 |
),
|
421 |
-
'group'
|
422 |
), //
|
423 |
-
'rtmedia_add_linkback'
|
424 |
-
'title'
|
425 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
426 |
-
'args'
|
427 |
-
'key'
|
428 |
-
'value' => $options[
|
429 |
-
'desc'
|
430 |
),
|
431 |
-
'group'
|
432 |
), //
|
433 |
-
'rtmedia_affiliate_id'
|
434 |
-
'title'
|
435 |
-
'callback'
|
436 |
-
'args'
|
437 |
-
'key'
|
438 |
-
'value' => $options[
|
439 |
-
'desc'
|
440 |
),
|
441 |
-
'group'
|
442 |
-
'depends'
|
443 |
-
'after_content' =>
|
444 |
), //
|
445 |
-
'rtmedia_enable_api'
|
446 |
-
'title'
|
447 |
-
'callback'
|
448 |
-
'args'
|
449 |
-
'key'
|
450 |
-
'value' => $options[
|
451 |
-
'desc'
|
452 |
),
|
453 |
-
'group'
|
454 |
-
'after_content' =>
|
455 |
), //
|
456 |
);
|
457 |
|
@@ -463,24 +455,20 @@ class RTMediaFormHandler {
|
|
463 |
*
|
464 |
* @access static
|
465 |
*
|
466 |
-
* @param array $options
|
467 |
-
*
|
468 |
* @return void
|
469 |
*/
|
470 |
-
static function general_content(
|
471 |
global $rtmedia;
|
472 |
-
|
473 |
-
$
|
474 |
-
$render_options
|
475 |
-
$
|
476 |
-
$general_group
|
477 |
-
$general_group[
|
478 |
-
$general_group[
|
479 |
-
$general_group[
|
480 |
-
$general_group
|
481 |
-
$general_group = apply_filters( 'rtmedia_general_content_groups', $general_group );
|
482 |
ksort( $general_group );
|
483 |
-
$html = '';
|
484 |
self::render_tab_content( $render_options, $general_group, 90 );
|
485 |
}
|
486 |
|
@@ -489,25 +477,26 @@ class RTMediaFormHandler {
|
|
489 |
*
|
490 |
* @access static
|
491 |
*
|
492 |
-
* @param array
|
493 |
* @param string $key
|
494 |
*
|
495 |
* @return array $data
|
496 |
*/
|
497 |
static function get_type_details( $allowed_types, $key ) {
|
498 |
foreach ( $allowed_types as $type ) {
|
499 |
-
if ( $type[
|
500 |
$data = array(
|
501 |
-
'name' => $type[
|
502 |
-
'extn' => $type[
|
503 |
);
|
504 |
-
if ( isset( $type[
|
505 |
-
$data[
|
506 |
}
|
507 |
|
508 |
return $data;
|
509 |
}
|
510 |
}
|
|
|
511 |
}
|
512 |
|
513 |
/**
|
@@ -520,19 +509,19 @@ class RTMediaFormHandler {
|
|
520 |
* @return array $render
|
521 |
*/
|
522 |
static function types_render_options( $options ) {
|
523 |
-
$render
|
524 |
$allowed_media_type = rtmedia_get_allowed_types();
|
525 |
|
526 |
foreach ( $options as $key => $value ) {
|
527 |
$data = explode( '_', $key );
|
528 |
-
if ( ! isset( $render[ $data[
|
529 |
-
$render[ $data[
|
530 |
}
|
531 |
}
|
532 |
|
533 |
foreach ( $options as $key => $value ) {
|
534 |
-
$data
|
535 |
-
$render[ $data[
|
536 |
}
|
537 |
|
538 |
return $render;
|
@@ -557,7 +546,7 @@ class RTMediaFormHandler {
|
|
557 |
<?php do_action( 'rtmedia_media_type_setting_message' ); ?>
|
558 |
|
559 |
<h3 class="rtm-option-title">
|
560 |
-
<?php
|
561 |
</h3>
|
562 |
|
563 |
<table class="form-table">
|
@@ -565,14 +554,14 @@ class RTMediaFormHandler {
|
|
565 |
<?php do_action( 'rtmedia_type_settings_before_heading' ); ?>
|
566 |
|
567 |
<tr>
|
568 |
-
<th><strong><?php
|
569 |
|
570 |
<th>
|
571 |
|
572 |
<span class="rtm-tooltip bottom">
|
573 |
-
<strong class="rtm-title"><?php
|
574 |
<span class="rtm-tip-top">
|
575 |
-
<?php
|
576 |
</span>
|
577 |
</span>
|
578 |
</th>
|
@@ -580,9 +569,9 @@ class RTMediaFormHandler {
|
|
580 |
<th>
|
581 |
|
582 |
<span class="rtm-tooltip bottom">
|
583 |
-
<strong class="rtm-title"><?php
|
584 |
<span class="rtm-tip-top">
|
585 |
-
<?php
|
586 |
</span>
|
587 |
</span>
|
588 |
</th>
|
@@ -594,39 +583,45 @@ class RTMediaFormHandler {
|
|
594 |
do_action( 'rtmedia_type_settings_after_heading' );
|
595 |
|
596 |
foreach ( $render_data as $key => $section ) {
|
597 |
-
if ( isset( $section[
|
598 |
do_action( 'rtmedia_type_settings_before_body' );
|
599 |
|
600 |
// allow upload
|
601 |
-
$uplaod_args
|
|
|
|
|
|
|
602 |
$allow_upload_checkbox = self::checkbox( $uplaod_args, $echo = false );
|
603 |
$allow_upload_checkbox = apply_filters( 'rtmedia_filter_allow_upload_checkbox', $allow_upload_checkbox, $key, $uplaod_args );
|
604 |
|
605 |
// allow featured
|
606 |
-
$featured_args
|
|
|
|
|
|
|
607 |
$featured_checkbox = self::checkbox( $featured_args, $echo = false );
|
608 |
$featured_checkbox = apply_filters( 'rtmedia_filter_featured_checkbox', $featured_checkbox, $key );
|
609 |
|
610 |
-
if ( ! isset( $section[
|
611 |
-
$section[
|
612 |
}
|
613 |
|
614 |
-
$extensions = implode( ', ', $section[
|
615 |
?>
|
616 |
|
617 |
<tr>
|
618 |
<td>
|
619 |
<?php
|
620 |
-
echo $section[
|
621 |
|
622 |
-
if (
|
623 |
?>
|
624 |
<span class="rtm-tooltip rtm-extensions">
|
625 |
<i class="dashicons dashicons-info rtmicon"></i>
|
626 |
<span class="rtm-tip">
|
627 |
-
<strong><?php echo
|
628 |
-
<hr
|
629 |
-
<?php echo $extensions; ?>
|
630 |
</span>
|
631 |
</span>
|
632 |
<?php
|
@@ -636,11 +631,54 @@ class RTMediaFormHandler {
|
|
636 |
|
637 |
<td>
|
638 |
<span class="rtm-field-wrap">
|
639 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
640 |
</td>
|
641 |
|
642 |
<td>
|
643 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
644 |
</td>
|
645 |
|
646 |
<?php do_action( 'rtmedia_type_setting_columns_body', $key, $section ) ?>
|
@@ -653,8 +691,8 @@ class RTMediaFormHandler {
|
|
653 |
} else {
|
654 |
echo '<tr class="hide">';
|
655 |
echo '<td colspan="3">';
|
656 |
-
echo "<input type='hidden' value='1' name='rtmedia-options[allowedTypes_" . $key . "_enabled]'>";
|
657 |
-
echo "<input type='hidden' value='0' name='rtmedia-options[allowedTypes_" . $key . "_featured]'>";
|
658 |
echo '</td>';
|
659 |
echo '</tr>';
|
660 |
}
|
@@ -680,16 +718,16 @@ class RTMediaFormHandler {
|
|
680 |
$render = array();
|
681 |
foreach ( $options as $key => $value ) {
|
682 |
$data = explode( '_', $key );
|
683 |
-
if ( ! isset( $render[ $data[
|
684 |
-
$render[ $data[
|
685 |
-
$render[ $data[
|
686 |
}
|
687 |
-
if ( ! isset( $render[ $data[
|
688 |
-
$render[ $data[
|
689 |
-
$render[ $data[
|
690 |
}
|
691 |
|
692 |
-
$render[ $data[
|
693 |
}
|
694 |
|
695 |
return $render;
|
@@ -706,51 +744,51 @@ class RTMediaFormHandler {
|
|
706 |
*/
|
707 |
public static function sizes_content() {
|
708 |
global $rtmedia;
|
709 |
-
$options
|
710 |
$render_data = self::sizes_render_options( $options );
|
711 |
?>
|
712 |
|
713 |
<div class="rtm-option-wrapper rtm-img-size-setting">
|
714 |
<h3 class="rtm-option-title">
|
715 |
-
<?php
|
716 |
</h3>
|
717 |
|
718 |
<table class="form-table">
|
719 |
<tr>
|
720 |
-
<th><strong><?php
|
721 |
-
<th><strong><?php
|
722 |
-
<th><strong><?php
|
723 |
-
<th><strong><?php
|
724 |
-
<th><strong><?php
|
725 |
</tr>
|
726 |
|
727 |
<?php
|
728 |
foreach ( $render_data as $parent_key => $section ) {
|
729 |
$entities = $section;
|
730 |
-
unset( $entities[
|
731 |
-
$count
|
732 |
-
$row_span =
|
733 |
foreach ( $entities as $entity ) {
|
734 |
?>
|
735 |
<tr>
|
736 |
<?php
|
737 |
-
if ( $count
|
738 |
?>
|
739 |
-
<td class="rtm-row-title" rowspan="<?php echo $row_span; ?>">
|
740 |
-
<?php echo ucfirst( $section[
|
741 |
</td>
|
742 |
<?php
|
743 |
}
|
744 |
?>
|
745 |
<td>
|
746 |
-
<?php echo ucfirst( $entity[
|
747 |
</td>
|
748 |
<?php
|
749 |
$args = array(
|
750 |
-
'key' => 'defaultSizes_' . $parent_key . '_' . $entity[
|
751 |
);
|
752 |
foreach ( $entity as $child_key => $value ) {
|
753 |
-
if ( 'title'
|
754 |
$args[ $child_key ] = $value;
|
755 |
}
|
756 |
}
|
@@ -768,48 +806,48 @@ class RTMediaFormHandler {
|
|
768 |
|
769 |
<?php
|
770 |
$options = $rtmedia->options;
|
771 |
-
|
772 |
// Checking if user has subscribed any plan for encoding
|
773 |
$rtmedia_encoding_api_key = get_rtmedia_encoding_api_key();
|
774 |
|
775 |
-
if ( isset( $rtmedia_encoding_api_key ) && $rtmedia_encoding_api_key
|
776 |
$render_video_thumb = array(
|
777 |
-
'title'
|
778 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
779 |
-
'args'
|
780 |
-
'key'
|
781 |
-
'value' => $options[
|
782 |
'class' => array( 'rtmedia-setting-text-box' ),
|
783 |
-
'desc'
|
784 |
-
'min'
|
785 |
-
'max'
|
786 |
-
)
|
787 |
);
|
788 |
?>
|
789 |
|
790 |
<div class="rtm-option-wrapper">
|
791 |
-
<?php self::render_option_group(
|
792 |
-
|
793 |
</div>
|
794 |
<?php
|
795 |
}
|
796 |
|
797 |
$render_jpeg_image_quality = array(
|
798 |
-
'title'
|
799 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
800 |
-
'args'
|
801 |
-
'key'
|
802 |
-
'value' => $options[
|
803 |
'class' => array( 'rtmedia-setting-text-box' ),
|
804 |
-
'desc'
|
805 |
-
'min'
|
806 |
-
'max'
|
807 |
-
)
|
808 |
);
|
809 |
?>
|
810 |
|
811 |
<div class="rtm-option-wrapper">
|
812 |
-
<?php self::render_option_group(
|
813 |
<?php self::render_option_content( $render_jpeg_image_quality ); ?>
|
814 |
</div>
|
815 |
|
@@ -827,11 +865,11 @@ class RTMediaFormHandler {
|
|
827 |
*/
|
828 |
public static function custom_css_content() {
|
829 |
global $rtmedia;
|
830 |
-
$options
|
831 |
$render_data = self::custom_css_render_options( $options );
|
832 |
|
833 |
-
$render_groups
|
834 |
-
$render_groups[
|
835 |
|
836 |
self::render_tab_content( $render_data, $render_groups, 10 );
|
837 |
}
|
@@ -846,30 +884,28 @@ class RTMediaFormHandler {
|
|
846 |
* @return array $render
|
847 |
*/
|
848 |
static function custom_css_render_options( $options ) {
|
849 |
-
global $rtmedia;
|
850 |
-
|
851 |
$render = array(
|
852 |
'disable_styles' => array(
|
853 |
-
'title'
|
854 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
855 |
-
'args'
|
856 |
-
'id'
|
857 |
-
'key'
|
858 |
-
'value' => $options[
|
859 |
-
'desc'
|
860 |
),
|
861 |
-
'group'
|
862 |
),
|
863 |
-
'custom_styles'
|
864 |
-
'title'
|
865 |
'callback' => array( 'RTMediaFormHandler', 'textarea' ),
|
866 |
-
'args'
|
867 |
-
'id'
|
868 |
-
'key'
|
869 |
-
'value' => stripcslashes( $options[
|
870 |
-
'desc'
|
871 |
),
|
872 |
-
'group'
|
873 |
),
|
874 |
);
|
875 |
|
@@ -889,40 +925,40 @@ class RTMediaFormHandler {
|
|
889 |
global $rtmedia;
|
890 |
|
891 |
$render = array(
|
892 |
-
'enable'
|
893 |
-
'title'
|
894 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
895 |
-
'args'
|
896 |
-
'id'
|
897 |
-
'key'
|
898 |
-
'value' => $options[
|
899 |
-
'desc'
|
900 |
),
|
901 |
-
'group'
|
902 |
),
|
903 |
-
'default'
|
904 |
-
'title'
|
905 |
'callback' => array( 'RTMediaFormHandler', 'radio' ),
|
906 |
-
'args'
|
907 |
-
'key'
|
908 |
-
'radios'
|
909 |
-
'default' => $options[
|
910 |
-
'desc'
|
911 |
),
|
912 |
-
'group'
|
913 |
-
'depends'
|
914 |
),
|
915 |
'user_override' => array(
|
916 |
-
'title'
|
917 |
-
'callback'
|
918 |
-
'args'
|
919 |
-
'key'
|
920 |
-
'value' => $options[
|
921 |
-
'desc'
|
922 |
),
|
923 |
-
'group'
|
924 |
-
'depends'
|
925 |
-
'after_content' =>
|
926 |
),
|
927 |
);
|
928 |
|
@@ -941,11 +977,11 @@ class RTMediaFormHandler {
|
|
941 |
public static function privacy_content() {
|
942 |
global $rtmedia;
|
943 |
|
944 |
-
$general_group
|
945 |
-
$general_group[
|
946 |
-
$general_group
|
947 |
|
948 |
-
$options
|
949 |
$render_options = self::privacy_render_options( $options );
|
950 |
$render_options = apply_filters( 'rtmedia_privacy_settings_options', $render_options );
|
951 |
|
@@ -963,92 +999,92 @@ class RTMediaFormHandler {
|
|
963 |
*/
|
964 |
static function buddypress_render_options( $options ) {
|
965 |
$render = array(
|
966 |
-
'rtmedia-enable-on-profile'
|
967 |
-
'title'
|
968 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
969 |
-
'args'
|
970 |
-
'key'
|
971 |
-
'value' => $options[
|
972 |
-
'desc'
|
973 |
),
|
974 |
-
'group'
|
975 |
),
|
976 |
-
'rtmedia-enable-on-group'
|
977 |
-
'title'
|
978 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
979 |
-
'args'
|
980 |
-
'key'
|
981 |
-
'value' => $options[
|
982 |
-
'desc'
|
983 |
),
|
984 |
-
'group'
|
985 |
),
|
986 |
-
'rtmedia-enable-on-activity'
|
987 |
-
'title'
|
988 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
989 |
-
'args'
|
990 |
-
'key'
|
991 |
-
'value' => $options[
|
992 |
-
'desc'
|
993 |
-
'id'
|
994 |
),
|
995 |
-
'group'
|
996 |
),
|
997 |
-
'rtmedia-activity-feed-limit'
|
998 |
-
'title'
|
999 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
1000 |
-
'args'
|
1001 |
-
'key'
|
1002 |
-
'value' => $options[
|
1003 |
-
'desc'
|
1004 |
'class' => array( 'rtmedia-setting-text-box rtmedia-bp-activity-setting' ),
|
1005 |
-
'min'
|
1006 |
),
|
1007 |
-
'group'
|
1008 |
),
|
1009 |
-
|
1010 |
-
'title'
|
1011 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1012 |
-
'args'
|
1013 |
-
'key'
|
1014 |
-
'value' => $options[
|
1015 |
-
'desc'
|
1016 |
-
|
1017 |
),
|
1018 |
-
'group'
|
1019 |
),
|
1020 |
-
'rtmedia-enable-like-activity'
|
1021 |
-
'title'
|
1022 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1023 |
-
'args'
|
1024 |
-
'key'
|
1025 |
-
'value' => $options[
|
1026 |
-
'desc'
|
1027 |
|
1028 |
),
|
1029 |
-
'group'
|
1030 |
),
|
1031 |
'rtmedia-enable-comment-activity' => array(
|
1032 |
-
'title'
|
1033 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1034 |
-
'args'
|
1035 |
-
'key'
|
1036 |
-
'value' => $options[
|
1037 |
-
'desc'
|
1038 |
|
1039 |
),
|
1040 |
-
'group'
|
1041 |
),
|
1042 |
-
'general_enableAlbums'
|
1043 |
-
'title'
|
1044 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1045 |
-
'args'
|
1046 |
-
'id'
|
1047 |
-
'key'
|
1048 |
-
'value' => $options[
|
1049 |
-
'desc'
|
1050 |
),
|
1051 |
-
'group'
|
1052 |
),
|
1053 |
);
|
1054 |
|
@@ -1067,10 +1103,10 @@ class RTMediaFormHandler {
|
|
1067 |
public static function buddypress_content() {
|
1068 |
global $rtmedia;
|
1069 |
|
1070 |
-
$general_group
|
1071 |
-
$general_group[
|
1072 |
-
$general_group[
|
1073 |
-
$general_group
|
1074 |
|
1075 |
$render_options = self::buddypress_render_options( $rtmedia->options );
|
1076 |
$render_options = apply_filters( 'rtmedia_album_control_setting', $render_options, $rtmedia->options );
|
@@ -1087,7 +1123,7 @@ class RTMediaFormHandler {
|
|
1087 |
*
|
1088 |
* @access static
|
1089 |
*
|
1090 |
-
* @param
|
1091 |
* @param array $sub_tabs
|
1092 |
*
|
1093 |
* @return void
|
@@ -1106,8 +1142,8 @@ class RTMediaFormHandler {
|
|
1106 |
*
|
1107 |
* @access static
|
1108 |
*
|
1109 |
-
* @param
|
1110 |
-
* @param
|
1111 |
*
|
1112 |
* @return void
|
1113 |
*/
|
@@ -1118,17 +1154,17 @@ class RTMediaFormHandler {
|
|
1118 |
return;
|
1119 |
}
|
1120 |
|
1121 |
-
foreach ( (
|
1122 |
echo '<div class="row">';
|
1123 |
echo '<div class="large-11 columns">';
|
1124 |
|
1125 |
-
if ( isset( $field[
|
1126 |
-
call_user_func( $field[
|
1127 |
} else {
|
1128 |
-
if ( isset( $field[
|
1129 |
-
call_user_func( $field[
|
1130 |
} else {
|
1131 |
-
call_user_func( $field[
|
1132 |
}
|
1133 |
}
|
1134 |
echo '</div>';
|
@@ -1152,12 +1188,11 @@ class RTMediaFormHandler {
|
|
1152 |
<?php
|
1153 |
self::render_option_group( $value );
|
1154 |
foreach ( $options as $tab => $option ) {
|
1155 |
-
|
1156 |
-
|
1157 |
-
$option[ 'group' ] = $default_group;
|
1158 |
}
|
1159 |
|
1160 |
-
if ( $option[
|
1161 |
continue;
|
1162 |
}
|
1163 |
self::render_option_content( $option );
|
@@ -1187,7 +1222,7 @@ class RTMediaFormHandler {
|
|
1187 |
|
1188 |
public static function render_option_group( $group ) {
|
1189 |
?>
|
1190 |
-
<h3 class="rtm-option-title"><?php echo $group; ?></h3>
|
1191 |
<?php
|
1192 |
}
|
1193 |
|
@@ -1200,23 +1235,34 @@ class RTMediaFormHandler {
|
|
1200 |
?>
|
1201 |
|
1202 |
<table class="form-table" <?php
|
1203 |
-
if ( isset( $option[
|
1204 |
-
echo 'data-depends="' . $option[
|
1205 |
}
|
1206 |
?>>
|
1207 |
<tr>
|
1208 |
<th>
|
1209 |
-
<?php echo $option[
|
1210 |
-
|
1211 |
-
|
|
|
|
|
|
|
|
|
1212 |
</th>
|
1213 |
<td>
|
1214 |
<fieldset>
|
1215 |
-
<span
|
|
|
1216 |
<span class="rtm-tooltip">
|
1217 |
<i class="dashicons dashicons-info rtmicon"></i>
|
1218 |
<span class="rtm-tip">
|
1219 |
-
<?php echo ( isset( $option[
|
|
|
|
|
|
|
|
|
|
|
|
|
1220 |
</span>
|
1221 |
</span>
|
1222 |
</fieldset>
|
@@ -1225,10 +1271,16 @@ class RTMediaFormHandler {
|
|
1225 |
</table>
|
1226 |
|
1227 |
<?php
|
1228 |
-
if ( isset( $option[
|
1229 |
?>
|
1230 |
-
<div class="rtm-message rtm-notice"><?php echo wpautop( $option[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1231 |
}
|
1232 |
}
|
1233 |
-
|
1234 |
-
}
|
12 |
class RTMediaFormHandler {
|
13 |
|
14 |
public static function selectBox( $args ) {
|
|
|
|
|
15 |
$defaults = array(
|
16 |
+
'key' => '',
|
17 |
+
'desc' => '',
|
18 |
+
'default' => '',
|
19 |
'show_desc' => false,
|
20 |
+
'selects' => array(),
|
21 |
);
|
22 |
+
$args = wp_parse_args( $args, $defaults );
|
23 |
extract( $args );
|
24 |
|
25 |
if ( ! empty( $key ) ) {
|
26 |
+
$args['name'] = 'rtmedia-options[' . $key . ']';
|
27 |
}
|
28 |
|
29 |
+
$args['rtForm_options'] = array();
|
30 |
foreach ( $selects as $value => $key ) {
|
31 |
+
$args['rtForm_options'][] = array(
|
32 |
+
$key => $value,
|
33 |
'selected' => ( $default == $value ) ? true : false,
|
34 |
);
|
35 |
}
|
36 |
|
37 |
$chkObj = new rtForm();
|
38 |
+
$chkObj->display_select( $args );
|
39 |
}
|
40 |
|
41 |
/**
|
44 |
* @access static
|
45 |
*
|
46 |
* @param array $args
|
47 |
+
* @param bool $echo
|
48 |
*
|
49 |
* @return string $chkObj->get_textarea( $args )
|
50 |
*/
|
51 |
public static function textarea( $args, $echo = true ) {
|
|
|
|
|
52 |
$defaults = array(
|
53 |
+
'key' => '',
|
54 |
+
'desc' => '',
|
55 |
'show_desc' => false,
|
56 |
);
|
57 |
+
$args = wp_parse_args( $args, $defaults );
|
58 |
extract( $args );
|
59 |
|
60 |
if ( ! isset( $value ) ) {
|
61 |
+
trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) );
|
62 |
|
63 |
return;
|
64 |
}
|
65 |
|
66 |
if ( ! empty( $key ) ) {
|
67 |
+
$args['name'] = 'rtmedia-options[' . $key . ']';
|
68 |
}
|
69 |
|
70 |
+
$args['rtForm_options'] = array( array( '' => 1, 'checked' => $value ) );
|
71 |
|
72 |
$chkObj = new rtForm();
|
73 |
|
74 |
if ( $echo ) {
|
75 |
+
$chkObj->display_textarea( $args );
|
76 |
} else {
|
77 |
+
return $chkObj->get_textarea( $args ); // @codingStandardsIgnoreLine
|
78 |
}
|
79 |
+
return;
|
80 |
}
|
81 |
|
82 |
/**
|
85 |
* @access static
|
86 |
*
|
87 |
* @param array $args
|
88 |
+
* @param bool $echo
|
89 |
*
|
90 |
* @return string $chkObj->get_switch( $args )
|
91 |
*/
|
92 |
public static function checkbox( $args, $echo = true ) {
|
|
|
|
|
93 |
$defaults = array(
|
94 |
+
'key' => '',
|
95 |
+
'desc' => '',
|
96 |
'show_desc' => false,
|
97 |
);
|
98 |
+
$args = wp_parse_args( $args, $defaults );
|
99 |
extract( $args );
|
100 |
|
101 |
if ( ! isset( $value ) ) {
|
102 |
+
trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) );
|
103 |
|
104 |
return;
|
105 |
}
|
106 |
|
107 |
if ( ! empty( $key ) ) {
|
108 |
+
$args['name'] = 'rtmedia-options[' . $key . ']';
|
109 |
}
|
110 |
|
111 |
+
$args['rtForm_options'] = array( array( '' => 1, 'checked' => $value ) );
|
112 |
|
113 |
$chkObj = new rtForm();
|
114 |
+
|
115 |
if ( $echo ) {
|
116 |
+
$chkObj->display_switch( $args );
|
117 |
} else {
|
118 |
return $chkObj->get_switch( $args );
|
119 |
}
|
120 |
+
return;
|
121 |
}
|
122 |
|
123 |
/**
|
130 |
* @return void
|
131 |
*/
|
132 |
public static function radio( $args ) {
|
|
|
|
|
133 |
$defaults = array(
|
134 |
+
'key' => '',
|
135 |
+
'radios' => array(),
|
136 |
+
'default' => '',
|
137 |
'show_desc' => false,
|
138 |
);
|
139 |
+
$args = wp_parse_args( $args, $defaults );
|
140 |
extract( $args );
|
141 |
|
142 |
if ( 2 > count( $radios ) ) {
|
143 |
+
trigger_error( esc_html__( 'Need to specify atleast two radios, else use a checkbox instead', 'buddypress-media' ) );
|
144 |
|
145 |
return;
|
146 |
}
|
147 |
|
148 |
if ( ! empty( $key ) ) {
|
149 |
+
$args['name'] = 'rtmedia-options[' . $key . ']';
|
150 |
}
|
151 |
|
152 |
+
$args['rtForm_options'] = array();
|
153 |
foreach ( $radios as $value => $key ) {
|
154 |
+
$args['rtForm_options'][] = array(
|
155 |
+
$key => $value,
|
156 |
'checked' => ( $default == $value ) ? true : false,
|
157 |
);
|
158 |
}
|
159 |
|
160 |
$objRad = new rtForm();
|
161 |
+
$objRad->display_radio( $args );
|
162 |
}
|
163 |
|
164 |
/**
|
169 |
*/
|
170 |
public static function dimensions( $args ) {
|
171 |
$dmnObj = new rtDimensions();
|
172 |
+
$dmnObj->display_dimensions( $args );
|
173 |
}
|
174 |
|
175 |
/**
|
183 |
*/
|
184 |
public static function number( $args ) {
|
185 |
global $rtmedia;
|
186 |
+
$options = $rtmedia->options;
|
187 |
$defaults = array(
|
188 |
+
'key' => '',
|
189 |
'desc' => '',
|
190 |
);
|
191 |
+
$args = wp_parse_args( $args, $defaults );
|
192 |
extract( $args );
|
193 |
|
194 |
if ( ! isset( $value ) ) {
|
195 |
+
trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) );
|
196 |
|
197 |
return;
|
198 |
}
|
199 |
|
200 |
if ( ! empty( $key ) ) {
|
201 |
+
$args['name'] = 'rtmedia-options[' . $key . ']';
|
202 |
}
|
203 |
|
204 |
+
$args['value'] = $value;
|
205 |
|
206 |
$numObj = new rtForm();
|
207 |
+
$numObj->display_number( $args );
|
208 |
}
|
209 |
|
210 |
/**
|
218 |
*/
|
219 |
public static function textbox( $args ) {
|
220 |
global $rtmedia;
|
221 |
+
$options = $rtmedia->options;
|
222 |
$defaults = array(
|
223 |
+
'key' => '',
|
224 |
'desc' => '',
|
225 |
);
|
226 |
+
$args = wp_parse_args( $args, $defaults );
|
227 |
extract( $args );
|
228 |
|
229 |
if ( ! isset( $value ) ) {
|
230 |
+
trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) );
|
231 |
|
232 |
return;
|
233 |
}
|
234 |
|
235 |
if ( ! empty( $key ) ) {
|
236 |
+
$args['name'] = 'rtmedia-options[' . $key . ']';
|
237 |
}
|
238 |
|
239 |
+
$args['value'] = $value;
|
240 |
|
241 |
$numObj = new rtForm();
|
242 |
+
$numObj->display_textbox( $args );
|
243 |
}
|
244 |
|
245 |
/**
|
247 |
*
|
248 |
* @access static
|
249 |
*
|
250 |
+
* @param array $options
|
251 |
* @param string $section_name
|
252 |
*
|
253 |
* @return array $section
|
256 |
$section = array();
|
257 |
foreach ( $options as $key => $value ) {
|
258 |
$compare = strncmp( $key, $section_name, strlen( $section_name ) );
|
259 |
+
if ( 0 === $compare ) {
|
260 |
$section[ $key ] = $value;
|
261 |
}
|
262 |
}
|
273 |
*
|
274 |
* @return array $render
|
275 |
*/
|
276 |
+
static function display_render_options( $options ) {
|
277 |
+
$radios = array();
|
278 |
+
$radios['load_more'] = '<strong>' . esc_html__( 'Load More', 'buddypress-media' ) . '</strong>';
|
279 |
+
$radios['pagination'] = '<strong>' . esc_html__( 'Pagination', 'buddypress-media' ) . '</strong>';
|
280 |
|
281 |
if ( is_plugin_active( 'regenerate-thumbnails/regenerate-thumbnails.php' ) ) {
|
282 |
$regenerate_link = admin_url( '/tools.php?page=regenerate-thumbnails' );
|
288 |
|
289 |
$render = array(
|
290 |
'general_enableComments' => array(
|
291 |
+
'title' => esc_html__( 'Allow user to comment on uploaded media', 'buddypress-media' ),
|
292 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
293 |
+
'args' => array(
|
294 |
+
'key' => 'general_enableComments',
|
295 |
+
'value' => $options['general_enableComments'],
|
296 |
+
'desc' => esc_html__( 'This will display the comment form and comment listing on single media pages as well as inside lightbox (if lightbox is enabled).', 'buddypress-media' ),
|
297 |
),
|
298 |
+
'group' => '10',
|
299 |
),
|
300 |
'general_enableLightbox' => array(
|
301 |
+
'title' => esc_html__( 'Use lightbox to display media', 'buddypress-media' ),
|
302 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
303 |
+
'args' => array(
|
304 |
+
'key' => 'general_enableLightbox',
|
305 |
+
'value' => $options['general_enableLightbox'],
|
306 |
+
'desc' => esc_html__( 'View single media in facebook style lightbox.', 'buddypress-media' ),
|
307 |
),
|
308 |
+
'group' => '15',
|
309 |
),
|
310 |
+
'general_perPageMedia' => array(
|
311 |
+
'title' => esc_html__( 'Number of media per page', 'buddypress-media' ),
|
312 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
313 |
+
'args' => array(
|
314 |
+
'key' => 'general_perPageMedia',
|
315 |
+
'value' => $options['general_perPageMedia'],
|
316 |
'class' => array( 'rtmedia-setting-text-box' ),
|
317 |
+
'desc' => esc_html__( 'Number of media items you want to show per page on front end.', 'buddypress-media' ),
|
318 |
+
'min' => 1,
|
319 |
),
|
320 |
+
'group' => '15',
|
321 |
),
|
322 |
+
'general_display_media' => array(
|
323 |
+
'title' => esc_html__( 'Media display pagination option', 'buddypress-media' ),
|
324 |
'callback' => array( 'RTMediaFormHandler', 'radio' ),
|
325 |
+
'args' => array(
|
326 |
+
'key' => 'general_display_media',
|
327 |
+
'radios' => $radios,
|
328 |
+
'default' => $options['general_display_media'],
|
329 |
+
'desc' => esc_html__( 'Choose whether you want the load more button or pagination buttons.', 'buddypress-media' ),
|
330 |
+
'class' => array( 'rtmedia-load-more-radio' ),
|
331 |
),
|
332 |
+
'group' => '15',
|
333 |
+
),
|
334 |
+
'general_masonry_layout' => array(
|
335 |
+
'title' => esc_html__( 'Enable', 'buddypress-media' ) . ' <a href="http://masonry.desandro.com/" target="_blank">Masonry</a> ' . esc_html__( 'Cascading grid layout', 'buddypress-media' ),
|
336 |
+
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
337 |
+
'args' => array(
|
338 |
+
'key' => 'general_masonry_layout',
|
339 |
+
'value' => $options['general_masonry_layout'],
|
340 |
+
'desc' => esc_html__( 'If you enable masonry view, it is advisable to', 'buddypress-media' ) . ' <a href="' . $regenerate_link . '">regenerate thumbnail</a> ' . esc_html__( 'for masonry view.', 'buddypress-media' ),
|
341 |
'class' => array( 'rtm_enable_masonry_view' ),
|
342 |
),
|
343 |
+
'group' => '18',
|
344 |
+
'after_content' => esc_html__( 'You might need to', 'buddypress-media' ) . ' <a id="rtm-masonry-change-thumbnail-info" href="' . get_admin_url() . 'admin.php?page=rtmedia-settings#rtmedia-sizes">' . esc_html__( 'change thumbnail size', 'buddypress-media' ) . '</a> ' . esc_html__( 'and uncheck the crop box for thumbnails.', 'buddypress-media' ) . '<br /><br />' . esc_html__( 'To set gallery for fixed width, set image height to 0 and width as per your requirement and vice-versa.', 'buddypress-media' ),
|
345 |
),
|
346 |
+
'general_direct_upload' => array(
|
347 |
+
'title' => esc_html__( 'Enable Direct Upload', 'buddypress-media' ),
|
348 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
349 |
+
'args' => array(
|
350 |
+
'key' => 'general_direct_upload',
|
351 |
+
'value' => $options['general_direct_upload'],
|
352 |
+
'desc' => esc_html__( 'Uploading media directly as soon as it gets selected.', 'buddypress-media' ),
|
353 |
),
|
354 |
+
'group' => '19',
|
355 |
),
|
356 |
);
|
357 |
|
369 |
*/
|
370 |
public static function display_content() {
|
371 |
global $rtmedia;
|
372 |
+
$options = $rtmedia->options;
|
|
|
373 |
$render_options = self::display_render_options( $options );
|
374 |
+
$render_options = apply_filters( 'rtmedia_display_content_add_itmes', $render_options, $options );
|
375 |
+
$general_group = array();
|
376 |
+
$general_group[10] = esc_html__( 'Single Media View', 'buddypress-media' );
|
377 |
+
$general_group[15] = esc_html__( 'List Media View', 'buddypress-media' );
|
378 |
+
$general_group[18] = esc_html__( 'Masonry View', 'buddypress-media' );
|
379 |
+
$general_group[19] = esc_html__( 'Direct Upload', 'buddypress-media' );
|
380 |
+
$general_group = apply_filters( 'rtmedia_display_content_groups', $general_group );
|
|
|
381 |
ksort( $general_group );
|
382 |
self::render_tab_content( $render_options, $general_group, 20 );
|
383 |
}
|
394 |
static function render_general_content( $options ) {
|
395 |
$render = array(
|
396 |
'general_AllowUserData' => array(
|
397 |
+
'title' => esc_html__( 'Allow usage data tracking', 'buddypress-media' ),
|
398 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
399 |
+
'args' => array(
|
400 |
+
'key' => 'general_AllowUserData',
|
401 |
+
'value' => $options['general_AllowUserData'],
|
402 |
+
'desc' => esc_html__( 'To make rtMedia better compatible with your sites, you can help the rtMedia team learn what themes and plugins you are using. No private information about your setup will be sent during tracking.', 'buddypress-media' ),
|
403 |
+
),
|
404 |
),
|
405 |
'general_showAdminMenu' => array(
|
406 |
+
'title' => esc_html__( 'Admin bar menu integration', 'buddypress-media' ),
|
407 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
408 |
+
'args' => array(
|
409 |
+
'key' => 'general_showAdminMenu',
|
410 |
+
'value' => $options['general_showAdminMenu'],
|
411 |
+
'desc' => esc_html__( 'Add rtMedia menu to WordPress admin bar for easy access to settings and moderation page (if enabled).', 'buddypress-media' ),
|
412 |
),
|
413 |
+
'group' => 10,
|
414 |
), //
|
415 |
+
'rtmedia_add_linkback' => array(
|
416 |
+
'title' => esc_html__( 'Add a link to rtMedia in footer', 'buddypress-media' ),
|
417 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
418 |
+
'args' => array(
|
419 |
+
'key' => 'rtmedia_add_linkback',
|
420 |
+
'value' => $options['rtmedia_add_linkback'],
|
421 |
+
'desc' => esc_html__( 'Help us promote rtMedia.', 'buddypress-media' ),
|
422 |
),
|
423 |
+
'group' => 100,
|
424 |
), //
|
425 |
+
'rtmedia_affiliate_id' => array(
|
426 |
+
'title' => esc_html__( 'Also add my affiliate-id to rtMedia footer link', 'buddypress-media' ),
|
427 |
+
'callback' => array( 'RTMediaFormHandler', 'textbox' ),
|
428 |
+
'args' => array(
|
429 |
+
'key' => 'rtmedia_affiliate_id',
|
430 |
+
'value' => $options['rtmedia_affiliate_id'],
|
431 |
+
'desc' => esc_html__( 'Add your affiliate-id along with footer link and get rewarded by our affiliation program.', 'buddypress-media' ),
|
432 |
),
|
433 |
+
'group' => 100,
|
434 |
+
'depends' => 'rtmedia_add_linkback',
|
435 |
+
'after_content' => esc_html__( 'Signup for', 'buddypress-media' ) . ' rtMedia ' . esc_html__( 'affiliate program', 'buddypress-media' ) . ' <a href="https://rtmedia.io/affiliates/">' . esc_html__( 'here', 'buddypress-media' ) . '</a>',
|
436 |
), //
|
437 |
+
'rtmedia_enable_api' => array(
|
438 |
+
'title' => esc_html__( 'Enable JSON API', 'buddypress-media' ),
|
439 |
+
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
440 |
+
'args' => array(
|
441 |
+
'key' => 'rtmedia_enable_api',
|
442 |
+
'value' => $options['rtmedia_enable_api'],
|
443 |
+
'desc' => esc_html__( 'This will allow handling API requests for rtMedia sent through any mobile app.', 'buddypress-media' ),
|
444 |
),
|
445 |
+
'group' => 80,
|
446 |
+
'after_content' => esc_html__( 'You can refer to the API document from', 'buddypress-media' ) . ' <a href="https://rtmedia.io/docs/developers/json-api/">' . esc_html__( 'here', 'buddypress-media' ) . '</a>',
|
447 |
), //
|
448 |
);
|
449 |
|
455 |
*
|
456 |
* @access static
|
457 |
*
|
|
|
|
|
458 |
* @return void
|
459 |
*/
|
460 |
+
static function general_content() {
|
461 |
global $rtmedia;
|
462 |
+
$options = $rtmedia->options;
|
463 |
+
$render_options = self::render_general_content( $options );
|
464 |
+
$render_options = apply_filters( 'rtmedia_general_content_add_itmes', $render_options, $options );
|
465 |
+
$general_group = array();
|
466 |
+
$general_group[10] = esc_html__( 'Admin Settings', 'buddypress-media' );
|
467 |
+
$general_group[80] = esc_html__( 'API Settings', 'buddypress-media' );
|
468 |
+
$general_group[90] = esc_html__( 'Miscellaneous', 'buddypress-media' );
|
469 |
+
$general_group[100] = esc_html__( 'Footer Link', 'buddypress-media' );
|
470 |
+
$general_group = apply_filters( 'rtmedia_general_content_groups', $general_group );
|
|
|
471 |
ksort( $general_group );
|
|
|
472 |
self::render_tab_content( $render_options, $general_group, 90 );
|
473 |
}
|
474 |
|
477 |
*
|
478 |
* @access static
|
479 |
*
|
480 |
+
* @param array $allowed_types
|
481 |
* @param string $key
|
482 |
*
|
483 |
* @return array $data
|
484 |
*/
|
485 |
static function get_type_details( $allowed_types, $key ) {
|
486 |
foreach ( $allowed_types as $type ) {
|
487 |
+
if ( $type['name'] === $key ) {
|
488 |
$data = array(
|
489 |
+
'name' => $type['label'],
|
490 |
+
'extn' => $type['extn'],
|
491 |
);
|
492 |
+
if ( isset( $type['settings_visibility'] ) ) {
|
493 |
+
$data['settings_visibility'] = $type['settings_visibility'];
|
494 |
}
|
495 |
|
496 |
return $data;
|
497 |
}
|
498 |
}
|
499 |
+
return false;
|
500 |
}
|
501 |
|
502 |
/**
|
509 |
* @return array $render
|
510 |
*/
|
511 |
static function types_render_options( $options ) {
|
512 |
+
$render = array();
|
513 |
$allowed_media_type = rtmedia_get_allowed_types();
|
514 |
|
515 |
foreach ( $options as $key => $value ) {
|
516 |
$data = explode( '_', $key );
|
517 |
+
if ( ! isset( $render[ $data[1] ] ) ) {
|
518 |
+
$render[ $data[1] ] = self::get_type_details( $allowed_media_type, $data[1] );
|
519 |
}
|
520 |
}
|
521 |
|
522 |
foreach ( $options as $key => $value ) {
|
523 |
+
$data = explode( '_', $key );
|
524 |
+
$render[ $data[1] ][ $data[2] ] = $value;
|
525 |
}
|
526 |
|
527 |
return $render;
|
546 |
<?php do_action( 'rtmedia_media_type_setting_message' ); ?>
|
547 |
|
548 |
<h3 class="rtm-option-title">
|
549 |
+
<?php esc_html_e( 'Media Types Settings', 'buddypress-media' ); ?>
|
550 |
</h3>
|
551 |
|
552 |
<table class="form-table">
|
554 |
<?php do_action( 'rtmedia_type_settings_before_heading' ); ?>
|
555 |
|
556 |
<tr>
|
557 |
+
<th><strong><?php esc_html_e( 'Media Type', 'buddypress-media' ) ?></strong></th>
|
558 |
|
559 |
<th>
|
560 |
|
561 |
<span class="rtm-tooltip bottom">
|
562 |
+
<strong class="rtm-title"><?php esc_html_e( 'Allow Upload', 'buddypress-media' ); ?></strong>
|
563 |
<span class="rtm-tip-top">
|
564 |
+
<?php esc_html_e( 'Allows you to upload a particular media type on your post.', 'buddypress-media' ); ?>
|
565 |
</span>
|
566 |
</span>
|
567 |
</th>
|
569 |
<th>
|
570 |
|
571 |
<span class="rtm-tooltip bottom">
|
572 |
+
<strong class="rtm-title"><?php esc_html_e( 'Set Featured', 'buddypress-media' ); ?></strong>
|
573 |
<span class="rtm-tip-top">
|
574 |
+
<?php esc_html_e( 'Place a specific media as a featured content on the post.', 'buddypress-media' ); ?>
|
575 |
</span>
|
576 |
</span>
|
577 |
</th>
|
583 |
do_action( 'rtmedia_type_settings_after_heading' );
|
584 |
|
585 |
foreach ( $render_data as $key => $section ) {
|
586 |
+
if ( isset( $section['settings_visibility'] ) && true === $section['settings_visibility'] ) {
|
587 |
do_action( 'rtmedia_type_settings_before_body' );
|
588 |
|
589 |
// allow upload
|
590 |
+
$uplaod_args = array(
|
591 |
+
'key' => 'allowedTypes_' . $key . '_enabled',
|
592 |
+
'value' => $section['enabled'],
|
593 |
+
);
|
594 |
$allow_upload_checkbox = self::checkbox( $uplaod_args, $echo = false );
|
595 |
$allow_upload_checkbox = apply_filters( 'rtmedia_filter_allow_upload_checkbox', $allow_upload_checkbox, $key, $uplaod_args );
|
596 |
|
597 |
// allow featured
|
598 |
+
$featured_args = array(
|
599 |
+
'key' => 'allowedTypes_' . $key . '_featured',
|
600 |
+
'value' => $section['featured'],
|
601 |
+
);
|
602 |
$featured_checkbox = self::checkbox( $featured_args, $echo = false );
|
603 |
$featured_checkbox = apply_filters( 'rtmedia_filter_featured_checkbox', $featured_checkbox, $key );
|
604 |
|
605 |
+
if ( ! isset( $section['extn'] ) || ! is_array( $section['extn'] ) ) {
|
606 |
+
$section['extn'] = array();
|
607 |
}
|
608 |
|
609 |
+
$extensions = implode( ', ', $section['extn'] );
|
610 |
?>
|
611 |
|
612 |
<tr>
|
613 |
<td>
|
614 |
<?php
|
615 |
+
echo esc_html( $section['name'] );
|
616 |
|
617 |
+
if ( 'other' !== $key ) {
|
618 |
?>
|
619 |
<span class="rtm-tooltip rtm-extensions">
|
620 |
<i class="dashicons dashicons-info rtmicon"></i>
|
621 |
<span class="rtm-tip">
|
622 |
+
<strong><?php echo esc_html__( 'File Extensions', 'buddypress-media' ); ?></strong><br/>
|
623 |
+
<hr/>
|
624 |
+
<?php echo esc_html( $extensions ); ?>
|
625 |
</span>
|
626 |
</span>
|
627 |
<?php
|
631 |
|
632 |
<td>
|
633 |
<span class="rtm-field-wrap">
|
634 |
+
<?php //escaping done into inner function
|
635 |
+
// @codingStandardsIgnoreLine
|
636 |
+
echo wp_kses( $allow_upload_checkbox, array(
|
637 |
+
'span' => array(
|
638 |
+
'class' => array(),
|
639 |
+
'data-on' => array(),
|
640 |
+
'data-off' => array()
|
641 |
+
),
|
642 |
+
'label' => array(
|
643 |
+
'for' => array(),
|
644 |
+
'class' => array()
|
645 |
+
),
|
646 |
+
'input' => array(
|
647 |
+
'type' => array(),
|
648 |
+
'checked' => array(),
|
649 |
+
'data-toggle' => array(),
|
650 |
+
'id' => array(),
|
651 |
+
'name' => array(),
|
652 |
+
'value' => array()
|
653 |
+
)
|
654 |
+
) );
|
655 |
+
?>
|
656 |
+
</span>
|
657 |
</td>
|
658 |
|
659 |
<td>
|
660 |
+
<?php //escaping done into inner function
|
661 |
+
// @codingStandardsIgnoreLine
|
662 |
+
echo wp_kses( $featured_checkbox, array(
|
663 |
+
'span' => array(
|
664 |
+
'class' => array(),
|
665 |
+
'data-on' => array(),
|
666 |
+
'data-off' => array()
|
667 |
+
),
|
668 |
+
'label' => array(
|
669 |
+
'for' => array(),
|
670 |
+
'class' => array()
|
671 |
+
),
|
672 |
+
'input' => array(
|
673 |
+
'type' => array(),
|
674 |
+
'checked' => array(),
|
675 |
+
'data-toggle' => array(),
|
676 |
+
'id' => array(),
|
677 |
+
'name' => array(),
|
678 |
+
'value' => array()
|
679 |
+
)
|
680 |
+
) );
|
681 |
+
?>
|
682 |
</td>
|
683 |
|
684 |
<?php do_action( 'rtmedia_type_setting_columns_body', $key, $section ) ?>
|
691 |
} else {
|
692 |
echo '<tr class="hide">';
|
693 |
echo '<td colspan="3">';
|
694 |
+
echo "<input type='hidden' value='1' name='rtmedia-options[allowedTypes_" . esc_attr( $key ) . "_enabled]'>";
|
695 |
+
echo "<input type='hidden' value='0' name='rtmedia-options[allowedTypes_" . esc_html( $key ) . "_featured]'>";
|
696 |
echo '</td>';
|
697 |
echo '</tr>';
|
698 |
}
|
718 |
$render = array();
|
719 |
foreach ( $options as $key => $value ) {
|
720 |
$data = explode( '_', $key );
|
721 |
+
if ( ! isset( $render[ $data[1] ] ) ) {
|
722 |
+
$render[ $data[1] ] = array();
|
723 |
+
$render[ $data[1] ]['title'] = esc_html__( $data[1], 'buddypress-media' );
|
724 |
}
|
725 |
+
if ( ! isset( $render[ $data[1] ][ $data[2] ] ) ) {
|
726 |
+
$render[ $data[1] ][ $data[2] ] = array();
|
727 |
+
$render[ $data[1] ][ $data[2] ]['title'] = esc_html__( $data[2], 'buddypress-media' );
|
728 |
}
|
729 |
|
730 |
+
$render[ $data[1] ][ $data[2] ][ $data[3] ] = $value;
|
731 |
}
|
732 |
|
733 |
return $render;
|
744 |
*/
|
745 |
public static function sizes_content() {
|
746 |
global $rtmedia;
|
747 |
+
$options = self::extract_settings( 'defaultSizes', $rtmedia->options );
|
748 |
$render_data = self::sizes_render_options( $options );
|
749 |
?>
|
750 |
|
751 |
<div class="rtm-option-wrapper rtm-img-size-setting">
|
752 |
<h3 class="rtm-option-title">
|
753 |
+
<?php esc_html_e( 'Media Size Settings', 'buddypress-media' ); ?>
|
754 |
</h3>
|
755 |
|
756 |
<table class="form-table">
|
757 |
<tr>
|
758 |
+
<th><strong><?php esc_html_e( 'Category', 'buddypress-media' ) ?></strong></th>
|
759 |
+
<th><strong><?php esc_html_e( 'Entity', 'buddypress-media' ); ?></strong></th>
|
760 |
+
<th><strong><?php esc_html_e( 'Width', 'buddypress-media' ); ?></strong></th>
|
761 |
+
<th><strong><?php esc_html_e( 'Height', 'buddypress-media' ); ?></strong></th>
|
762 |
+
<th><strong><?php esc_html_e( 'Crop', 'buddypress-media' ); ?></strong></th>
|
763 |
</tr>
|
764 |
|
765 |
<?php
|
766 |
foreach ( $render_data as $parent_key => $section ) {
|
767 |
$entities = $section;
|
768 |
+
unset( $entities['title'] );
|
769 |
+
$count = 0;
|
770 |
+
$row_span = count( $entities ); // @codingStandardsIgnoreLine
|
771 |
foreach ( $entities as $entity ) {
|
772 |
?>
|
773 |
<tr>
|
774 |
<?php
|
775 |
+
if ( 0 === $count ) {
|
776 |
?>
|
777 |
+
<td class="rtm-row-title" rowspan="<?php echo esc_attr( $row_span ); ?>">
|
778 |
+
<?php echo esc_html( ucfirst( $section['title'] ) ); ?>
|
779 |
</td>
|
780 |
<?php
|
781 |
}
|
782 |
?>
|
783 |
<td>
|
784 |
+
<?php echo esc_html( ucfirst( $entity['title'] ) ); ?>
|
785 |
</td>
|
786 |
<?php
|
787 |
$args = array(
|
788 |
+
'key' => 'defaultSizes_' . $parent_key . '_' . $entity['title'],
|
789 |
);
|
790 |
foreach ( $entity as $child_key => $value ) {
|
791 |
+
if ( 'title' !== $child_key ) {
|
792 |
$args[ $child_key ] = $value;
|
793 |
}
|
794 |
}
|
806 |
|
807 |
<?php
|
808 |
$options = $rtmedia->options;
|
809 |
+
|
810 |
// Checking if user has subscribed any plan for encoding
|
811 |
$rtmedia_encoding_api_key = get_rtmedia_encoding_api_key();
|
812 |
|
813 |
+
if ( isset( $rtmedia_encoding_api_key ) && '' !== $rtmedia_encoding_api_key && $rtmedia_encoding_api_key ) {
|
814 |
$render_video_thumb = array(
|
815 |
+
'title' => esc_html__( 'Number of thumbnails to generate on video upload', 'buddypress-media' ),
|
816 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
817 |
+
'args' => array(
|
818 |
+
'key' => 'general_videothumbs',
|
819 |
+
'value' => $options['general_videothumbs'],
|
820 |
'class' => array( 'rtmedia-setting-text-box' ),
|
821 |
+
'desc' => esc_html__( ' If you choose more than 1 thumbnail, your users will be able to change the thumbnail by going to video \'edit\' section. Maximum value is 10.', 'buddypress-media' ),
|
822 |
+
'min' => 1,
|
823 |
+
'max' => 10,
|
824 |
+
),
|
825 |
);
|
826 |
?>
|
827 |
|
828 |
<div class="rtm-option-wrapper">
|
829 |
+
<?php self::render_option_group( esc_html__( 'Encoding Settings', 'buddypress-media' ) ); ?>
|
830 |
+
<?php self::render_option_content( $render_video_thumb ); ?>
|
831 |
</div>
|
832 |
<?php
|
833 |
}
|
834 |
|
835 |
$render_jpeg_image_quality = array(
|
836 |
+
'title' => esc_html__( 'JPEG/JPG image quality (1-100)', 'buddypress-media' ),
|
837 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
838 |
+
'args' => array(
|
839 |
+
'key' => 'general_jpeg_image_quality',
|
840 |
+
'value' => $options['general_jpeg_image_quality'],
|
841 |
'class' => array( 'rtmedia-setting-text-box' ),
|
842 |
+
'desc' => esc_html__( 'Enter JPEG/JPG Image Quality. Minimum value is 1. 100 is original quality.', 'buddypress-media' ),
|
843 |
+
'min' => 1,
|
844 |
+
'max' => 100,
|
845 |
+
),
|
846 |
);
|
847 |
?>
|
848 |
|
849 |
<div class="rtm-option-wrapper">
|
850 |
+
<?php self::render_option_group( esc_html__( 'Image Quality', 'buddypress-media' ) ); ?>
|
851 |
<?php self::render_option_content( $render_jpeg_image_quality ); ?>
|
852 |
</div>
|
853 |
|
865 |
*/
|
866 |
public static function custom_css_content() {
|
867 |
global $rtmedia;
|
868 |
+
$options = self::extract_settings( 'styles', $rtmedia->options );
|
869 |
$render_data = self::custom_css_render_options( $options );
|
870 |
|
871 |
+
$render_groups = array();
|
872 |
+
$render_groups[10] = esc_html__( 'Custom CSS settings', 'buddypress-media' );
|
873 |
|
874 |
self::render_tab_content( $render_data, $render_groups, 10 );
|
875 |
}
|
884 |
* @return array $render
|
885 |
*/
|
886 |
static function custom_css_render_options( $options ) {
|
|
|
|
|
887 |
$render = array(
|
888 |
'disable_styles' => array(
|
889 |
+
'title' => esc_html__( 'rtMedia default styles', 'buddypress-media' ),
|
890 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
891 |
+
'args' => array(
|
892 |
+
'id' => 'rtmedia-disable-styles',
|
893 |
+
'key' => 'styles_enabled',
|
894 |
+
'value' => $options['styles_enabled'],
|
895 |
+
'desc' => esc_html__( 'Load default rtMedia styles. You need to write your own style for rtMedia if you disable it.', 'buddypress-media' ),
|
896 |
),
|
897 |
+
'group' => 10,
|
898 |
),
|
899 |
+
'custom_styles' => array(
|
900 |
+
'title' => esc_html__( 'Paste your CSS code', 'buddypress-media' ),
|
901 |
'callback' => array( 'RTMediaFormHandler', 'textarea' ),
|
902 |
+
'args' => array(
|
903 |
+
'id' => 'rtmedia-custom-css',
|
904 |
+
'key' => 'styles_custom',
|
905 |
+
'value' => stripcslashes( $options['styles_custom'] ),
|
906 |
+
'desc' => esc_html__( 'Custom rtMedia CSS container', 'buddypress-media' ),
|
907 |
),
|
908 |
+
'group' => 10,
|
909 |
),
|
910 |
);
|
911 |
|
925 |
global $rtmedia;
|
926 |
|
927 |
$render = array(
|
928 |
+
'enable' => array(
|
929 |
+
'title' => esc_html__( 'Enable privacy', 'buddypress-media' ),
|
930 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
931 |
+
'args' => array(
|
932 |
+
'id' => 'rtmedia-privacy-enable',
|
933 |
+
'key' => 'privacy_enabled',
|
934 |
+
'value' => $options['privacy_enabled'],
|
935 |
+
'desc' => esc_html__( 'Enable privacy in rtMedia', 'buddypress-media' ),
|
936 |
),
|
937 |
+
'group' => 10,
|
938 |
),
|
939 |
+
'default' => array(
|
940 |
+
'title' => esc_html__( 'Default privacy', 'buddypress-media' ),
|
941 |
'callback' => array( 'RTMediaFormHandler', 'radio' ),
|
942 |
+
'args' => array(
|
943 |
+
'key' => 'privacy_default',
|
944 |
+
'radios' => $rtmedia->privacy_settings['levels'],
|
945 |
+
'default' => $options['privacy_default'],
|
946 |
+
'desc' => esc_html__( 'Set default privacy for media', 'buddypress-media' ),
|
947 |
),
|
948 |
+
'group' => 10,
|
949 |
+
'depends' => 'privacy_enabled',
|
950 |
),
|
951 |
'user_override' => array(
|
952 |
+
'title' => esc_html__( 'Allow users to set privacy for their content', 'buddypress-media' ),
|
953 |
+
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
954 |
+
'args' => array(
|
955 |
+
'key' => 'privacy_userOverride',
|
956 |
+
'value' => $options['privacy_userOverride'],
|
957 |
+
'desc' => esc_html__( 'If you choose this, users will be able to change privacy of their own uploads.', 'buddypress-media' ),
|
958 |
),
|
959 |
+
'group' => 10,
|
960 |
+
'depends' => 'privacy_enabled',
|
961 |
+
'after_content' => esc_html__( 'For group uploads, BuddyPress groups privacy is used.', 'buddypress-media' ),
|
962 |
),
|
963 |
);
|
964 |
|
977 |
public static function privacy_content() {
|
978 |
global $rtmedia;
|
979 |
|
980 |
+
$general_group = array();
|
981 |
+
$general_group[10] = 'Privacy Settings';
|
982 |
+
$general_group = apply_filters( 'rtmedia_privacy_settings_groups', $general_group );
|
983 |
|
984 |
+
$options = self::extract_settings( 'privacy', $rtmedia->options );
|
985 |
$render_options = self::privacy_render_options( $options );
|
986 |
$render_options = apply_filters( 'rtmedia_privacy_settings_options', $render_options );
|
987 |
|
999 |
*/
|
1000 |
static function buddypress_render_options( $options ) {
|
1001 |
$render = array(
|
1002 |
+
'rtmedia-enable-on-profile' => array(
|
1003 |
+
'title' => esc_html__( 'Enable media in profile', 'buddypress-media' ),
|
1004 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1005 |
+
'args' => array(
|
1006 |
+
'key' => 'buddypress_enableOnProfile',
|
1007 |
+
'value' => $options['buddypress_enableOnProfile'],
|
1008 |
+
'desc' => esc_html__( 'Enable Media on BuddyPress Profile', 'buddypress-media' ),
|
1009 |
),
|
1010 |
+
'group' => 10,
|
1011 |
),
|
1012 |
+
'rtmedia-enable-on-group' => array(
|
1013 |
+
'title' => esc_html__( 'Enable media in group', 'buddypress-media' ),
|
1014 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1015 |
+
'args' => array(
|
1016 |
+
'key' => 'buddypress_enableOnGroup',
|
1017 |
+
'value' => $options['buddypress_enableOnGroup'],
|
1018 |
+
'desc' => esc_html__( 'Enable Media on BuddyPress Groups', 'buddypress-media' ),
|
1019 |
),
|
1020 |
+
'group' => 10,
|
1021 |
),
|
1022 |
+
'rtmedia-enable-on-activity' => array(
|
1023 |
+
'title' => esc_html__( 'Allow upload from activity stream', 'buddypress-media' ),
|
1024 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1025 |
+
'args' => array(
|
1026 |
+
'key' => 'buddypress_enableOnActivity',
|
1027 |
+
'value' => $options['buddypress_enableOnActivity'],
|
1028 |
+
'desc' => esc_html__( 'Allow upload using status update box present on activity stream page', 'buddypress-media' ),
|
1029 |
+
'id' => 'rtmedia-bp-enable-activity',
|
1030 |
),
|
1031 |
+
'group' => 10,
|
1032 |
),
|
1033 |
+
'rtmedia-activity-feed-limit' => array(
|
1034 |
+
'title' => esc_html__( 'Number of media items to show in activity stream', 'buddypress-media' ),
|
1035 |
'callback' => array( 'RTMediaFormHandler', 'number' ),
|
1036 |
+
'args' => array(
|
1037 |
+
'key' => 'buddypress_limitOnActivity',
|
1038 |
+
'value' => $options['buddypress_limitOnActivity'],
|
1039 |
+
'desc' => esc_html__( 'With bulk uploads activity, the stream may get flooded. You can control the maximum number of media items or files per activity. This limit will not affect the actual number of uploads. This is only for display. "0" means unlimited.', 'buddypress-media' ),
|
1040 |
'class' => array( 'rtmedia-setting-text-box rtmedia-bp-activity-setting' ),
|
1041 |
+
'min' => 0,
|
1042 |
),
|
1043 |
+
'group' => 10,
|
1044 |
),
|
1045 |
+
'rtmedia-enable-notification' => array(
|
1046 |
+
'title' => esc_html__( 'Enable media notification', 'buddypress-media' ),
|
1047 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1048 |
+
'args' => array(
|
1049 |
+
'key' => 'buddypress_enableNotification',
|
1050 |
+
'value' => $options['buddypress_enableNotification'],
|
1051 |
+
'desc' => esc_html__( 'This will enable notifications to media authors for media likes and comments.', 'buddypress-media' ),
|
1052 |
+
|
1053 |
),
|
1054 |
+
'group' => 10,
|
1055 |
),
|
1056 |
+
'rtmedia-enable-like-activity' => array(
|
1057 |
+
'title' => esc_html__( 'Create activity for media likes', 'buddypress-media' ),
|
1058 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1059 |
+
'args' => array(
|
1060 |
+
'key' => 'buddypress_mediaLikeActivity',
|
1061 |
+
'value' => $options['buddypress_mediaLikeActivity'],
|
1062 |
+
'desc' => esc_html__( 'Enabling this setting will create BuddyPress activity for media likes.', 'buddypress-media' ),
|
1063 |
|
1064 |
),
|
1065 |
+
'group' => 10,
|
1066 |
),
|
1067 |
'rtmedia-enable-comment-activity' => array(
|
1068 |
+
'title' => esc_html__( 'Create activity for media comments', 'buddypress-media' ),
|
1069 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1070 |
+
'args' => array(
|
1071 |
+
'key' => 'buddypress_mediaCommentActivity',
|
1072 |
+
'value' => $options['buddypress_mediaCommentActivity'],
|
1073 |
+
'desc' => esc_html__( 'Enabling this setting will create BuddyPress activity for media comments.', 'buddypress-media' ),
|
1074 |
|
1075 |
),
|
1076 |
+
'group' => 10,
|
1077 |
),
|
1078 |
+
'general_enableAlbums' => array(
|
1079 |
+
'title' => esc_html__( 'Organize media into albums', 'buddypress-media' ),
|
1080 |
'callback' => array( 'RTMediaFormHandler', 'checkbox' ),
|
1081 |
+
'args' => array(
|
1082 |
+
'id' => 'rtmedia-album-enable',
|
1083 |
+
'key' => 'general_enableAlbums',
|
1084 |
+
'value' => $options['general_enableAlbums'],
|
1085 |
+
'desc' => esc_html__( 'This will add \'album\' tab to BuddyPress profile and group depending on the ^above^ settings.', 'buddypress-media' ),
|
1086 |
),
|
1087 |
+
'group' => 50,
|
1088 |
),
|
1089 |
);
|
1090 |
|
1103 |
public static function buddypress_content() {
|
1104 |
global $rtmedia;
|
1105 |
|
1106 |
+
$general_group = array();
|
1107 |
+
$general_group[10] = 'Integration With BuddyPress Features';
|
1108 |
+
$general_group[50] = 'Album Settings';
|
1109 |
+
$general_group = apply_filters( 'rtmedia_buddypress_setting_group', $general_group );
|
1110 |
|
1111 |
$render_options = self::buddypress_render_options( $rtmedia->options );
|
1112 |
$render_options = apply_filters( 'rtmedia_album_control_setting', $render_options, $rtmedia->options );
|
1123 |
*
|
1124 |
* @access static
|
1125 |
*
|
1126 |
+
* @param string $page
|
1127 |
* @param array $sub_tabs
|
1128 |
*
|
1129 |
* @return void
|
1142 |
*
|
1143 |
* @access static
|
1144 |
*
|
1145 |
+
* @param string $page
|
1146 |
+
* @param string $section
|
1147 |
*
|
1148 |
* @return void
|
1149 |
*/
|
1154 |
return;
|
1155 |
}
|
1156 |
|
1157 |
+
foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
|
1158 |
echo '<div class="row">';
|
1159 |
echo '<div class="large-11 columns">';
|
1160 |
|
1161 |
+
if ( isset( $field['args']['label_for'] ) && ! empty( $field['args']['label_for'] ) ) {
|
1162 |
+
call_user_func( $field['callback'], array_merge( $field['args'], array( 'label' => $field['args']['label_for'] ) ) );
|
1163 |
} else {
|
1164 |
+
if ( isset( $field['title'] ) && ! empty( $field['title'] ) ) {
|
1165 |
+
call_user_func( $field['callback'], array_merge( $field['args'], array( 'label' => $field['title'] ) ) );
|
1166 |
} else {
|
1167 |
+
call_user_func( $field['callback'], $field['args'] );
|
1168 |
}
|
1169 |
}
|
1170 |
echo '</div>';
|
1188 |
<?php
|
1189 |
self::render_option_group( $value );
|
1190 |
foreach ( $options as $tab => $option ) {
|
1191 |
+
if ( ! isset( $option['group'] ) ) {
|
1192 |
+
$option['group'] = $default_group;
|
|
|
1193 |
}
|
1194 |
|
1195 |
+
if ( intval( $option['group'] ) !== $key ) {
|
1196 |
continue;
|
1197 |
}
|
1198 |
self::render_option_content( $option );
|
1222 |
|
1223 |
public static function render_option_group( $group ) {
|
1224 |
?>
|
1225 |
+
<h3 class="rtm-option-title"><?php echo esc_html( $group ); ?></h3>
|
1226 |
<?php
|
1227 |
}
|
1228 |
|
1235 |
?>
|
1236 |
|
1237 |
<table class="form-table" <?php
|
1238 |
+
if ( isset( $option['depends'] ) && '' !== $option['depends'] ) {
|
1239 |
+
echo 'data-depends="' . esc_attr( $option['depends'] ) . '"';
|
1240 |
}
|
1241 |
?>>
|
1242 |
<tr>
|
1243 |
<th>
|
1244 |
+
<?php echo wp_kses( $option['title'], array(
|
1245 |
+
'a' => array(
|
1246 |
+
'id' => array(),
|
1247 |
+
'href' => array(),
|
1248 |
+
'target' => array(),
|
1249 |
+
),
|
1250 |
+
) ); ?>
|
1251 |
</th>
|
1252 |
<td>
|
1253 |
<fieldset>
|
1254 |
+
<span
|
1255 |
+
class="rtm-field-wrap"><?php call_user_func( $option['callback'], $option['args'] ); ?></span>
|
1256 |
<span class="rtm-tooltip">
|
1257 |
<i class="dashicons dashicons-info rtmicon"></i>
|
1258 |
<span class="rtm-tip">
|
1259 |
+
<?php echo wp_kses( ( isset( $option['args']['desc'] ) ) ? $option['args']['desc'] : 'NA', array(
|
1260 |
+
'a' => array(
|
1261 |
+
'id' => array(),
|
1262 |
+
'href' => array(),
|
1263 |
+
'target' => array(),
|
1264 |
+
),
|
1265 |
+
) ); ?>
|
1266 |
</span>
|
1267 |
</span>
|
1268 |
</fieldset>
|
1271 |
</table>
|
1272 |
|
1273 |
<?php
|
1274 |
+
if ( isset( $option['after_content'] ) && '' !== $option['after_content'] ) {
|
1275 |
?>
|
1276 |
+
<div class="rtm-message rtm-notice"><?php echo wp_kses( wpautop( $option['after_content'] ), array(
|
1277 |
+
'a' => array(
|
1278 |
+
'id' => array(),
|
1279 |
+
'href' => array(),
|
1280 |
+
'target' => array(),
|
1281 |
+
),
|
1282 |
+
'p' => array(),
|
1283 |
+
) ); ?></div><?php
|
1284 |
}
|
1285 |
}
|
1286 |
+
}
|
|
app/admin/templates/tmpl-rtm-album-favourites-importer.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<br />
|
2 |
+
<div class="bp-album-favorites">
|
3 |
+
<strong>
|
4 |
+
<?php echo esc_attr__( "User's Favorites:", 'buddypress-media' ); ?> <span class="finished">0</span> / <span class="total">{{data.users}}</span>
|
5 |
+
</strong>
|
6 |
+
<div id="rtprogressbar">
|
7 |
+
<div style="width:0%"></div>
|
8 |
+
</div>
|
9 |
+
</div>
|
app/admin/templates/tmpl-rtm-image.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<# if(data.class && '' !== data.class){ #>
|
2 |
+
<img class="bpm-ajax-loader" src="{{data.src}}" /> <strong>{{data.norefresh}}</strong>
|
3 |
+
<# } else { #>
|
4 |
+
<img style="margin: 0 0 0 10px" src="{{data.src}}" />
|
5 |
+
<# } #>
|
app/admin/templates/tmpl-rtm-map-mapping-failure.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<div class="map_mapping_failure">{{map_data.msg}}</div>
|
app/admin/templates/tmpl-rtm-msg-div.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<div class="{{data.class}}" id="{{data.id}}">
|
2 |
+
<p>{{data.msg}}</p>
|
3 |
+
</div>
|
app/admin/templates/tmpl-rtm-p-tag.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<# if( data.strong && '' !== data.strong ) { #>
|
2 |
+
<p><strong>{{data.msg}}</strong></p>
|
3 |
+
<# } else { #>
|
4 |
+
<p>{{data.msg}}</p>
|
5 |
+
<# } #>
|
app/admin/templates/tmpl-rtm-theme-overlay.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<div class="theme-overlay rtm-theme-overlay">
|
2 |
+
<div class="theme-backdrop rtm-close"></div>
|
3 |
+
<div class="rtm-theme-content-wrap">{{{data.themeContent}}}</div>
|
4 |
+
</div>
|
app/assets/admin/css/admin.css
CHANGED
@@ -699,7 +699,7 @@ input[type=checkbox]:checked ~ .switch-handle {
|
|
699 |
}
|
700 |
.rtm-plugin-card.plugin-card .rtm-logo img {
|
701 |
height: auto;
|
702 |
-
margin: -10px 0 0 -10px
|
703 |
max-width: 120px;
|
704 |
}
|
705 |
.rtm-plugin-card.plugin-card .desc, .rtm-plugin-card.plugin-card .name {
|
@@ -709,6 +709,7 @@ input[type=checkbox]:checked ~ .switch-handle {
|
|
709 |
}
|
710 |
.rtm-plugin-card.plugin-card h4 {
|
711 |
margin-bottom: 0;
|
|
|
712 |
}
|
713 |
.rtm-plugin-card.plugin-card a {
|
714 |
text-decoration: none;
|
@@ -728,6 +729,9 @@ input[type=checkbox]:checked ~ .switch-handle {
|
|
728 |
#rtm-plugins .rtm-setting-title + .rtm-option-title {
|
729 |
margin-top: 0;
|
730 |
}
|
|
|
|
|
|
|
731 |
|
732 |
.rtm-encoding-table {
|
733 |
border-collapse: collapse;
|
699 |
}
|
700 |
.rtm-plugin-card.plugin-card .rtm-logo img {
|
701 |
height: auto;
|
702 |
+
/*margin: -10px 0 0 -10px;*/
|
703 |
max-width: 120px;
|
704 |
}
|
705 |
.rtm-plugin-card.plugin-card .desc, .rtm-plugin-card.plugin-card .name {
|
709 |
}
|
710 |
.rtm-plugin-card.plugin-card h4 {
|
711 |
margin-bottom: 0;
|
712 |
+
margin-top: 0;
|
713 |
}
|
714 |
.rtm-plugin-card.plugin-card a {
|
715 |
text-decoration: none;
|
729 |
#rtm-plugins .rtm-setting-title + .rtm-option-title {
|
730 |
margin-top: 0;
|
731 |
}
|
732 |
+
#rtm-plugins .plugin-card-top {
|
733 |
+
padding: 10px;
|
734 |
+
}
|
735 |
|
736 |
.rtm-encoding-table {
|
737 |
border-collapse: collapse;
|
app/assets/admin/css/admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.alignleft{float:left}.alignright{float:right}.aligncenter{display:block;margin-left:auto;margin-right:auto;text-align:center}.clear-both{clear:both}.clear-none{clear:none}.clear-left{clear:left}.clear-right{clear:right}.rtm-inline-block{display:inline-block}.rtm-text-left{text-align:left}.rtm-text-right{text-align:right}.rtm-text-center{text-align:center}.rtm-border-0{border:0 !important}.hide{display:none}.clearfix:after{content:"";display:table;clear:both}.rtm-row-container{padding-top:10px}.rtm-admin-tab-container{display:table;width:100%}.rtm-admin-tab-container .rtm-tabs-content{background:#fff;border-left:1px solid #e7e7e7;display:table-cell;min-height:300px;padding:20px 30px;vertical-align:top}.rtm-setting-container{background-color:#f5f5f5;border:1px solid #dedede;box-shadow:0 1px 1px rgba(0,0,0,0.04);margin-top:10px}.rtm-sidebar .postbox .hndle{cursor:default}.rtm-tabs{display:table-cell;list-style:none;margin:0;min-height:300px;width:202px}.rtm-button-container{background:#f3f3f3;border-bottom:1px solid #dedede;box-shadow:0 1px 0 #fcfcfc inset;overflow:hidden;padding:6px 10px 6px 6px;position:relative;text-align:right}.rtm-button-container.bottom{background:#eee;border-top:1px solid #e7e7e7;box-shadow:0 0 0;z-index:999}#mce-EMAIL{width:100%}#mc-embedded-subscribe{display:block;margin:10px auto 0;width:100%}.rtm-social-links a{display:inline-block;margin:4px 0 4px 4px;text-decoration:none}.nav-tab.rtm-premium{background:#e74c3c;color:white;letter-spacing:0.5px}.rtm-setting-title{border-bottom:1px solid #eee;font-size:22px;font-weight:400;line-height:1;margin-bottom:20px;margin-top:0;padding-bottom:14px;display:none}.rtm-setting-title.rtm-show{display:block}.rtm-option-wrapper{margin-bottom:40px}.rtm-option-wrapper:last-child{margin-bottom:20px}.rtm-setting-title+.rtm-option-wrapper{margin-top:0}.rtm-option-wrapper:last-child{border-bottom:0}.rtm-option-wrapper .form-table{clear:none}.rtm-option-wrapper .rtm-field-wrap{float:left}.rtm-option-wrapper a{text-decoration:none}.rtm-option-wrapper .form-table th{color:#444;font-size:13px;font-weight:400;padding:5px 30px 5px 0;vertical-align:top;width:48%}.rtm-option-wrapper .form-table td{font-size:13px;padding:0 0 5px;vertical-align:top}.rtm-option-wrapper .form-table td fieldset label{display:block;margin:0 !important}.rtm-option-wrapper .form-table .rtm-form-radio label{margin-top:5px !important}.rtm-option-wrapper textarea,.rtm-option-wrapper select,.rtm-option-wrapper input[type=text],.rtm-option-wrapper input[type=number]{border-radius:3px}.rtm-option-wrapper input[type=number]{width:60px}.rtm-option-wrapper .rt-form-radio{height:28px;line-height:24px}.rtm-option-wrapper .rt-form-radio label:first-child{margin-right:12px !important}.rtm-option-wrapper .dashicons-info{color:#aaa;font-size:14px;height:26px;line-height:26px;position:relative}.rtm-option-wrapper .rtm-debug-info{margin-top:32px}.rtm-option-wrapper .rtm-debug-info tr{border-bottom:1px solid #eee}.rtm-option-wrapper .rtm-debug-info tr:first-child{border-top:1px solid #eee}.rtm-option-wrapper .rtm-debug-info tr:nth-child(2n){background-color:#f8f8f8}.rtm-option-wrapper .rtm-debug-info th{border-right:1px solid #eee;font-weight:600;width:auto}.rtm-option-wrapper .rtm-debug-info th,.rtm-option-wrapper .rtm-debug-info td{padding:10px}.rtm-option-title{border-bottom:1px solid #eee;font-size:14px;letter-spacing:0.02rem;margin-bottom:12px;margin-top:0;padding:0 0 6px;text-transform:uppercase}.rtm-sidebar .button{display:block;opacity:0.8;position:relative;text-decoration:none}.rtm-social-share .dashicons{font-size:18px;position:absolute;right:10px;top:4px}.rtm-social-share .twitter .dashicons{color:#45b0e3}.rtm-social-share .facebook .dashicons{color:#3b5998}.rtm-social-share .wordpress .dashicons{color:#21759b}.rtm-social-share .rss .dashicons{color:#FF6600}.rtm-social-share p:last-child{margin-bottom:0}.rtm-notice{background:rgba(238,238,238,0.8);color:#777;font-size:12px;line-height:1.6;margin-top:10px;overflow:hidden;padding:0 10px}.rtm-notice p{font-size:inherit;line-height:inherit;margin:10px 0}.rtm-warning{background-color:#fcf8e3;border-bottom:1px solid #EEE;color:#c09853;padding:10px 15px}.rtmedia-theme-warning{margin-bottom:26px}.rtm-success{background-color:#dff0d8;border-bottom:1px solid #e7e7e7;color:#468847;margin:0;padding:8px 35px 8px 14px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.rtm-fly-warning{border-bottom:0;left:-10px;letter-spacing:1px;line-height:22px;margin-bottom:0;padding:14px 25px;position:absolute;top:-5px}#rtmedia-types .form-table th{line-height:26px;padding:5px 0 20px;width:33%}#rtmedia-types .form-table td{padding:0 0 12px}#rtmedia-custom-css-settings .form-table th{width:35%}#rtmedia-custom-css-settings .form-table:last-child .rtm-field-wrap{width:92%}#rtmedia-custom-css-settings textarea{height:300px;width:100%}.rtm-img-size-setting .form-table th{border-bottom:1px solid #eee;padding-bottom:10px;padding-top:10px;width:20%}.rtm-img-size-setting .form-table tr:nth-child(2) td{padding-top:20px}.rtm-img-size-setting .form-table tr:nth-child(4){border-bottom:1px solid #eee}.rtm-img-size-setting .form-table tr:nth-child(4) td{padding-bottom:20px}.rtm-img-size-setting .form-table tr:nth-child(5) td{padding-top:20px}.rtm-img-size-setting .form-table tr:nth-child(6) td{padding-bottom:20px}.rtm-img-size-setting .form-table tr:nth-child(7){border-top:1px solid #eee}.rtm-img-size-setting .form-table tr:nth-child(7) td{padding-top:20px}.rtm-img-size-setting .form-table tr:nth-last-child(2) td{padding-bottom:20px}.rtm-img-size-setting .form-table tr:last-child{border-top:1px solid #eee}.rtm-img-size-setting .form-table tr:last-child td{padding-top:20px;padding-bottom:20px}.rtm-img-size-setting .form-table .rtm-row-title{font-weight:600}#rtmedia-privacy .rt-form-radio{font-size:12px}#rtmedia-privacy .rt-form-radio strong{font-size:13px}#rtmedia-encoding-usage strong{display:inline-block;min-width:120px}#rtmedia-encoding-usage p{overflow:hidden}.encoding-used,.encoding-remaining{background:#7AD03A;float:right;height:12px;margin-top:3px;width:12px}.encoding-remaining{background:#dedede}#rtprogressbar{background:#dedede;height:10px;position:relative}#rtprogressbar div{background:#7AD03A;height:10px;left:0;position:absolute}.rtm-tabs li{margin:0}.rtm-tabs a{border-bottom:1px solid #e7e7e7;border-top:1px solid #f2f2f2;color:#222;display:block;font-weight:700;outline:none;opacity:0.8;padding:10px 4px 10px 14px;position:relative;text-decoration:none;z-index:10}.rtm-tabs a:hover{background:#eee;color:#269ad6;margin-right:0;opacity:1;width:auto}.rtm-tabs a:focus{background:#fff;box-shadow:0 0 0}.rtm-tabs .active{background:white;position:relative}.rtm-tabs .active:after{background:#fff;content:' ';height:100%;position:absolute;right:-1px;top:0;width:1px}.rtm-tabs .active a{border-top-color:#fff;color:#222;opacity:1}.rtm-tabs .active a:hover{background:#fff}.rtm-tabs span{display:block;padding:0 0 0 25px}.rtm-tabs .dashicons{font-size:14px;height:auto;line-height:1;margin-top:3px;position:absolute;vertical-align:middle;width:auto}.rtm-horizotanl-tabs .rtm-tabs{list-style:none;margin:0;display:block;width:auto;min-height:0}.rtm-horizotanl-tabs .rtm-tabs-content{border-left:none;background:#fff;min-height:300px;padding:20px 30px;vertical-align:top}.rtm-horizotanl-tabs .rtm-tabs a{border-bottom:none}.rtm-horizotanl-tabs .rtm-tabs li{display:inline-block}.rtm-horizotanl-tabs.rtm-admin-tab-container{width:100%;display:block}.switch{position:relative;display:inline-block;vertical-align:top;width:58px;height:22px;padding:3px;border-radius:18px}.switch input[type=checkbox]{position:absolute;top:0;left:0;opacity:0}.switch-label{position:relative;display:block;height:inherit;color:#fff;font-size:12px;text-transform:uppercase;background:#b4b4b4;border-radius:inherit;-webkit-transition:0.15s ease-out;transition:0.15s ease-out;-webkit-transition-property:opacity background;transition-property:opacity background}.switch-label:before,.switch-label:after{position:absolute;top:50%;margin-top:-.5em;line-height:1;-webkit-transition:inherit;transition:inherit}.switch-label:before{content:attr(data-off);right:11px;color:#fff}.switch-label:after{content:attr(data-on);left:11px;opacity:0}input[type=checkbox]:checked ~ .switch-label{background:#33a7d1}input[type=checkbox]:checked ~ .switch-label:before{opacity:0}input[type=checkbox]:checked ~ .switch-label:after{opacity:1}.switch-handle{position:absolute;top:5px;left:5px;width:18px;height:18px;background:white;border-radius:10px;box-shadow:1px 1px 5px rgba(0,0,0,0.2);background-image:-webkit-linear-gradient(top, #fff 40%, #f0f0f0);background-image:linear-gradient(to bottom, #fff 40%, #f0f0f0);-webkit-transition:left 0.15s ease-out;transition:left 0.15s ease-out}.switch-handle:before{content:'';position:absolute;top:50%;left:50%;margin:-6px 0 0 -6px;width:12px;height:12px;background:#f9f9f9;border-radius:6px;box-shadow:inset 0 1px rgba(0,0,0,0.02);background-image:-webkit-linear-gradient(top, #eee, #fff);background-image:linear-gradient(to bottom, #eee, #fff)}input[type=checkbox]:checked ~ .switch-handle{left:41px;box-shadow:-1px 1px 5px rgba(0,0,0,0.2)}.rtm-tooltip{display:inline-block;margin-left:3px;position:relative}.rtm-tooltip:hover .rtm-tip-top,.rtm-tooltip:hover .rtm-tip{margin-left:0;opacity:1;visibility:visible}.rtm-tooltip .rtm-title{border-bottom:1px dotted;padding-bottom:2px}.rtm-tip-top,.rtm-tip{background:#fffAF0;border:1px solid #f5deaf;border-radius:3px;font-size:12px;left:24px;margin-top:-4px;margin-left:-10px;line-height:1.5;opacity:0;padding:6px 12px;position:absolute;top:0;visibility:hidden;width:210px;z-index:9999;-webkit-transition:all ease-in-out 0.4s;transition:all ease-in-out 0.4s}.rtm-tip-top{bottom:26px;left:auto;right:-66px;top:auto;width:200px}.rtm-tip-top:after,.rtm-tip-top:before{right:auto;top:100%;left:50%;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.rtm-tip-top:after{border-color:rgba(255,250,240,0);border-top-color:#fffAF0;border-width:6px;margin-left:-6px}.rtm-tip-top:before{border-color:rgba(245,222,175,0);border-top-color:#f5deaf;border-width:8px;margin-left:-8px}.rtm-extensions .dashicons{font-size:12px;margin-left:-4px;position:relative;top:-3px}.rtm-extensions.rtm-set-top .dashicons{top:1px}.rtm-plugin-card.plugin-card{margin:1%;overflow:hidden;width:48%}.rtm-plugin-card.plugin-card .rtm-logo{float:left;margin-right:10px;max-width:200px;width:auto}.rtm-plugin-card.plugin-card .rtm-logo img{height:auto;margin:-10px 0 0 -10px;max-width:120px}.rtm-plugin-card.plugin-card .desc,.rtm-plugin-card.plugin-card .name{margin-left:0;margin-right:0;overflow:hidden}.rtm-plugin-card.plugin-card h4{margin-bottom:0}.rtm-plugin-card.plugin-card a{text-decoration:none}.rtm-plugin-card.plugin-card .rtm-live-demo{margin-right:10px}.rtm-plugin-card.plugin-card .price{color:#269ad6;font-size:22px;line-height:1.2}#rtm-plugins .rtm-option-title{margin-top:50px}#rtm-plugins .rtm-setting-title+.rtm-option-title{margin-top:0}.rtm-encoding-table{border-collapse:collapse;clear:none}.rtm-encoding-table th,.rtm-encoding-table td{border:1px solid #e7e7e7}.rtm-encoding-table th{font-size:13px;font-weight:600}.rtm-theme-browser .rtm-themes{clear:none;padding:0}.rtm-theme-browser .rtm-themes .rtm-theme{width:48%}.rtm-theme-browser .rtm-themes .rtm-theme:nth-child(even){margin-right:0 !important}.rtm-theme-browser .rtm-themes .rtm-theme:nth-child(3n){margin-right:4%}.admin-bar .theme-overlay .theme-wrap{z-index:99999}.rtm-support-container{min-height:300px}.rtm-support-form .rtm-form-filed{clear:both;margin:15px 0}.rtm-support-form label{float:left;width:15%}.rtm-support-form .bp-media-textarea{height:80px}.rtm-button-wrapper{padding-left:15%}.rtm-page-container{background:#fff;overflow:hidden;padding:20px}.rtm-pro-feature-list li{box-sizing:border-box;float:left;padding:0 10px 20px;width:33%}.rtm-pro-feature-list .rtm-icon-wrap{float:left;margin-top:15px;width:30px}.rtm-pro-feature-list .dashicons{font-size:18px}.rtm-pro-feature-list .rtm-title{font-size:18px;margin-left:30px;margin-top:0px}.rtm-pro-feature-list .rtm-content{font-size:14px;line-height:25px;margin-left:30px;color:#8a8a8a;width:auto}.rtm-update-to-pro{text-align:center}.rtm-button{background-color:#269ad6;border:0;border-radius:3px;color:#fff;cursor:pointer;display:inline-block;font-size:13px;letter-spacing:1px;line-height:1;margin-bottom:10px;padding:12px 26px;text-align:center;text-decoration:none;text-transform:uppercase}.rtm-button:hover,.rtm-button:focus{background-color:#228ac0;color:#fff}.rtm-button.large{font-size:16px;margin-bottom:20px;padding:20px 40px}.rtm-button.rtm-button-success{background-color:#2ecc71}.rtm-button.rtm-button-success:hover,.rtm-button.rtm-button-success:focus{background-color:#2fab41}.rtm-hire-points{font-size:14px;margin-bottom:24px}@media only screen and (min-width: 1025px){.rtm-setting-container{float:left;width:78.2%}.rtm-sidebar{float:right;width:20%}.rtm-sidebar .postbox{min-width:0}.rtm-field-wrap{max-width:92%}.rtm-tip:after,.rtm-tip:before{right:100%;top:15px;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}.rtm-tip:after{border-color:rgba(255,250,240,0);border-right-color:#fffAF0;border-width:6px;margin-top:-6px}.rtm-tip:before{border-color:rgba(221,204,170,0);border-right-color:#f5deaf;border-width:7px;margin-top:-7px}.rtm-support-form .bp-media-input,.rtm-support-form .bp-media-textarea{float:left;width:40%}}@media only screen and (min-width: 641px) and (max-width: 1024px){.rtm-sidebar{width:100%}.rtm-sidebar .postbox{display:inline-block;margin-left:5px;vertical-align:top}.rtm-sidebar .postbox:first-child{margin-left:0}}@media screen and (max-width: 1024px){.rtm-tip{bottom:26px;left:auto;right:-102px;top:auto;width:200px}.rtm-tip:after,.rtm-tip:before{right:auto;top:100%;left:50%;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.rtm-tip:after{border-color:rgba(255,250,240,0);border-top-color:#fffAF0;border-width:6px;margin-left:-6px}.rtm-tip:before{border-color:rgba(245,222,175,0);border-top-color:#f5deaf;border-width:7px;margin-left:-7px}#rtmedia-custom-css-settings .form-table:last-child .rtm-field-wrap{width:100%}.rtm-field-wrap input[type=text]{max-width:140px !important}.theme-browser .theme:nth-child(2n+1){margin-right:4%}.rtmedia-settings-submit{margin-bottom:0 !important}}@media only screen and (min-width: 641px){.rtm-pro-feature-list li:nth-child(3n+1){clear:left}}@media screen and (min-width: 421px) and (max-width: 782px){.rtm-option-wrapper .form-table td{display:table-cell}.rtm-option-wrapper .form-table th{display:table-cell}}@media only screen and (max-width: 640px){.rtm-pro-feature-list li{width:50%}.rtm-pro-feature-list li:nth-child(2n+1){clear:left}.rtm-tabs{width:40px}.rtm-tabs li{width:40px}.rtm-tabs a{height:18px}.rtm-tabs a:hover{width:140px}.rtm-tabs a:hover span{display:block}.rtm-tabs span{display:none;padding:0 0 0 28px;position:absolute}.rtm-support-form label{width:100%;margin-bottom:5px}.rtm-support-form .bp-media-input,.rtm-support-form .bp-media-textarea{width:70%}.rtm-button-wrapper{padding-left:0}}@media screen and (max-width: 481px){.rtm-plugin-card.plugin-card .rtm-logo{display:inline-block;float:none}.rtm-theme-browser .rtm-themes .rtm-theme{margin:0 0 20px;width:100%}}@media screen and (max-width: 420px){.rtm-option-wrapper .form-table th{padding-bottom:15px;width:100%}#rtmedia-types .form-table th,#rtmedia-custom-css-settings .form-table th{width:100%}.rtm-pro-feature-list li{width:100%}.rtm-tip-top{right:-115px}}body.rtl .rtm-tabs a{padding:10px 32px 10px 4px}body.rtl .rtm-tabs .dashicons{right:10px}body.rtl .rtm-social-share .dashicons{left:10px;right:auto}body.rtl .rtm-option-wrapper .rtm-field-wrap{float:right}body.rtl .rtm-tip-top,body.rtl .rtm-tip{left:auto;right:24px}body.rtl .rtm-tip-top:after,body.rtl .rtm-tip-top:before,body.rtl .rtm-tip:after,body.rtl .rtm-tip:before{display:none}body.rtl .rtm-edit-td,body.rtl .rtm-delete-td{float:right;margin-left:0}body.rtl .rtm-edit-td{margin-right:-15px}body.rtl #rtmedia-membership span.float-right{float:left}body.rtl .theme-browser .theme{float:left;margin:0 4% 4% 0}.rtmedia-license .rtm-tabs span{padding:0}
|
1 |
+
.alignleft{float:left}.alignright{float:right}.aligncenter{display:block;margin-left:auto;margin-right:auto;text-align:center}.clear-both{clear:both}.clear-none{clear:none}.clear-left{clear:left}.clear-right{clear:right}.rtm-inline-block{display:inline-block}.rtm-text-left{text-align:left}.rtm-text-right{text-align:right}.rtm-text-center{text-align:center}.rtm-border-0{border:0 !important}.hide{display:none}.clearfix:after{content:"";display:table;clear:both}.rtm-row-container{padding-top:10px}.rtm-admin-tab-container{display:table;width:100%}.rtm-admin-tab-container .rtm-tabs-content{background:#fff;border-left:1px solid #e7e7e7;display:table-cell;min-height:300px;padding:20px 30px;vertical-align:top}.rtm-setting-container{background-color:#f5f5f5;border:1px solid #dedede;box-shadow:0 1px 1px rgba(0,0,0,0.04);margin-top:10px}.rtm-sidebar .postbox .hndle{cursor:default}.rtm-tabs{display:table-cell;list-style:none;margin:0;min-height:300px;width:202px}.rtm-button-container{background:#f3f3f3;border-bottom:1px solid #dedede;box-shadow:0 1px 0 #fcfcfc inset;overflow:hidden;padding:6px 10px 6px 6px;position:relative;text-align:right}.rtm-button-container.bottom{background:#eee;border-top:1px solid #e7e7e7;box-shadow:0 0 0;z-index:999}#mce-EMAIL{width:100%}#mc-embedded-subscribe{display:block;margin:10px auto 0;width:100%}.rtm-social-links a{display:inline-block;margin:4px 0 4px 4px;text-decoration:none}.nav-tab.rtm-premium{background:#e74c3c;color:white;letter-spacing:0.5px}.rtm-setting-title{border-bottom:1px solid #eee;font-size:22px;font-weight:400;line-height:1;margin-bottom:20px;margin-top:0;padding-bottom:14px;display:none}.rtm-setting-title.rtm-show{display:block}.rtm-option-wrapper{margin-bottom:40px}.rtm-option-wrapper:last-child{margin-bottom:20px}.rtm-setting-title+.rtm-option-wrapper{margin-top:0}.rtm-option-wrapper:last-child{border-bottom:0}.rtm-option-wrapper .form-table{clear:none}.rtm-option-wrapper .rtm-field-wrap{float:left}.rtm-option-wrapper a{text-decoration:none}.rtm-option-wrapper .form-table th{color:#444;font-size:13px;font-weight:400;padding:5px 30px 5px 0;vertical-align:top;width:48%}.rtm-option-wrapper .form-table td{font-size:13px;padding:0 0 5px;vertical-align:top}.rtm-option-wrapper .form-table td fieldset label{display:block;margin:0 !important}.rtm-option-wrapper .form-table .rtm-form-radio label{margin-top:5px !important}.rtm-option-wrapper textarea,.rtm-option-wrapper select,.rtm-option-wrapper input[type=text],.rtm-option-wrapper input[type=number]{border-radius:3px}.rtm-option-wrapper input[type=number]{width:60px}.rtm-option-wrapper .rt-form-radio{height:28px;line-height:24px}.rtm-option-wrapper .rt-form-radio label:first-child{margin-right:12px !important}.rtm-option-wrapper .dashicons-info{color:#aaa;font-size:14px;height:26px;line-height:26px;position:relative}.rtm-option-wrapper .rtm-debug-info{margin-top:32px}.rtm-option-wrapper .rtm-debug-info tr{border-bottom:1px solid #eee}.rtm-option-wrapper .rtm-debug-info tr:first-child{border-top:1px solid #eee}.rtm-option-wrapper .rtm-debug-info tr:nth-child(2n){background-color:#f8f8f8}.rtm-option-wrapper .rtm-debug-info th{border-right:1px solid #eee;font-weight:600;width:auto}.rtm-option-wrapper .rtm-debug-info th,.rtm-option-wrapper .rtm-debug-info td{padding:10px}.rtm-option-title{border-bottom:1px solid #eee;font-size:14px;letter-spacing:0.02rem;margin-bottom:12px;margin-top:0;padding:0 0 6px;text-transform:uppercase}.rtm-sidebar .button{display:block;opacity:0.8;position:relative;text-decoration:none}.rtm-social-share .dashicons{font-size:18px;position:absolute;right:10px;top:4px}.rtm-social-share .twitter .dashicons{color:#45b0e3}.rtm-social-share .facebook .dashicons{color:#3b5998}.rtm-social-share .wordpress .dashicons{color:#21759b}.rtm-social-share .rss .dashicons{color:#FF6600}.rtm-social-share p:last-child{margin-bottom:0}.rtm-notice{background:rgba(238,238,238,0.8);color:#777;font-size:12px;line-height:1.6;margin-top:10px;overflow:hidden;padding:0 10px}.rtm-notice p{font-size:inherit;line-height:inherit;margin:10px 0}.rtm-warning{background-color:#fcf8e3;border-bottom:1px solid #EEE;color:#c09853;padding:10px 15px}.rtmedia-theme-warning{margin-bottom:26px}.rtm-success{background-color:#dff0d8;border-bottom:1px solid #e7e7e7;color:#468847;margin:0;padding:8px 35px 8px 14px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.rtm-fly-warning{border-bottom:0;left:-10px;letter-spacing:1px;line-height:22px;margin-bottom:0;padding:14px 25px;position:absolute;top:-5px}#rtmedia-types .form-table th{line-height:26px;padding:5px 0 20px;width:33%}#rtmedia-types .form-table td{padding:0 0 12px}#rtmedia-custom-css-settings .form-table th{width:35%}#rtmedia-custom-css-settings .form-table:last-child .rtm-field-wrap{width:92%}#rtmedia-custom-css-settings textarea{height:300px;width:100%}.rtm-img-size-setting .form-table th{border-bottom:1px solid #eee;padding-bottom:10px;padding-top:10px;width:20%}.rtm-img-size-setting .form-table tr:nth-child(2) td{padding-top:20px}.rtm-img-size-setting .form-table tr:nth-child(4){border-bottom:1px solid #eee}.rtm-img-size-setting .form-table tr:nth-child(4) td{padding-bottom:20px}.rtm-img-size-setting .form-table tr:nth-child(5) td{padding-top:20px}.rtm-img-size-setting .form-table tr:nth-child(6) td{padding-bottom:20px}.rtm-img-size-setting .form-table tr:nth-child(7){border-top:1px solid #eee}.rtm-img-size-setting .form-table tr:nth-child(7) td{padding-top:20px}.rtm-img-size-setting .form-table tr:nth-last-child(2) td{padding-bottom:20px}.rtm-img-size-setting .form-table tr:last-child{border-top:1px solid #eee}.rtm-img-size-setting .form-table tr:last-child td{padding-top:20px;padding-bottom:20px}.rtm-img-size-setting .form-table .rtm-row-title{font-weight:600}#rtmedia-privacy .rt-form-radio{font-size:12px}#rtmedia-privacy .rt-form-radio strong{font-size:13px}#rtmedia-encoding-usage strong{display:inline-block;min-width:120px}#rtmedia-encoding-usage p{overflow:hidden}.encoding-used,.encoding-remaining{background:#7AD03A;float:right;height:12px;margin-top:3px;width:12px}.encoding-remaining{background:#dedede}#rtprogressbar{background:#dedede;height:10px;position:relative}#rtprogressbar div{background:#7AD03A;height:10px;left:0;position:absolute}.rtm-tabs li{margin:0}.rtm-tabs a{border-bottom:1px solid #e7e7e7;border-top:1px solid #f2f2f2;color:#222;display:block;font-weight:700;outline:none;opacity:0.8;padding:10px 4px 10px 14px;position:relative;text-decoration:none;z-index:10}.rtm-tabs a:hover{background:#eee;color:#269ad6;margin-right:0;opacity:1;width:auto}.rtm-tabs a:focus{background:#fff;box-shadow:0 0 0}.rtm-tabs .active{background:white;position:relative}.rtm-tabs .active:after{background:#fff;content:' ';height:100%;position:absolute;right:-1px;top:0;width:1px}.rtm-tabs .active a{border-top-color:#fff;color:#222;opacity:1}.rtm-tabs .active a:hover{background:#fff}.rtm-tabs span{display:block;padding:0 0 0 25px}.rtm-tabs .dashicons{font-size:14px;height:auto;line-height:1;margin-top:3px;position:absolute;vertical-align:middle;width:auto}.rtm-horizotanl-tabs .rtm-tabs{list-style:none;margin:0;display:block;width:auto;min-height:0}.rtm-horizotanl-tabs .rtm-tabs-content{border-left:none;background:#fff;min-height:300px;padding:20px 30px;vertical-align:top}.rtm-horizotanl-tabs .rtm-tabs a{border-bottom:none}.rtm-horizotanl-tabs .rtm-tabs li{display:inline-block}.rtm-horizotanl-tabs.rtm-admin-tab-container{width:100%;display:block}.switch{position:relative;display:inline-block;vertical-align:top;width:58px;height:22px;padding:3px;border-radius:18px}.switch input[type=checkbox]{position:absolute;top:0;left:0;opacity:0}.switch-label{position:relative;display:block;height:inherit;color:#fff;font-size:12px;text-transform:uppercase;background:#b4b4b4;border-radius:inherit;-webkit-transition:0.15s ease-out;transition:0.15s ease-out;-webkit-transition-property:opacity background;transition-property:opacity background}.switch-label:before,.switch-label:after{position:absolute;top:50%;margin-top:-.5em;line-height:1;-webkit-transition:inherit;transition:inherit}.switch-label:before{content:attr(data-off);right:11px;color:#fff}.switch-label:after{content:attr(data-on);left:11px;opacity:0}input[type=checkbox]:checked ~ .switch-label{background:#33a7d1}input[type=checkbox]:checked ~ .switch-label:before{opacity:0}input[type=checkbox]:checked ~ .switch-label:after{opacity:1}.switch-handle{position:absolute;top:5px;left:5px;width:18px;height:18px;background:white;border-radius:10px;box-shadow:1px 1px 5px rgba(0,0,0,0.2);background-image:-webkit-linear-gradient(top, #fff 40%, #f0f0f0);background-image:linear-gradient(to bottom, #fff 40%, #f0f0f0);-webkit-transition:left 0.15s ease-out;transition:left 0.15s ease-out}.switch-handle:before{content:'';position:absolute;top:50%;left:50%;margin:-6px 0 0 -6px;width:12px;height:12px;background:#f9f9f9;border-radius:6px;box-shadow:inset 0 1px rgba(0,0,0,0.02);background-image:-webkit-linear-gradient(top, #eee, #fff);background-image:linear-gradient(to bottom, #eee, #fff)}input[type=checkbox]:checked ~ .switch-handle{left:41px;box-shadow:-1px 1px 5px rgba(0,0,0,0.2)}.rtm-tooltip{display:inline-block;margin-left:3px;position:relative}.rtm-tooltip:hover .rtm-tip-top,.rtm-tooltip:hover .rtm-tip{margin-left:0;opacity:1;visibility:visible}.rtm-tooltip .rtm-title{border-bottom:1px dotted;padding-bottom:2px}.rtm-tip-top,.rtm-tip{background:#fffAF0;border:1px solid #f5deaf;border-radius:3px;font-size:12px;left:24px;margin-top:-4px;margin-left:-10px;line-height:1.5;opacity:0;padding:6px 12px;position:absolute;top:0;visibility:hidden;width:210px;z-index:9999;-webkit-transition:all ease-in-out 0.4s;transition:all ease-in-out 0.4s}.rtm-tip-top{bottom:26px;left:auto;right:-66px;top:auto;width:200px}.rtm-tip-top:after,.rtm-tip-top:before{right:auto;top:100%;left:50%;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.rtm-tip-top:after{border-color:rgba(255,250,240,0);border-top-color:#fffAF0;border-width:6px;margin-left:-6px}.rtm-tip-top:before{border-color:rgba(245,222,175,0);border-top-color:#f5deaf;border-width:8px;margin-left:-8px}.rtm-extensions .dashicons{font-size:12px;margin-left:-4px;position:relative;top:-3px}.rtm-extensions.rtm-set-top .dashicons{top:1px}.rtm-plugin-card.plugin-card{margin:1%;overflow:hidden;width:48%}.rtm-plugin-card.plugin-card .rtm-logo{float:left;margin-right:10px;max-width:200px;width:auto}.rtm-plugin-card.plugin-card .rtm-logo img{height:auto;max-width:120px}.rtm-plugin-card.plugin-card .desc,.rtm-plugin-card.plugin-card .name{margin-left:0;margin-right:0;overflow:hidden}.rtm-plugin-card.plugin-card h4{margin-bottom:0;margin-top:0}.rtm-plugin-card.plugin-card a{text-decoration:none}.rtm-plugin-card.plugin-card .rtm-live-demo{margin-right:10px}.rtm-plugin-card.plugin-card .price{color:#269ad6;font-size:22px;line-height:1.2}#rtm-plugins .rtm-option-title{margin-top:50px}#rtm-plugins .rtm-setting-title+.rtm-option-title{margin-top:0}#rtm-plugins .plugin-card-top{padding:10px}.rtm-encoding-table{border-collapse:collapse;clear:none}.rtm-encoding-table th,.rtm-encoding-table td{border:1px solid #e7e7e7}.rtm-encoding-table th{font-size:13px;font-weight:600}.rtm-theme-browser .rtm-themes{clear:none;padding:0}.rtm-theme-browser .rtm-themes .rtm-theme{width:48%}.rtm-theme-browser .rtm-themes .rtm-theme:nth-child(even){margin-right:0 !important}.rtm-theme-browser .rtm-themes .rtm-theme:nth-child(3n){margin-right:4%}.admin-bar .theme-overlay .theme-wrap{z-index:99999}.rtm-support-container{min-height:300px}.rtm-support-form .rtm-form-filed{clear:both;margin:15px 0}.rtm-support-form label{float:left;width:15%}.rtm-support-form .bp-media-textarea{height:80px}.rtm-button-wrapper{padding-left:15%}.rtm-page-container{background:#fff;overflow:hidden;padding:20px}.rtm-pro-feature-list li{box-sizing:border-box;float:left;padding:0 10px 20px;width:33%}.rtm-pro-feature-list .rtm-icon-wrap{float:left;margin-top:15px;width:30px}.rtm-pro-feature-list .dashicons{font-size:18px}.rtm-pro-feature-list .rtm-title{font-size:18px;margin-left:30px;margin-top:0px}.rtm-pro-feature-list .rtm-content{font-size:14px;line-height:25px;margin-left:30px;color:#8a8a8a;width:auto}.rtm-update-to-pro{text-align:center}.rtm-button{background-color:#269ad6;border:0;border-radius:3px;color:#fff;cursor:pointer;display:inline-block;font-size:13px;letter-spacing:1px;line-height:1;margin-bottom:10px;padding:12px 26px;text-align:center;text-decoration:none;text-transform:uppercase}.rtm-button:hover,.rtm-button:focus{background-color:#228ac0;color:#fff}.rtm-button.large{font-size:16px;margin-bottom:20px;padding:20px 40px}.rtm-button.rtm-button-success{background-color:#2ecc71}.rtm-button.rtm-button-success:hover,.rtm-button.rtm-button-success:focus{background-color:#2fab41}.rtm-hire-points{font-size:14px;margin-bottom:24px}@media only screen and (min-width: 1025px){.rtm-setting-container{float:left;width:78.2%}.rtm-sidebar{float:right;width:20%}.rtm-sidebar .postbox{min-width:0}.rtm-field-wrap{max-width:92%}.rtm-tip:after,.rtm-tip:before{right:100%;top:15px;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}.rtm-tip:after{border-color:rgba(255,250,240,0);border-right-color:#fffAF0;border-width:6px;margin-top:-6px}.rtm-tip:before{border-color:rgba(221,204,170,0);border-right-color:#f5deaf;border-width:7px;margin-top:-7px}.rtm-support-form .bp-media-input,.rtm-support-form .bp-media-textarea{float:left;width:40%}}@media only screen and (min-width: 641px) and (max-width: 1024px){.rtm-sidebar{width:100%}.rtm-sidebar .postbox{display:inline-block;margin-left:5px;vertical-align:top}.rtm-sidebar .postbox:first-child{margin-left:0}}@media screen and (max-width: 1024px){.rtm-tip{bottom:26px;left:auto;right:-102px;top:auto;width:200px}.rtm-tip:after,.rtm-tip:before{right:auto;top:100%;left:50%;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.rtm-tip:after{border-color:rgba(255,250,240,0);border-top-color:#fffAF0;border-width:6px;margin-left:-6px}.rtm-tip:before{border-color:rgba(245,222,175,0);border-top-color:#f5deaf;border-width:7px;margin-left:-7px}#rtmedia-custom-css-settings .form-table:last-child .rtm-field-wrap{width:100%}.rtm-field-wrap input[type=text]{max-width:140px !important}.theme-browser .theme:nth-child(2n+1){margin-right:4%}.rtmedia-settings-submit{margin-bottom:0 !important}}@media only screen and (min-width: 641px){.rtm-pro-feature-list li:nth-child(3n+1){clear:left}}@media screen and (min-width: 421px) and (max-width: 782px){.rtm-option-wrapper .form-table td{display:table-cell}.rtm-option-wrapper .form-table th{display:table-cell}}@media only screen and (max-width: 640px){.rtm-pro-feature-list li{width:50%}.rtm-pro-feature-list li:nth-child(2n+1){clear:left}.rtm-tabs{width:40px}.rtm-tabs li{width:40px}.rtm-tabs a{height:18px}.rtm-tabs a:hover{width:140px}.rtm-tabs a:hover span{display:block}.rtm-tabs span{display:none;padding:0 0 0 28px;position:absolute}.rtm-support-form label{width:100%;margin-bottom:5px}.rtm-support-form .bp-media-input,.rtm-support-form .bp-media-textarea{width:70%}.rtm-button-wrapper{padding-left:0}}@media screen and (max-width: 481px){.rtm-plugin-card.plugin-card .rtm-logo{display:inline-block;float:none}.rtm-theme-browser .rtm-themes .rtm-theme{margin:0 0 20px;width:100%}}@media screen and (max-width: 420px){.rtm-option-wrapper .form-table th{padding-bottom:15px;width:100%}#rtmedia-types .form-table th,#rtmedia-custom-css-settings .form-table th{width:100%}.rtm-pro-feature-list li{width:100%}.rtm-tip-top{right:-115px}}body.rtl .rtm-tabs a{padding:10px 32px 10px 4px}body.rtl .rtm-tabs .dashicons{right:10px}body.rtl .rtm-social-share .dashicons{left:10px;right:auto}body.rtl .rtm-option-wrapper .rtm-field-wrap{float:right}body.rtl .rtm-tip-top,body.rtl .rtm-tip{left:auto;right:24px}body.rtl .rtm-tip-top:after,body.rtl .rtm-tip-top:before,body.rtl .rtm-tip:after,body.rtl .rtm-tip:before{display:none}body.rtl .rtm-edit-td,body.rtl .rtm-delete-td{float:right;margin-left:0}body.rtl .rtm-edit-td{margin-right:-15px}body.rtl #rtmedia-membership span.float-right{float:left}body.rtl .theme-browser .theme{float:left;margin:0 4% 4% 0}.rtmedia-license .rtm-tabs span{padding:0}
|
app/assets/admin/css/sass/_addons.scss
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
|
12 |
img {
|
13 |
height: auto;
|
14 |
-
margin: -10px 0 0 -10px
|
15 |
max-width: 120px;
|
16 |
}
|
17 |
}
|
@@ -24,6 +24,7 @@
|
|
24 |
|
25 |
h4 {
|
26 |
margin-bottom: 0;
|
|
|
27 |
}
|
28 |
|
29 |
a {
|
@@ -49,6 +50,9 @@
|
|
49 |
.rtm-setting-title + .rtm-option-title {
|
50 |
margin-top: 0;
|
51 |
}
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
.rtm-encoding-table {
|
11 |
|
12 |
img {
|
13 |
height: auto;
|
14 |
+
/*margin: -10px 0 0 -10px;*/
|
15 |
max-width: 120px;
|
16 |
}
|
17 |
}
|
24 |
|
25 |
h4 {
|
26 |
margin-bottom: 0;
|
27 |
+
margin-top: 0;
|
28 |
}
|
29 |
|
30 |
a {
|
50 |
.rtm-setting-title + .rtm-option-title {
|
51 |
margin-top: 0;
|
52 |
}
|
53 |
+
.plugin-card-top {
|
54 |
+
padding: 10px;
|
55 |
+
}
|
56 |
}
|
57 |
|
58 |
.rtm-encoding-table {
|
app/assets/admin/js/admin.min.js
CHANGED
@@ -2,4 +2,4 @@
|
|
2 |
* rtMedia JavaScript Library
|
3 |
* @package rtMedia
|
4 |
*/
|
5 |
-
function rtmedia_addon_do_not_show(){var a={action:"rtmedia_addon_popup_not_show_again"};jQuery.post(rtmedia_admin_ajax,a,function(a){jQuery("#TB_window").remove(),jQuery("#TB_overlay").remove()})}"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a,b,c,d){var e={init:function(b,c){var d=this;d.elem=c,d.$elem=a(c),d.options=a.extend({},a.fn.rtTab.options,b),d.rtTabs()},rtTabs:function(){var c=this,d=c.options.activeTab;c.$elem.find("li:nth-child("+d+")").addClass("active"),c.rtTabContent(activeTabContent="yes"),c.rtClick();var e="false"!==c.$elem.attr("data-hash");if(e===!0){var f=b.location.hash;f&&c.$elem.find("li").find('a[href="'+f+'"]').trigger("click"),a(b).on("hashchange",function(){var a=b.location.hash;c.$elem.find("li").find('a[href="'+a+'"]').trigger("click")})}},rtClick:function(){var c=this,d=c.$elem.find("li"),e=d.find("a");e.on("click",function(e){e.preventDefault(),d.removeClass("active"),c.rtTabContent(),a(this).parent().addClass("active");var f=a(this).attr("href");a(f).removeClass("hide");var g="false"!==c.$elem.attr("data-hash");if(g===!0){var h=a(b).scrollTop();location.hash=a(this).attr("href"),a(b).scrollTop(h)}"function"==typeof c.options.onComplete&&c.options.onComplete.apply(c.elem,arguments)})},rtTabContent:function(b){var c=this,d=c.$elem.find("li"),e=d.find("a");e.each(function(){var c=a(this),d=c.attr("href");"yes"===b?c.parent().hasClass("active")||a(d).addClass("hide"):a(d).addClass("hide")})}};a.fn.rtTab=function(b){return this.each(function(){var c=Object.create(e);c.init(b,this),a.data(this,"rtTab",c)})},a.fn.rtTab.options={activeTab:1,onComplete:null}}(jQuery,window,document),jQuery(document).ready(function(a){a(".rtm-tabs").rtTab(),a('input[name^="rtmedia-options"]').on("change",function(){a(".rtm-save-settings-msg").remove(),0===a(".rtm-fly-warning").length&&(a(".rtm-button-container.top").prepend('<div class="rtm-warning rtm-fly-warning hide">Settings have changed, you should save them!</div>'),a(".rtm-fly-warning").slideDown())}),a(".rtm-img-size-setting .form-table tr:nth-child(7) td:last-child").attr("colspan","3"),a(".rtm-field-wrap .switch input[type=checkbox]").each(function(){var b=a(this);b.parents("table").attr("data-depends")||(b.is(":checked")?(b.parents("table").next(".rtm-notice").slideDown(),b.parents("table").siblings("table").each(function(){a(this).attr("data-depends")&&a(this).slideDown()})):(b.parents("table").next(".rtm-notice").slideUp(),b.parents("table").siblings("table").each(function(){a(this).attr("data-depends")&&a(this).slideUp()}))),b.parents("tr").next("tr").attr("data-depends")&&(b.is(":checked")?b.parents("tr").next("tr").slideDown():b.parents("tr").next("tr").slideUp())}),a(".rtm-field-wrap .switch input[type=checkbox]").on("change",function(){var b=a(this);b.parents("table").attr("data-depends")||(b.parents("table").next(".rtm-notice").slideToggle(),b.parents("table").siblings("table").each(function(){a(this).attr("data-depends")&&a(this).slideToggle()})),b.parents("tr").next("tr").attr("data-depends")&&b.parents("tr").next("tr").slideToggle()});var b=Backbone.View.extend({el:a(".bp-media-admin"),events:{"click .rtm-theme":"render","click .rtm-close":"close","click .rtm-previous":"previousTheme","click .rtm-next":"nextTheme",keyup:"keyEvent"},initialize:function(){_.bindAll(this,"render","close","nextTheme","previousTheme","keyEvent"),this.keyEvent()},render:function(b){a(".rtm-theme").removeClass("rtm-modal-open");var c=a(b.currentTarget).addClass("rtm-modal-open").find(".rtm-theme-content").html();a(".rtm-theme-overlay")[0]?(a(".rtm-theme-overlay").show(),a(this.el).find(".rtm-theme-content-wrap").empty().append(c)):a(this.el).append('<div class="theme-overlay rtm-theme-overlay"><div class="theme-backdrop rtm-close"></div><div class="rtm-theme-content-wrap">'+c+"</div></div>"),a(b.currentTarget).is(":first-child")?a(".rtm-previous").addClass("disabled"):a(b.currentTarget).is(":last-child")?a(".rtm-next").addClass("disabled"):a(".rtm-next, .rtm-previous").removeClass("disabled")},close:function(){a(".rtm-theme").removeClass("rtm-modal-open"),a(".rtm-theme-overlay").hide(),a(".rtm-next, .rtm-previous").removeClass("disabled")},nextTheme:function(b){return a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:last-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").next().trigger("click"),!1},previousTheme:function(b){return a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:first-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").prev().trigger("click"),!1},keyEvent:function(){a("body").on("keyup",function(b){return 39===b.keyCode?(a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:last-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").next().trigger("click"),!1):37===b.keyCode?(a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:first-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").prev().trigger("click"),!1):void(27===b.keyCode&&a(".rtm-close").trigger("click"))})}});new b}),jQuery(document).ready(function(a){function b(a){return jQuery.post(ajaxurl,a,function(b){if(0!=b){var c=!1,d=Math.ceil((20*parseInt(b)+parseInt(a.values.finished))/parseInt(a.values.total)*100);d>100&&(d=100,c=!0),jQuery("#rtprogressbar>div").css("width",d+"%"),finished=jQuery("#rtprivacyinstaller span.finished").html(),jQuery("#rtprivacyinstaller span.finished").html(parseInt(finished)+a.count),c&&jQuery.post(ajaxurl,{action:"rtmedia_privacy_redirect"},function(a){window.location=settings_url})}else jQuery("#map_progress_msgs").html('<div class="map_mapping_failure">Row '+b+" failed.</div>")})}function c(a){return jQuery.getJSON(ajaxurl,a,function(b){if(favorites=!1,b){var c=Math.ceil((5*parseInt(b.page)+parseInt(a.values.finished))/parseInt(a.values.total)*100);comments_total=jQuery("#bpmedia-bpalbumimporter .bp-album-comments span.total").html(),users_total=jQuery("#bpmedia-bpalbumimporter .bp-album-users span.total").html(),media_total=jQuery("#bpmedia-bpalbumimporter .bp-album-media span.total").html(),comments_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-comments span.finished").html(),users_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-users span.finished").html();var f=Math.ceil((parseInt(b.comments)+parseInt(comments_finished))/parseInt(comments_total)*100),g=Math.ceil(parseInt(b.users)/parseInt(users_total)*100);(c>100||100==c)&&(c=100,favorites=!0),jQuery(".bp-album-media #rtprogressbar>div").css("width",c+"%"),jQuery(".bp-album-comments #rtprogressbar>div").css("width",f+"%"),jQuery(".bp-album-users #rtprogressbar>div").css("width",g+"%"),media_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-media span.finished").html(),parseInt(media_finished)<parseInt(media_total)&&jQuery("#bpmedia-bpalbumimporter .bp-album-media span.finished").html(parseInt(media_finished)+a.count),jQuery("#bpmedia-bpalbumimporter .bp-album-comments span.finished").html(parseInt(b.comments)+parseInt(comments_finished)),jQuery("#bpmedia-bpalbumimporter .bp-album-users span.finished").html(parseInt(b.users)),favorites&&(favorite_data={action:"rtmedia_rt_album_import_favorites"},jQuery.post(ajaxurl,favorite_data,function(a){if(0!==a.favorites||"0"!==a.favorites){jQuery(".bp-album-favorites").length||jQuery(".bp-album-comments").after('<br /><div class="bp-album-favorites"><strong>User\'s Favorites: <span class="finished">0</span> / <span class="total">'+a.users+'</span></strong><div id="rtprogressbar"><div style="width:0%"></div></div></div>'),$favorites={},0!=a.offset||"0"!=a.offset?start=1*a.offset+1:start=1;for(var b=start;b<=a.users;b++)$count=1,b==a.users&&($count=parseInt(a.users%$count),0==$count&&($count=1)),newvals={action:"rtmedia_rt_album_import_step_favorites",offset:1*(b-1),redirect:b==a.users},$favorites[b]=newvals;var c=jQuery.Deferred();c.resolve(),jQuery.each($favorites,function(a,b){c=c.pipe(function(){return d(b)})})}else window.setTimeout(e,2e3)},"json"))}else jQuery("#map_progress_msgs").html('<div class="map_mapping_failure">Row '+b.page+" failed.</div>")})}function d(a){return jQuery.post(ajaxurl,a,function(a){redirect=!1,favorites_total=jQuery("#bpmedia-bpalbumimporter .bp-album-favorites span.total").html(),favorites_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-favorites span.finished").html(),jQuery("#bpmedia-bpalbumimporter .bp-album-favorites span.finished").html(parseInt(favorites_finished)+1);var b=Math.ceil(parseInt(favorites_finished+1)/parseInt(favorites_total)*100);(b>100||100==b)&&(b=100,redirect=!0),jQuery(".bp-album-favorites #rtprogressbar>div").css("width",b+"%"),redirect&&window.setTimeout(e,2e3)})}function e(){window.location=document.URL}a(".rtm-save-settings-msg").length>0&&setTimeout(function(){a(".rtm-save-settings-msg").remove()},1e4),jQuery("#spread-the-word").on("click","#bp-media-add-linkback",function(){var a={action:"rtmedia_linkback",linkback:jQuery("#bp-media-add-linkback:checked").length};jQuery.post(rtmedia_admin_ajax,a,function(a){})}),jQuery("#bp-media-settings-boxes").on("change","#select-request",function(){if(jQuery(this).val()){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html('<div class="support_form_loader"></div>');var a={action:"rtmedia_select_request",form:jQuery(this).val()};jQuery.post(ajaxurl,a,function(a){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(a).fadeIn("slow")})}}),jQuery("#bp-media-settings-boxes").on("click","#cancel-request",function(){if(jQuery(this).val()){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html('<div class="support_form_loader"></div>');var a={action:"rtmedia_cancel_request"};jQuery.post(ajaxurl,a,function(a){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(a).fadeIn("slow")})}}),jQuery("#bp-media-settings-boxes").on("submit","#bp_media_settings_form, .rtmedia-settings-submit",function(a){var b=!0,c=new RegExp("^[0-9]+$");jQuery("input[name*='defaultSizes']").each(function(a){return c.test(jQuery(this).val())?void 0:(alert("Invalid value for "+jQuery(this).attr("name").replace("rtmedia-options[defaultSizes_","").replace("]","").replace(/_/g," ").replace(/(\b)([a-zA-Z] )/g,function(a){return a.toUpperCase()})),b=!1,!1)});var d=jQuery('input[name^="rtmedia-options[general_videothumbs]"]');if(b&&d.length>0&&"undefined"!=typeof d){var e="",f=0;if(d.val()<=0?(e+="Number of video thumbnails to be generated should be greater than 0 in media sizes settings. Setting it to default value 2.",f=2):c.test(d.val())||(e+="Invalid value for Number of video thumbnails in media sizes settings. Setting it to round value "+Math.round(d.val())+".",f=Math.round(d.val())),""!=e)return alert(e),d.val(f),b=!1,!1}var g=jQuery('input[name^="rtmedia-options[general_jpeg_image_quality]"]');if(b&&g.length>0&&"undefined"!=typeof g){var e="",h=0;if(g.val()<=0?(e+="Number of percentage in JPEG image quality should be greater than 0 in media sizes settings. Setting it to default value 90.",h=90):g.val()>100?(e+="Number of percentage in JPEG image quality should be less than 100 in media sizes settings. Setting it to 100.",h=100):c.test(g.val())||(e+="Invalid value for percentage in JPEG image quality in media sizes settings. Setting it to round value "+Math.round(g.val())+".",h=Math.round(g.val())),""!=e)return alert(e),g.val(h),b=!1,!1}var i=jQuery('input[name^="rtmedia-options[general_perPageMedia]"]');if(b&&i.length>0&&"undefined"!=typeof i){var e="",j=0;if(i.val()<1?(e+="Please enter positive integer value only. Setting number of media per page value to default value 10.",j=10):jQuery.isNumeric(i.val())&&Math.floor(i.val())!=i.val()&&(e+="Please enter positive integer value only. Setting number of media per page value to round value "+Math.round(i.val())+".",j=Math.round(i.val())),""!=e)return alert(e),i.val(j),b=!1,!1}b||a.preventDefault()}),jQuery(document).on("click","#bpm-services .encoding-try-now,#rtm-services .encoding-try-now",function(a){if(a.preventDefault(),confirm(rtmedia_admin_strings.are_you_sure)){jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+rtmedia_admin_url+'images/wpspin_light.gif" />');var b={action:"rtmedia_free_encoding_subscribe"};jQuery.getJSON(ajaxurl,b,function(a){if(void 0===a.error&&a.apikey){var b=window.location.href,c=window.location.hash;b=b.replace(c,""),document.location.href=b+"&apikey="+a.apikey+c}else jQuery(".encoding-try-now").next().remove(),jQuery("#settings-error-encoding-error").remove(),jQuery("#bp-media-settings-boxes").before('<div class="error" id="settings-error-encoding-error"><p>'+a.error+"</p></div>")})}}),jQuery(document).on("click","#api-key-submit",function(a){a.preventDefault(),0==jQuery(this).next("img").length&&jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+rtmedia_admin_url+'images/wpspin_light.gif" />');var b={action:"rtmedia_enter_api_key",apikey:jQuery("#new-api-key").val()};jQuery.getJSON(ajaxurl,b,function(a){if(void 0===a.error&&a.apikey){var b=window.location.href,c=window.location.hash;b=b.replace(c,""),-1==b.toString().indexOf("&apikey="+a.apikey)&&(b+="&apikey="+a.apikey),-1==b.toString().indexOf("&update=true")&&(b+="&update=true"),document.location.href=b+c}else jQuery("#settings-error-api-key-error").remove(),jQuery("h2:first").after('<div class="error" id="settings-error-api-key-error"><p>'+a.error+"</p></div>");jQuery("#api-key-submit").next("img").remove()})}),jQuery(document).on("click","#disable-encoding",function(a){if(a.preventDefault(),confirm(rtmedia_admin_strings.disable_encoding)){jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+rtmedia_admin_url+'images/wpspin_light.gif" />');var b={action:"rtmedia_disable_encoding"};jQuery.post(ajaxurl,b,function(a){a?(jQuery(".settings-error-encoding-disabled").remove(),jQuery("#settings-encoding-successfully-updated").length>0?jQuery("#settings-encoding-successfully-updated p").html(a):jQuery("h2:first").after('<div class="updated" id="settings-encoding-successfully-updated"><p>'+a+"</p></div>"),jQuery("#rtmedia-encoding-usage").hide(),jQuery("#disable-encoding").next("img").remove(),jQuery("#disable-encoding").hide(),jQuery("#enable-encoding").show()):(jQuery("#settings-error-encoding-disabled").remove(),jQuery("h2:first").after('<div class="error" id="settings-error-encoding-disabled"><p>'+rtmedia_admin_strings.something_went_wrong+"</p></div>"))})}}),jQuery(document).on("click","#enable-encoding",function(a){if(a.preventDefault(),confirm(rtmedia_admin_strings.enable_encoding)){jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+rtmedia_admin_url+'images/wpspin_light.gif" />');var b={action:"rtmedia_enable_encoding"};jQuery.post(ajaxurl,b,function(a){a?(jQuery(".settings-error-encoding-enabled").remove(),jQuery("#settings-encoding-successfully-updated").length>0?jQuery("#settings-encoding-successfully-updated p").html(a):jQuery("h2:first").after('<div class="updated" id="settings-encoding-successfully-updated"><p>'+a+"</p></div>"),jQuery("#enable-encoding").next("img").remove(),jQuery("#enable-encoding").hide(),jQuery("#disable-encoding").show()):(jQuery("#settings-error-encoding-disabled").remove(),jQuery("h2:first").after('<div class="error" id="settings-error-encoding-enabled"><p>'+rtmedia_admin_strings.something_went_wrong+"</p></div>"))})}}),jQuery(".bp-media-encoding-table").on("click",".bpm-unsubscribe",function(a){a.preventDefault(),jQuery("#bpm-unsubscribe-dialog").dialog({dialogClass:"wp-dialog",modal:!0,buttons:{Unsubscribe:function(){jQuery(this).dialog("close"),jQuery(".bpm-unsubscribe").after('<img style="margin: 0 0 0 10px" src="'+rtmedia_admin_url+'images/wpspin_light.gif" />');var a={action:"rtmedia_unsubscribe_encoding_service",note:jQuery("#bpm-unsubscribe-note").val(),plan:jQuery(".bpm-unsubscribe").attr("data-plan"),price:jQuery(".bpm-unsubscribe").attr("data-price")};jQuery.getJSON(ajaxurl,a,function(a){void 0===a.error&&a.updated?(jQuery(".bpm-unsubscribe").next().remove(),jQuery(".bpm-unsubscribe").after(a.form),jQuery(".bpm-unsubscribe").remove(),jQuery("#settings-unsubscribed-successfully").remove(),jQuery("#settings-unsubscribe-error").remove(),jQuery("h2:first").after('<div class="updated" id="settings-unsubscribed-successfully"><p>'+a.updated+"</p></div>"),window.location.hash="#settings-unsubscribed-successfully"):(jQuery(".bpm-unsubscribe").next().remove(),jQuery("#settings-unsubscribed-successfully").remove(),jQuery("#settings-unsubscribe-error").remove(),jQuery("h2:first").after('<div class="error" id="settings-unsubscribe-error"><p>'+a.error+"</p></div>"),window.location.hash="#settings-unsubscribe-error")})}}})}),jQuery("#bpmedia-bpalbumimporter").on("change","#bp-album-import-accept",function(){jQuery(".bp-album-import-accept").toggleClass("i-accept"),jQuery(".bp-album-importer-wizard").slideToggle()}),jQuery("#rtprivacyinstall").click(function(a){a.preventDefault(),$progress_parent=jQuery("#rtprivacyinstaller"),$progress_parent.find(".rtprivacytype").each(function(){if($type=jQuery(this).attr("id"),"total"==$type){$values=[],jQuery(this).find("input").each(function(){$values[jQuery(this).attr("name")]=[jQuery(this).val()]}),$data={};for(var a=1;a<=$values.steps[0];a++)$count=20,a==$values.steps[0]&&($count=parseInt($values.laststep[0]),0==$count&&($count=20)),newvals={page:a,action:"rtmedia_privacy_install",count:$count,values:$values},$data[a]=newvals;var c=jQuery.Deferred();c.resolve(),jQuery.each($data,function(a,d){c=c.pipe(function(){return b(d)})})}})}),jQuery("#bpmedia-bpalbumimport-cleanup").click(function(a){a.preventDefault(),jQuery.post(ajaxurl,{action:"rtmedia_rt_album_cleanup"},function(a){window.location=settings_rt_album_import_url})}),jQuery("#bpmedia-bpalbumimporter").on("click","#bpmedia-bpalbumimport",function(a){if(a.preventDefault(),!jQuery("#bp-album-import-accept").prop("checked")){jQuery("html, body").animate({scrollTop:jQuery("#bp-album-import-accept").offset().top},500);var b=jQuery(".bp-album-import-accept"),d=500,e="#FFEBE8",f=3;return void function h(){b.css("background-color","#EE0000"),setTimeout(function(){b.css("background-color",e),--f&&setTimeout(h,d)},d)}()}jQuery(this).prop("disabled",!0),wp_admin_url=ajaxurl.replace("admin-ajax.php",""),jQuery(".bpm-ajax-loader").length||jQuery(this).after(' <img class="bpm-ajax-loader" src="'+wp_admin_url+'images/wpspin_light.gif" /> <strong>'+rtmedia_admin_strings.no_refresh+"</strong>"),$progress_parent=jQuery("#bpmedia-bpalbumimport"),$values=[],jQuery(this).parent().find("input").each(function(){$values[jQuery(this).attr("name")]=[jQuery(this).val()]}),0==$values.steps[0]&&($values.steps[0]=1),$data={};for(var f=1;f<=$values.steps[0];f++)$count=5,f==$values.steps[0]&&($count=parseInt($values.laststep[0]),0==$count&&($count=5)),newvals={page:f,action:"rtmedia_rt_album_import",count:$count,values:$values},$data[f]=newvals;var g=jQuery.Deferred();g.resolve(),jQuery.each($data,function(a,b){g=g.pipe(function(){return c(b)})})}),jQuery("#bp-media-settings-boxes").on("click",".interested",function(){jQuery(".interested-container").removeClass("hidden"),jQuery(".choice-free").attr("required","required")}),jQuery("#bp-media-settings-boxes").on("click",".not-interested",function(){jQuery(".interested-container").addClass("hidden"),jQuery(".choice-free").removeAttr("required")}),jQuery("#video-transcoding-main-container").on("click",".video-transcoding-survey",function(a){a.preventDefault();var b={action:"rtmedia_convert_videos_form",email:jQuery(".email").val(),url:jQuery(".url").val(),choice:jQuery('input[name="choice"]:checked').val(),interested:jQuery('input[name="interested"]:checked').val()};return jQuery.post(ajaxurl,b,function(a){jQuery("#video-transcoding-main-container").html("<p><strong>"+a+"</strong></p>")}),!1}),jQuery("#bpmedia-bpalbumimporter").on("click",".deactivate-bp-album",function(a){a.preventDefault(),$bpalbum=jQuery(this);var b={action:"rtmedia_rt_album_deactivate"};jQuery.get(ajaxurl,b,function(a){a?location.reload():$bpalbum.parent().after("<p>"+rtmedia_admin_strings.something_went_wrong+"</p>")})}),jQuery(".updated").on("click",".bpm-hide-encoding-notice",function(){jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+rtmedia_admin_url+'images/wpspin_light.gif" />');var a={action:"rtmedia_hide_encoding_notice"};jQuery.post(ajaxurl,a,function(a){a&&jQuery(".bpm-hide-encoding-notice").closest(".updated").remove()})}),jQuery("#rtmedia-bp-enable-activity").is(":checked")?jQuery(".rtmedia-bp-activity-setting").prop("readonly",!1):jQuery(".rtmedia-bp-activity-setting").prop("readonly",!0),jQuery("#rtmedia-bp-enable-activity").on("click",function(a){jQuery(this).is(":checked")?jQuery(".rtmedia-bp-activity-setting").prop("readonly",!1):jQuery(".rtmedia-bp-activity-setting").prop("readonly",!0)});var f="",g="";void 0!==rtmedia_on_label&&(f='data-on-label="'+rtmedia_on_label+'"'),void 0!==rtmedia_off_label&&(g='data-off-label="'+rtmedia_off_label+'"'),jQuery("#rtmedia-submit-request").click(function(){var b=jQuery("#name").val(),c=jQuery("#email").val(),d=jQuery("#website").val(),e=jQuery("#phone").val(),f=jQuery("#subject").val(),g=jQuery("#details").val(),h=jQuery('input[name="request_type"]').val(),i=jQuery('input[name="request_id"]').val(),j=jQuery('input[name="server_address"]').val(),k=jQuery('input[name="ip_address"]').val(),l=jQuery('input[name="server_type"]').val(),m=jQuery('input[name="user_agent"]').val(),n={name:b,email:c,website:d,phone:e,subject:f,details:g,request_id:i,request_type:"premium_support",server_address:j,ip_address:k,server_type:l,user_agent:m};if("bug_report"==h){var o=jQuery("#wp_admin_username").val();if(""==o)return alert("Please enter WP Admin Login."),!1;var p=jQuery("#wp_admin_pwd").val();if(""==p)return alert("Please enter WP Admin password."),!1;var q=jQuery("#ssh_ftp_host").val();if(""==q)return alert("Please enter SSH / FTP host."),!1;var r=jQuery("#ssh_ftp_username").val();if(""==r)return alert("Please enter SSH / FTP login."),!1;var s=jQuery("#ssh_ftp_pwd").val();if(""==s)return alert("Please enter SSH / FTP password."),!1;n={name:b,email:c,website:d,phone:e,subject:f,details:g,request_id:i,request_type:"premium_support",server_address:j,ip_address:k,server_type:l,user_agent:m,wp_admin_username:o,wp_admin_pwd:p,ssh_ftp_host:q,ssh_ftp_username:r,ssh_ftp_pwd:s}}for(formdata in n)if(""==n[formdata]&&"phone"!=formdata)return alert("Please enter "+formdata.replace("_"," ")+" field."),!1;return data={action:"rtmedia_submit_request",form_data:n},jQuery.post(ajaxurl,data,function(b){return b=b.trim(),"false"==b?(alert("Please fill all the fields."),!1):(a("#rtmedia_service_contact_container").empty(),void a("#rtmedia_service_contact_container").append(b))}),!1}),jQuery("#cancel-request").click(function(){return!1}),jQuery(".rtm_enable_masonry_view input[type=checkbox]").is(":checked")?jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").show():jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").hide(),jQuery(".rtm_enable_masonry_view input[type=checkbox]").on("click",function(a){jQuery(this).is(":checked")?jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").show():jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").hide()}),jQuery("#rtm-masonry-change-thumbnail-info").click(function(a){jQuery("html, body").animate({scrollTop:0},"500","swing")})}),jQuery(window).load(function(){jQuery(".rtmedia-addon-thickbox").trigger("click")});
|
2 |
* rtMedia JavaScript Library
|
3 |
* @package rtMedia
|
4 |
*/
|
5 |
+
function rtmedia_addon_do_not_show(){var a={action:"rtmedia_addon_popup_not_show_again"};jQuery.post(rtmedia_admin_ajax,a,function(a){jQuery("#TB_window").remove(),jQuery("#TB_overlay").remove()})}"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a,b,c,d){var e={init:function(b,c){var d=this;d.elem=c,d.$elem=a(c),d.options=a.extend({},a.fn.rtTab.options,b),d.rtTabs()},rtTabs:function(){var c=this,d=c.options.activeTab;c.$elem.find("li:nth-child("+d+")").addClass("active"),c.rtTabContent(activeTabContent="yes"),c.rtClick();var e="false"!==c.$elem.attr("data-hash");if(e===!0){var f=b.location.hash;f&&c.$elem.find("li").find('a[href="'+f+'"]').trigger("click"),a(b).on("hashchange",function(){var a=b.location.hash;c.$elem.find("li").find('a[href="'+a+'"]').trigger("click")})}},rtClick:function(){var c=this,d=c.$elem.find("li"),e=d.find("a");e.on("click",function(e){e.preventDefault(),d.removeClass("active"),c.rtTabContent(),a(this).parent().addClass("active");var f=a(this).attr("href");a(f).removeClass("hide");var g="false"!==c.$elem.attr("data-hash");if(g===!0){var h=a(b).scrollTop();location.hash=a(this).attr("href"),a(b).scrollTop(h)}"function"==typeof c.options.onComplete&&c.options.onComplete.apply(c.elem,arguments)})},rtTabContent:function(b){var c=this,d=c.$elem.find("li"),e=d.find("a");e.each(function(){var c=a(this),d=c.attr("href");"yes"===b?c.parent().hasClass("active")||a(d).addClass("hide"):a(d).addClass("hide")})}};a.fn.rtTab=function(b){return this.each(function(){var c=Object.create(e);c.init(b,this),a.data(this,"rtTab",c)})},a.fn.rtTab.options={activeTab:1,onComplete:null}}(jQuery,window,document),jQuery(document).ready(function(a){var b=document.createElement("div");b.setAttribute("class","rtm-warning rtm-fly-warning hide"),a(".rtm-tabs").rtTab(),a('input[name^="rtmedia-options"]').on("change",function(){a(".rtm-save-settings-msg").remove(),0===a(".rtm-fly-warning").length&&(b.innerText="Settings have changed, you should save them!",a(".rtm-button-container.top").prepend(b),a(".rtm-fly-warning").slideDown())}),a(".rtm-img-size-setting .form-table tr:nth-child(7) td:last-child").attr("colspan","3"),a(".rtm-field-wrap .switch input[type=checkbox]").each(function(){var b=a(this);b.parents("table").attr("data-depends")||(b.is(":checked")?(b.parents("table").next(".rtm-notice").slideDown(),b.parents("table").siblings("table").each(function(){a(this).attr("data-depends")&&a(this).slideDown()})):(b.parents("table").next(".rtm-notice").slideUp(),b.parents("table").siblings("table").each(function(){a(this).attr("data-depends")&&a(this).slideUp()}))),b.parents("tr").next("tr").attr("data-depends")&&(b.is(":checked")?b.parents("tr").next("tr").slideDown():b.parents("tr").next("tr").slideUp())}),a(".rtm-field-wrap .switch input[type=checkbox]").on("change",function(){var b=a(this);b.parents("table").attr("data-depends")||(b.parents("table").next(".rtm-notice").slideToggle(),b.parents("table").siblings("table").each(function(){a(this).attr("data-depends")&&a(this).slideToggle()})),b.parents("tr").next("tr").attr("data-depends")&&b.parents("tr").next("tr").slideToggle()});var c=Backbone.View.extend({el:a(".bp-media-admin"),events:{"click .rtm-theme":"render","click .rtm-close":"close","click .rtm-previous":"previousTheme","click .rtm-next":"nextTheme",keyup:"keyEvent"},initialize:function(){_.bindAll(this,"render","close","nextTheme","previousTheme","keyEvent"),this.keyEvent()},render:function(b){a(".rtm-theme").removeClass("rtm-modal-open");var c=a(b.currentTarget).addClass("rtm-modal-open").find(".rtm-theme-content").html();if(a(".rtm-theme-overlay")[0])a(".rtm-theme-overlay").show(),a(this.el).find(".rtm-theme-content-wrap").empty().append(c);else{var d={themeContent:c};a(this.el).append(rtMediaAdmin.templates.rtm_theme_overlay(d))}a(b.currentTarget).is(":first-child")?a(".rtm-previous").addClass("disabled"):a(b.currentTarget).is(":last-child")?a(".rtm-next").addClass("disabled"):a(".rtm-next, .rtm-previous").removeClass("disabled")},close:function(){a(".rtm-theme").removeClass("rtm-modal-open"),a(".rtm-theme-overlay").hide(),a(".rtm-next, .rtm-previous").removeClass("disabled")},nextTheme:function(b){return a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:last-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").next().trigger("click"),!1},previousTheme:function(b){return a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:first-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").prev().trigger("click"),!1},keyEvent:function(){a("body").on("keyup",function(b){return 39===b.keyCode?(a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:last-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").next().trigger("click"),!1):37===b.keyCode?(a(".rtm-next, .rtm-previous").removeClass("disabled"),a(".rtm-theme:first-child").hasClass("rtm-modal-open")&&a(b.currentTarget).addClass("disabled"),a(".rtm-modal-open").prev().trigger("click"),!1):void(27===b.keyCode&&a(".rtm-close").trigger("click"))})}});new c});var rtMediaAdmin=new Object;rtMediaAdmin.templates={rtm_image:wp.template("rtm-image"),rtm_msg_div:wp.template("rtm-msg-div"),rtm_album_favourites_importer:wp.template("rtm-album-favourites-importer"),rtm_map_mapping_failure:wp.template("rtm-map-mapping-failure"),rtm_p_tag:wp.template("rtm-p-tag"),rtm_theme_overlay:wp.template("rtm-theme-overlay")},jQuery(document).ready(function(a){function b(a){return jQuery.post(ajaxurl,a,function(b){if(0!=b){var c=!1,d=Math.ceil((20*parseInt(b)+parseInt(a.values.finished))/parseInt(a.values.total)*100);d>100&&(d=100,c=!0),jQuery("#rtprogressbar>div").css("width",d+"%"),finished=jQuery("#rtprivacyinstaller span.finished").html(),jQuery("#rtprivacyinstaller span.finished").html(parseInt(finished)+a.count),c&&jQuery.post(ajaxurl,{action:"rtmedia_privacy_redirect"},function(a){window.location=settings_url})}else{var e={msg:"Row "+b+" failed."};jQuery("#map_progress_msgs").html(rtMediaAdmin.templates.rtm_map_mapping_failure(e))}})}function c(a){return jQuery.getJSON(ajaxurl,a,function(b){if(favorites=!1,b){var c=Math.ceil((5*parseInt(b.page)+parseInt(a.values.finished))/parseInt(a.values.total)*100);comments_total=jQuery("#bpmedia-bpalbumimporter .bp-album-comments span.total").html(),users_total=jQuery("#bpmedia-bpalbumimporter .bp-album-users span.total").html(),media_total=jQuery("#bpmedia-bpalbumimporter .bp-album-media span.total").html(),comments_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-comments span.finished").html(),users_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-users span.finished").html();var f=Math.ceil((parseInt(b.comments)+parseInt(comments_finished))/parseInt(comments_total)*100),g=Math.ceil(parseInt(b.users)/parseInt(users_total)*100);(c>100||100==c)&&(c=100,favorites=!0),jQuery(".bp-album-media #rtprogressbar>div").css("width",c+"%"),jQuery(".bp-album-comments #rtprogressbar>div").css("width",f+"%"),jQuery(".bp-album-users #rtprogressbar>div").css("width",g+"%"),media_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-media span.finished").html(),parseInt(media_finished)<parseInt(media_total)&&jQuery("#bpmedia-bpalbumimporter .bp-album-media span.finished").html(parseInt(media_finished)+a.count),jQuery("#bpmedia-bpalbumimporter .bp-album-comments span.finished").html(parseInt(b.comments)+parseInt(comments_finished)),jQuery("#bpmedia-bpalbumimporter .bp-album-users span.finished").html(parseInt(b.users)),favorites&&(favorite_data={action:"rtmedia_rt_album_import_favorites",rtm_wpnonce:jQuery("#bpaimporter_wpnonce").val()},jQuery.post(ajaxurl,favorite_data,function(a){if(!a.hasOwnProperty(favorites)||0===a.favorites&&"0"===a.favorites)window.setTimeout(e,2e3);else{if(!jQuery(".bp-album-favorites").length){var b={users:a.users};jQuery(".bp-album-comments").after(rtMediaAdmin.templates.rtm_album_favourites_importer(b))}$favorites={},0!=a.offset||"0"!=a.offset?start=1*a.offset+1:start=1;for(var c=start;c<=a.users;c++)$count=1,c==a.users&&($count=parseInt(a.users%$count),0==$count&&($count=1)),newvals={action:"rtmedia_rt_album_import_step_favorites",offset:1*(c-1),redirect:c==a.users,rtm_wpnonce:jQuery("#bpaimporter_wpnonce").val()},$favorites[c]=newvals;var f=jQuery.Deferred();f.resolve(),jQuery.each($favorites,function(a,b){f=f.pipe(function(){return d(b)})})}},"json"))}else if(a.hasOwnProperty(page)){var h={msg:"Row "+b.page+" failed."};jQuery("#map_progress_msgs").html(rtMediaAdmin.templates.rtm_map_mapping_failure(h))}else{var h={msg:"Request failed."};jQuery("#map_progress_msgs").html(rtMediaAdmin.templates.rtm_map_mapping_failure(h))}})}function d(a){return jQuery.post(ajaxurl,a,function(a){redirect=!1,favorites_total=jQuery("#bpmedia-bpalbumimporter .bp-album-favorites span.total").html(),favorites_finished=jQuery("#bpmedia-bpalbumimporter .bp-album-favorites span.finished").html(),jQuery("#bpmedia-bpalbumimporter .bp-album-favorites span.finished").html(parseInt(favorites_finished)+1);var b=Math.ceil(parseInt(favorites_finished+1)/parseInt(favorites_total)*100);(b>100||100==b)&&(b=100,redirect=!0),jQuery(".bp-album-favorites #rtprogressbar>div").css("width",b+"%"),redirect&&window.setTimeout(e,2e3)})}function e(){window.location=document.URL}var f=document.createElement("div");f.className="support_form_loader",a(".rtm-save-settings-msg").length>0&&setTimeout(function(){a(".rtm-save-settings-msg").remove()},1e4),jQuery("#spread-the-word").on("click","#bp-media-add-linkback",function(){var a={action:"rtmedia_linkback",linkback:jQuery("#bp-media-add-linkback:checked").length};jQuery.post(rtmedia_admin_ajax,a,function(a){})}),jQuery("#bp-media-settings-boxes").on("change","#select-request",function(){if(jQuery(this).val()){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(f);var a={action:"rtmedia_select_request",form:jQuery(this).val()};jQuery.post(ajaxurl,a,function(a){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(a).fadeIn("slow")})}}),jQuery("#bp-media-settings-boxes").on("click","#cancel-request",function(){if(jQuery(this).val()){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(f);var a={action:"rtmedia_cancel_request"};jQuery.post(ajaxurl,a,function(a){jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(),jQuery("#bp_media_settings_form .bp-media-metabox-holder").html(a).fadeIn("slow")})}}),jQuery("#bp-media-settings-boxes").on("submit","#bp_media_settings_form, .rtmedia-settings-submit",function(a){var b=!0,c=new RegExp("^[0-9]+$");jQuery("input[name*='defaultSizes']").each(function(a){return c.test(jQuery(this).val())?void 0:(alert("Invalid value for "+jQuery(this).attr("name").replace("rtmedia-options[defaultSizes_","").replace("]","").replace(/_/g," ").replace(/(\b)([a-zA-Z] )/g,function(a){return a.toUpperCase()})),b=!1,!1)});var d=jQuery('input[name^="rtmedia-options[general_videothumbs]"]');if(b&&d.length>0&&"undefined"!=typeof d){var e="",f=0;if(d.val()<=0?(e+="Number of video thumbnails to be generated should be greater than 0 in media sizes settings. Setting it to default value 2.",f=2):c.test(d.val())||(e+="Invalid value for Number of video thumbnails in media sizes settings. Setting it to round value "+Math.round(d.val())+".",f=Math.round(d.val())),""!=e)return alert(e),d.val(f),b=!1,!1}var g=jQuery('input[name^="rtmedia-options[general_jpeg_image_quality]"]');if(b&&g.length>0&&"undefined"!=typeof g){var e="",h=0;if(g.val()<=0?(e+="Number of percentage in JPEG image quality should be greater than 0 in media sizes settings. Setting it to default value 90.",h=90):g.val()>100?(e+="Number of percentage in JPEG image quality should be less than 100 in media sizes settings. Setting it to 100.",h=100):c.test(g.val())||(e+="Invalid value for percentage in JPEG image quality in media sizes settings. Setting it to round value "+Math.round(g.val())+".",h=Math.round(g.val())),""!=e)return alert(e),g.val(h),b=!1,!1}var i=jQuery('input[name^="rtmedia-options[general_perPageMedia]"]');if(b&&i.length>0&&"undefined"!=typeof i){var e="",j=0;if(i.val()<1?(e+="Please enter positive integer value only. Setting number of media per page value to default value 10.",j=10):jQuery.isNumeric(i.val())&&Math.floor(i.val())!=i.val()&&(e+="Please enter positive integer value only. Setting number of media per page value to round value "+Math.round(i.val())+".",j=Math.round(i.val())),""!=e)return alert(e),i.val(j),b=!1,!1}b||a.preventDefault()}),jQuery(document).on("click","#bpm-services .encoding-try-now,#rtm-services .encoding-try-now",function(a){if(a.preventDefault(),confirm(rtmedia_admin_strings.are_you_sure)){var b={src:rtmedia_admin_url+"images/wpspin_light.gif"};jQuery(this).after(rtMediaAdmin.templates.rtm_image(b));var b={action:"rtmedia_free_encoding_subscribe"};jQuery.getJSON(ajaxurl,b,function(a){if(void 0===a.error&&a.apikey){var b=window.location.href,c=window.location.hash;b=b.replace(c,""),document.location.href=b+"&apikey="+a.apikey+c}else{jQuery(".encoding-try-now").next().remove(),jQuery("#settings-error-encoding-error").remove();var d={id:"settings-error-encoding-error",msg:a.error,"class":"error"};jQuery("#bp-media-settings-boxes").before(rtMediaAdmin.templates.rtm_msg_div(d))}})}}),jQuery(document).on("click","#api-key-submit",function(a){if(a.preventDefault(),0==jQuery(this).next("img").length){var b={src:rtmedia_admin_url+"images/wpspin_light.gif"};jQuery(this).after(rtMediaAdmin.templates.rtm_image(b))}var b={action:"rtmedia_enter_api_key",apikey:jQuery("#new-api-key").val()};jQuery.getJSON(ajaxurl,b,function(a){if(void 0===a.error&&a.apikey){var b=window.location.href,c=window.location.hash;b=b.replace(c,""),-1==b.toString().indexOf("&apikey="+a.apikey)&&(b+="&apikey="+a.apikey),-1==b.toString().indexOf("&update=true")&&(b+="&update=true"),document.location.href=b+c}else{jQuery("#settings-error-api-key-error").remove();var d={id:"settings-error-api-key-error",msg:a.error,"class":"error"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(d))}jQuery("#api-key-submit").next("img").remove()})}),jQuery(document).on("click","#disable-encoding",function(a){if(a.preventDefault(),confirm(rtmedia_admin_strings.disable_encoding)){var b={src:rtmedia_admin_url+"images/wpspin_light.gif"};jQuery(this).after(rtMediaAdmin.templates.rtm_image(b));var b={action:"rtmedia_disable_encoding"};jQuery.post(ajaxurl,b,function(a){if(a){if(jQuery(".settings-error-encoding-disabled").remove(),jQuery("#settings-encoding-successfully-updated").length>0)jQuery("#settings-encoding-successfully-updated p").html(a);else{var b={id:"settings-encoding-successfully-updated",msg:a,"class":"updated"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(b))}jQuery("#rtmedia-encoding-usage").hide(),jQuery("#disable-encoding").next("img").remove(),jQuery("#disable-encoding").hide(),jQuery("#enable-encoding").show()}else{jQuery("#settings-error-encoding-disabled").remove();var b={id:"settings-error-encoding-disabled",msg:rtmedia_admin_strings.something_went_wrong,"class":"error"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(b))}})}}),jQuery(document).on("click","#enable-encoding",function(a){if(a.preventDefault(),confirm(rtmedia_admin_strings.enable_encoding)){var b={src:rtmedia_admin_url+"images/wpspin_light.gif"};jQuery(this).after(rtMediaAdmin.templates.rtm_image(b));var b={action:"rtmedia_enable_encoding"};jQuery.post(ajaxurl,b,function(a){if(a){if(jQuery(".settings-error-encoding-enabled").remove(),jQuery("#settings-encoding-successfully-updated").length>0)jQuery("#settings-encoding-successfully-updated p").html(a);else{var b={id:"settings-encoding-successfully-updated",msg:a,"class":"updated"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(b))}jQuery("#enable-encoding").next("img").remove(),jQuery("#enable-encoding").hide(),jQuery("#disable-encoding").show()}else{jQuery("#settings-error-encoding-disabled").remove();var b={id:"settings-error-encoding-enabled",msg:rtmedia_admin_strings.something_went_wrong,"class":"error"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(b))}})}}),jQuery(".bp-media-encoding-table").on("click",".bpm-unsubscribe",function(a){a.preventDefault(),jQuery("#bpm-unsubscribe-dialog").dialog({dialogClass:"wp-dialog",modal:!0,buttons:{Unsubscribe:function(){jQuery(this).dialog("close");var a={src:rtmedia_admin_url+"images/wpspin_light.gif"};jQuery(".bpm-unsubscribe").after(rtMediaAdmin.templates.rtm_image(a));var a={action:"rtmedia_unsubscribe_encoding_service",note:jQuery("#bpm-unsubscribe-note").val(),plan:jQuery(".bpm-unsubscribe").attr("data-plan"),price:jQuery(".bpm-unsubscribe").attr("data-price")};jQuery.getJSON(ajaxurl,a,function(a){if(void 0===a.error&&a.updated){jQuery(".bpm-unsubscribe").next().remove(),jQuery(".bpm-unsubscribe").after(a.form),jQuery(".bpm-unsubscribe").remove(),jQuery("#settings-unsubscribed-successfully").remove(),jQuery("#settings-unsubscribe-error").remove();var b={id:"settings-unsubscribed-successfully",msg:a.updated,"class":"updated"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(b)),window.location.hash="#settings-unsubscribed-successfully"}else{jQuery(".bpm-unsubscribe").next().remove(),jQuery("#settings-unsubscribed-successfully").remove(),jQuery("#settings-unsubscribe-error").remove();var b={id:"settings-unsubscribe-error",msg:a.error,"class":"error"};jQuery("h2:first").after(rtMediaAdmin.templates.rtm_msg_div(b)),window.location.hash="#settings-unsubscribe-error"}})}}})}),jQuery("#bpmedia-bpalbumimporter").on("change","#bp-album-import-accept",function(){jQuery(".bp-album-import-accept").toggleClass("i-accept"),jQuery(".bp-album-importer-wizard").slideToggle()}),jQuery("#rtprivacyinstall").click(function(a){a.preventDefault(),$progress_parent=jQuery("#rtprivacyinstaller"),$progress_parent.find(".rtprivacytype").each(function(){if($type=jQuery(this).attr("id"),"total"==$type){$values=[],jQuery(this).find("input").each(function(){$values[jQuery(this).attr("name")]=[jQuery(this).val()]}),$data={};for(var a=1;a<=$values.steps[0];a++)$count=20,a==$values.steps[0]&&($count=parseInt($values.laststep[0]),0==$count&&($count=20)),newvals={page:a,action:"rtmedia_privacy_install",count:$count,values:$values},$data[a]=newvals;var c=jQuery.Deferred();c.resolve(),jQuery.each($data,function(a,d){c=c.pipe(function(){return b(d)})})}})}),jQuery("#bpmedia-bpalbumimport-cleanup").click(function(a){a.preventDefault(),jQuery.post(ajaxurl,{action:"rtmedia_rt_album_cleanup",rtm_wpnonce:jQuery("#bpaimporter_wpnonce").val()},function(a){window.location=settings_rt_album_import_url})}),jQuery("#bpmedia-bpalbumimporter").on("click","#bpmedia-bpalbumimport",function(a){if(a.preventDefault(),!jQuery("#bp-album-import-accept").prop("checked")){jQuery("html, body").animate({scrollTop:jQuery("#bp-album-import-accept").offset().top},500);var b=jQuery(".bp-album-import-accept"),d=500,e="#FFEBE8",f=3;return void function i(){b.css("background-color","#EE0000"),setTimeout(function(){b.css("background-color",e),--f&&setTimeout(i,d)},d)}()}if(jQuery(this).prop("disabled",!0),wp_admin_url=ajaxurl.replace("admin-ajax.php",""),!jQuery(".bpm-ajax-loader").length){var g={src:rtmedia_admin_url+"images/wpspin_light.gif","class":"bpm-ajax-loader",norefresh:rtmedia_admin_strings.no_refresh};jQuery(this).after(rtMediaAdmin.templates.rtm_image(g))}$progress_parent=jQuery("#bpmedia-bpalbumimport"),$values=[],jQuery(this).parent().find("input").each(function(){$values[jQuery(this).attr("name")]=[jQuery(this).val()]}),0==$values.steps[0]&&($values.steps[0]=1),$data={};for(var f=1;f<=$values.steps[0];f++)$count=5,f==$values.steps[0]&&($count=parseInt($values.laststep[0]),0==$count&&($count=5)),newvals={page:f,action:"rtmedia_rt_album_import",count:$count,values:$values,rtm_wpnonce:jQuery("#bpaimporter_wpnonce").val()},$data[f]=newvals;var h=jQuery.Deferred();h.resolve(),jQuery.each($data,function(a,b){h=h.pipe(function(){return c(b)})})}),jQuery("#bp-media-settings-boxes").on("click",".interested",function(){jQuery(".interested-container").removeClass("hidden"),jQuery(".choice-free").attr("required","required")}),jQuery("#bp-media-settings-boxes").on("click",".not-interested",function(){jQuery(".interested-container").addClass("hidden"),jQuery(".choice-free").removeAttr("required")}),jQuery("#video-transcoding-main-container").on("click",".video-transcoding-survey",function(a){a.preventDefault();var b={action:"rtmedia_convert_videos_form",email:jQuery(".email").val(),url:jQuery(".url").val(),choice:jQuery('input[name="choice"]:checked').val(),interested:jQuery('input[name="interested"]:checked').val()};return jQuery.post(ajaxurl,b,function(a){var b={msg:a,strong:"yes"};jQuery("#video-transcoding-main-container").html(rtMediaAdmin.templates.rtm_p_tag(b))}),!1}),jQuery("#bpmedia-bpalbumimporter").on("click",".deactivate-bp-album",function(a){a.preventDefault(),$bpalbum=jQuery(this);var b={action:"rtmedia_rt_album_deactivate",rtm_wpnonce:jQuery("#bpaimporter_wpnonce").val()};jQuery.get(ajaxurl,b,function(a){if(a)location.reload();else{var b={msg:rtmedia_admin_strings.something_went_wrong};$bpalbum.parent().after(rtMediaAdmin.templates.rtm_p_tag(b))}})}),jQuery(".updated").on("click",".bpm-hide-encoding-notice",function(){var a={src:rtmedia_admin_url+"images/wpspin_light.gif"};jQuery(this).after(rtMediaAdmin.templates.rtm_image(a));var a={action:"rtmedia_hide_encoding_notice"};jQuery.post(ajaxurl,a,function(a){a&&jQuery(".bpm-hide-encoding-notice").closest(".updated").remove()})}),jQuery("#rtmedia-bp-enable-activity").is(":checked")?jQuery(".rtmedia-bp-activity-setting").prop("readonly",!1):jQuery(".rtmedia-bp-activity-setting").prop("readonly",!0),jQuery("#rtmedia-bp-enable-activity").on("click",function(a){jQuery(this).is(":checked")?jQuery(".rtmedia-bp-activity-setting").prop("readonly",!1):jQuery(".rtmedia-bp-activity-setting").prop("readonly",!0)});var g="",h="";void 0!==rtmedia_on_label&&(g='data-on-label="'+rtmedia_on_label+'"'),void 0!==rtmedia_off_label&&(h='data-off-label="'+rtmedia_off_label+'"'),jQuery("#rtmedia-submit-request").click(function(){var b=jQuery("#name").val(),c=jQuery("#email").val(),d=jQuery("#website").val(),e=jQuery("#phone").val(),f=jQuery("#subject").val(),g=jQuery("#details").val(),h=jQuery('input[name="request_type"]').val(),i=jQuery('input[name="request_id"]').val(),j=jQuery('input[name="server_address"]').val(),k=jQuery('input[name="ip_address"]').val(),l=jQuery('input[name="server_type"]').val(),m=jQuery('input[name="user_agent"]').val(),n={name:b,email:c,website:d,phone:e,subject:f,details:g,request_id:i,request_type:"premium_support",server_address:j,ip_address:k,server_type:l,user_agent:m};if("bug_report"==h){var o=jQuery("#wp_admin_username").val();if(""==o)return alert("Please enter WP Admin Login."),!1;var p=jQuery("#wp_admin_pwd").val();if(""==p)return alert("Please enter WP Admin password."),!1;var q=jQuery("#ssh_ftp_host").val();if(""==q)return alert("Please enter SSH / FTP host."),!1;var r=jQuery("#ssh_ftp_username").val();if(""==r)return alert("Please enter SSH / FTP login."),!1;var s=jQuery("#ssh_ftp_pwd").val();if(""==s)return alert("Please enter SSH / FTP password."),!1;n={name:b,email:c,website:d,phone:e,subject:f,details:g,request_id:i,request_type:"premium_support",server_address:j,ip_address:k,server_type:l,user_agent:m,wp_admin_username:o,wp_admin_pwd:p,ssh_ftp_host:q,ssh_ftp_username:r,ssh_ftp_pwd:s}}for(formdata in n)if(""==n[formdata]&&"phone"!=formdata)return alert("Please enter "+formdata.replace("_"," ")+" field."),!1;return data={action:"rtmedia_submit_request",form_data:n,support_wpnonce:jQuery("#support_wpnonce").val()},jQuery.post(ajaxurl,data,function(b){return b=b.trim(),"false"==b?(alert("Please fill all the fields."),!1):(a("#rtmedia_service_contact_container").empty(),void a("#rtmedia_service_contact_container").append(b))}),!1}),jQuery("#cancel-request").click(function(){return!1}),jQuery(".rtm_enable_masonry_view input[type=checkbox]").is(":checked")?jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").show():jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").hide(),jQuery(".rtm_enable_masonry_view input[type=checkbox]").on("click",function(a){jQuery(this).is(":checked")?jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").show():jQuery(".rtm_enable_masonry_view").parents(".metabox-holder").find(".rtmedia-info").hide()}),jQuery("#rtm-masonry-change-thumbnail-info").click(function(a){jQuery("html, body").animate({scrollTop:0},"500","swing")})}),jQuery(window).load(function(){jQuery(".rtmedia-addon-thickbox").trigger("click")});
|
app/assets/admin/js/scripts.js
CHANGED
@@ -3,6 +3,9 @@
|
|
3 |
*/
|
4 |
jQuery( document ).ready( function ( $ ) {
|
5 |
|
|
|
|
|
|
|
6 |
// Tabs
|
7 |
$( '.rtm-tabs' ).rtTab();
|
8 |
|
@@ -11,7 +14,9 @@ jQuery( document ).ready( function ( $ ) {
|
|
11 |
$( '.rtm-save-settings-msg' ).remove();
|
12 |
|
13 |
if ( $( '.rtm-fly-warning' ).length === 0 ) {
|
14 |
-
|
|
|
|
|
15 |
$( '.rtm-fly-warning' ).slideDown();
|
16 |
}
|
17 |
} );
|
@@ -97,7 +102,11 @@ jQuery( document ).ready( function ( $ ) {
|
|
97 |
$( '.rtm-theme-overlay' ).show();
|
98 |
$( this.el ).find( '.rtm-theme-content-wrap' ).empty().append( themeContent );
|
99 |
} else {
|
100 |
-
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
if ( $( event.currentTarget ).is( ':first-child' ) ) {
|
3 |
*/
|
4 |
jQuery( document ).ready( function ( $ ) {
|
5 |
|
6 |
+
var rtm_warning = document.createElement('div');
|
7 |
+
rtm_warning.setAttribute( 'class', 'rtm-warning rtm-fly-warning hide' );
|
8 |
+
|
9 |
// Tabs
|
10 |
$( '.rtm-tabs' ).rtTab();
|
11 |
|
14 |
$( '.rtm-save-settings-msg' ).remove();
|
15 |
|
16 |
if ( $( '.rtm-fly-warning' ).length === 0 ) {
|
17 |
+
rtm_warning.innerText = "Settings have changed, you should save them!";
|
18 |
+
|
19 |
+
$( '.rtm-button-container.top' ).prepend( rtm_warning );
|
20 |
$( '.rtm-fly-warning' ).slideDown();
|
21 |
}
|
22 |
} );
|
102 |
$( '.rtm-theme-overlay' ).show();
|
103 |
$( this.el ).find( '.rtm-theme-content-wrap' ).empty().append( themeContent );
|
104 |
} else {
|
105 |
+
var data = {
|
106 |
+
themeContent : themeContent
|
107 |
+
};
|
108 |
+
|
109 |
+
$( this.el ).append( rtMediaAdmin.templates.rtm_theme_overlay( data ) );
|
110 |
}
|
111 |
|
112 |
if ( $( event.currentTarget ).is( ':first-child' ) ) {
|
app/assets/admin/js/settings.js
CHANGED
@@ -1,5 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
jQuery( document ).ready( function ( $ ) {
|
2 |
|
|
|
|
|
|
|
3 |
// Hide settings saved message
|
4 |
if ( $( '.rtm-save-settings-msg' ).length > 0 ) {
|
5 |
setTimeout( function () {
|
@@ -21,7 +35,10 @@ jQuery( document ).ready( function ( $ ) {
|
|
21 |
jQuery( '#bp-media-settings-boxes' ).on( 'change', '#select-request', function () {
|
22 |
if ( jQuery( this ).val() ) {
|
23 |
jQuery( '#bp_media_settings_form .bp-media-metabox-holder' ).html();
|
24 |
-
|
|
|
|
|
|
|
25 |
var data = {
|
26 |
action: 'rtmedia_select_request',
|
27 |
form: jQuery( this ).val()
|
@@ -39,7 +56,10 @@ jQuery( document ).ready( function ( $ ) {
|
|
39 |
jQuery( '#bp-media-settings-boxes' ).on( 'click', '#cancel-request', function () {
|
40 |
if ( jQuery( this ).val() ) {
|
41 |
jQuery( '#bp_media_settings_form .bp-media-metabox-holder' ).html();
|
42 |
-
|
|
|
|
|
|
|
43 |
var data = {
|
44 |
action: 'rtmedia_cancel_request'
|
45 |
};
|
@@ -136,7 +156,12 @@ jQuery( document ).ready( function ( $ ) {
|
|
136 |
jQuery( document ).on( 'click', "#bpm-services .encoding-try-now,#rtm-services .encoding-try-now", function ( e ) {
|
137 |
e.preventDefault();
|
138 |
if ( confirm( rtmedia_admin_strings.are_you_sure ) ) {
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
140 |
var data = {
|
141 |
action: 'rtmedia_free_encoding_subscribe'
|
142 |
};
|
@@ -151,7 +176,14 @@ jQuery( document ).ready( function ( $ ) {
|
|
151 |
} else {
|
152 |
jQuery( '.encoding-try-now' ).next().remove();
|
153 |
jQuery( '#settings-error-encoding-error' ).remove();
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
} );
|
157 |
}
|
@@ -161,7 +193,11 @@ jQuery( document ).ready( function ( $ ) {
|
|
161 |
e.preventDefault();
|
162 |
|
163 |
if ( jQuery( this ).next( 'img' ).length == 0 ) {
|
164 |
-
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
var data = {
|
@@ -186,7 +222,14 @@ jQuery( document ).ready( function ( $ ) {
|
|
186 |
document.location.href = tempUrl + hash;
|
187 |
} else {
|
188 |
jQuery( '#settings-error-api-key-error' ).remove();
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
|
192 |
jQuery( '#api-key-submit' ).next( 'img' ).remove();
|
@@ -196,7 +239,12 @@ jQuery( document ).ready( function ( $ ) {
|
|
196 |
jQuery( document ).on( 'click', '#disable-encoding', function ( e ) {
|
197 |
e.preventDefault();
|
198 |
if ( confirm( rtmedia_admin_strings.disable_encoding ) ) {
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
200 |
var data = {
|
201 |
action: 'rtmedia_disable_encoding'
|
202 |
};
|
@@ -209,7 +257,13 @@ jQuery( document ).ready( function ( $ ) {
|
|
209 |
if ( jQuery( '#settings-encoding-successfully-updated' ).length > 0 ) {
|
210 |
jQuery( '#settings-encoding-successfully-updated p' ).html( response );
|
211 |
} else {
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
}
|
214 |
|
215 |
jQuery( '#rtmedia-encoding-usage' ).hide();
|
@@ -218,7 +272,14 @@ jQuery( document ).ready( function ( $ ) {
|
|
218 |
jQuery( '#enable-encoding' ).show();
|
219 |
} else {
|
220 |
jQuery( '#settings-error-encoding-disabled' ).remove();
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
223 |
} );
|
224 |
}
|
@@ -227,10 +288,16 @@ jQuery( document ).ready( function ( $ ) {
|
|
227 |
jQuery( document ).on( 'click', '#enable-encoding', function ( e ) {
|
228 |
e.preventDefault();
|
229 |
if ( confirm( rtmedia_admin_strings.enable_encoding ) ) {
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
231 |
var data = {
|
232 |
action: 'rtmedia_enable_encoding'
|
233 |
};
|
|
|
234 |
jQuery.post( ajaxurl, data, function ( response ) {
|
235 |
if ( response ) {
|
236 |
jQuery( '.settings-error-encoding-enabled' ).remove();
|
@@ -238,7 +305,13 @@ jQuery( document ).ready( function ( $ ) {
|
|
238 |
if ( jQuery( '#settings-encoding-successfully-updated' ).length > 0 ) {
|
239 |
jQuery( '#settings-encoding-successfully-updated p' ).html( response );
|
240 |
} else {
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
|
244 |
jQuery( '#enable-encoding' ).next( 'img' ).remove();
|
@@ -246,7 +319,14 @@ jQuery( document ).ready( function ( $ ) {
|
|
246 |
jQuery( '#disable-encoding' ).show();
|
247 |
} else {
|
248 |
jQuery( '#settings-error-encoding-disabled' ).remove();
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
}
|
251 |
} );
|
252 |
}
|
@@ -254,14 +334,20 @@ jQuery( document ).ready( function ( $ ) {
|
|
254 |
|
255 |
jQuery( '.bp-media-encoding-table' ).on( 'click', '.bpm-unsubscribe', function ( e ) {
|
256 |
e.preventDefault();
|
257 |
-
|
258 |
jQuery( "#bpm-unsubscribe-dialog" ).dialog( {
|
259 |
dialogClass: "wp-dialog",
|
260 |
modal: true,
|
261 |
buttons: {
|
262 |
Unsubscribe: function () {
|
263 |
jQuery( this ).dialog( "close" );
|
264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
var data = {
|
266 |
action: 'rtmedia_unsubscribe_encoding_service',
|
267 |
note: jQuery( '#bpm-unsubscribe-note' ).val(),
|
@@ -277,20 +363,33 @@ jQuery( document ).ready( function ( $ ) {
|
|
277 |
jQuery( '.bpm-unsubscribe' ).remove();
|
278 |
jQuery( '#settings-unsubscribed-successfully' ).remove();
|
279 |
jQuery( '#settings-unsubscribe-error' ).remove();
|
280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
window.location.hash = '#settings-unsubscribed-successfully';
|
282 |
} else {
|
283 |
jQuery( '.bpm-unsubscribe' ).next().remove();
|
284 |
jQuery( '#settings-unsubscribed-successfully' ).remove();
|
285 |
jQuery( '#settings-unsubscribe-error' ).remove();
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
window.location.hash = '#settings-unsubscribe-error';
|
288 |
}
|
289 |
} );
|
290 |
}
|
291 |
}
|
292 |
} );
|
293 |
-
|
294 |
} );
|
295 |
|
296 |
function fireRequest( data ) {
|
@@ -302,7 +401,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
302 |
progw = 100;
|
303 |
redirect = true
|
304 |
}
|
305 |
-
;
|
306 |
jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
|
307 |
finished = jQuery( '#rtprivacyinstaller span.finished' ).html();
|
308 |
jQuery( '#rtprivacyinstaller span.finished' ).html( parseInt( finished ) + data.count );
|
@@ -314,7 +412,11 @@ jQuery( document ).ready( function ( $ ) {
|
|
314 |
} );
|
315 |
}
|
316 |
} else {
|
317 |
-
|
|
|
|
|
|
|
|
|
318 |
}
|
319 |
} );
|
320 |
}
|
@@ -361,8 +463,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
361 |
return fireRequest( v );
|
362 |
} );
|
363 |
} );
|
364 |
-
|
365 |
-
|
366 |
}
|
367 |
} );
|
368 |
} );
|
@@ -395,12 +495,19 @@ jQuery( document ).ready( function ( $ ) {
|
|
395 |
jQuery( '#bpmedia-bpalbumimporter .bp-album-users span.finished' ).html( parseInt( response.users ) );
|
396 |
if ( favorites ) {
|
397 |
favorite_data = {
|
398 |
-
'action': 'rtmedia_rt_album_import_favorites'
|
|
|
399 |
}
|
400 |
jQuery.post( ajaxurl, favorite_data, function ( response ) {
|
401 |
-
if ( response.favorites !== 0 || response.favorites !== '0'
|
402 |
-
if ( !jQuery( '.bp-album-favorites' ).length )
|
403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
$favorites = {};
|
405 |
if ( response.offset != 0 || response.offset != '0' )
|
406 |
start = response.offset * 1 + 1;
|
@@ -418,7 +525,8 @@ jQuery( document ).ready( function ( $ ) {
|
|
418 |
newvals = {
|
419 |
'action': 'rtmedia_rt_album_import_step_favorites',
|
420 |
'offset': ( i - 1 ) * 1,
|
421 |
-
'redirect': i == response.users
|
|
|
422 |
}
|
423 |
$favorites[ i ] = newvals;
|
424 |
}
|
@@ -429,14 +537,25 @@ jQuery( document ).ready( function ( $ ) {
|
|
429 |
return fireimportfavoriteRequest( v );
|
430 |
} );
|
431 |
} );
|
432 |
-
|
433 |
} else {
|
434 |
window.setTimeout( reload_url, 2000 );
|
435 |
}
|
436 |
}, 'json' );
|
437 |
}
|
438 |
} else {
|
439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
}
|
441 |
} );
|
442 |
}
|
@@ -466,7 +585,8 @@ jQuery( document ).ready( function ( $ ) {
|
|
466 |
jQuery( '#bpmedia-bpalbumimport-cleanup' ).click( function ( e ) {
|
467 |
e.preventDefault();
|
468 |
jQuery.post( ajaxurl, {
|
469 |
-
action: 'rtmedia_rt_album_cleanup'
|
|
|
470 |
}, function ( response ) {
|
471 |
window.location = settings_rt_album_import_url;
|
472 |
} );
|
@@ -497,9 +617,16 @@ jQuery( document ).ready( function ( $ ) {
|
|
497 |
jQuery( this ).prop( 'disabled', true );
|
498 |
}
|
499 |
wp_admin_url = ajaxurl.replace( 'admin-ajax.php', '' );
|
500 |
-
if ( !jQuery( '.bpm-ajax-loader' ).length )
|
501 |
-
jQuery( this ).after( ' <img class="bpm-ajax-loader" src="' + wp_admin_url + 'images/wpspin_light.gif" /> <strong>' + rtmedia_admin_strings.no_refresh + '</strong>' );
|
502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
|
504 |
$progress_parent = jQuery( '#bpmedia-bpalbumimport' );
|
505 |
$values = [];
|
@@ -519,13 +646,13 @@ jQuery( document ).ready( function ( $ ) {
|
|
519 |
if ( $count == 0 ) {
|
520 |
$count = 5
|
521 |
}
|
522 |
-
;
|
523 |
}
|
524 |
newvals = {
|
525 |
'page': i,
|
526 |
'action': 'rtmedia_rt_album_import',
|
527 |
'count': $count,
|
528 |
-
'values': $values
|
|
|
529 |
}
|
530 |
$data[ i ] = newvals;
|
531 |
}
|
@@ -536,8 +663,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
536 |
return fireimportRequest( v );
|
537 |
} );
|
538 |
} );
|
539 |
-
|
540 |
-
|
541 |
} );
|
542 |
|
543 |
jQuery( '#bp-media-settings-boxes' ).on( 'click', '.interested', function () {
|
@@ -559,7 +684,12 @@ jQuery( document ).ready( function ( $ ) {
|
|
559 |
interested: jQuery( 'input[name="interested"]:checked' ).val()
|
560 |
}
|
561 |
jQuery.post( ajaxurl, data, function ( response ) {
|
562 |
-
|
|
|
|
|
|
|
|
|
|
|
563 |
} );
|
564 |
return false;
|
565 |
} );
|
@@ -568,18 +698,29 @@ jQuery( document ).ready( function ( $ ) {
|
|
568 |
e.preventDefault();
|
569 |
$bpalbum = jQuery( this );
|
570 |
var data = {
|
571 |
-
action: 'rtmedia_rt_album_deactivate'
|
|
|
572 |
}
|
573 |
jQuery.get( ajaxurl, data, function ( response ) {
|
574 |
-
if ( response )
|
575 |
location.reload();
|
576 |
-
else
|
577 |
-
|
|
|
|
|
|
|
|
|
|
|
578 |
} );
|
579 |
} );
|
580 |
|
581 |
jQuery( '.updated' ).on( 'click', '.bpm-hide-encoding-notice', function () {
|
582 |
-
|
|
|
|
|
|
|
|
|
|
|
583 |
var data = {
|
584 |
action: 'rtmedia_hide_encoding_notice'
|
585 |
}
|
@@ -590,36 +731,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
590 |
} );
|
591 |
} );
|
592 |
|
593 |
-
|
594 |
-
// if ( jQuery( '#rtmedia-privacy-enable' ).is( ":checked" ) ) {
|
595 |
-
// jQuery( ".privacy-driven-disable label input" ).prop( "disabled", false );
|
596 |
-
// jQuery( ".privacy-driven-disable label .rt-switch" ).bootstrapSwitch( "setActive", true );
|
597 |
-
// } else {
|
598 |
-
// jQuery( ".privacy-driven-disable label input" ).prop( "disabled", true );
|
599 |
-
// jQuery( ".privacy-driven-disable label .rt-switch" ).bootstrapSwitch( "setActive", false );
|
600 |
-
// jQuery( ".privacy-driven-disable" ).parent().parent().css( "display", "none" );
|
601 |
-
// }
|
602 |
-
//
|
603 |
-
// if ( jQuery( '#rtmedia-bp-enable-activity' ).is( ":checked" ) ) {
|
604 |
-
// jQuery( ".rtmedia-bp-activity-setting" ).prop( "disabled", false );
|
605 |
-
// jQuery( ".privacy-driven-disable label .rt-switch" ).bootstrapSwitch( "setActive", true );
|
606 |
-
// } else {
|
607 |
-
// jQuery( ".rtmedia-bp-activity-setting" ).prop( "disabled", true );
|
608 |
-
// jQuery( ".privacy-driven-disable label .rt-switch" ).bootstrapSwitch( "setActive", false );
|
609 |
-
// }
|
610 |
-
//
|
611 |
-
// jQuery( '#rtmedia-privacy-enable' ).on( "click", function ( e ) {
|
612 |
-
// if ( jQuery( this ).is( ":checked" ) ) {
|
613 |
-
// jQuery( ".privacy-driven-disable label input" ).prop( "disabled", false );
|
614 |
-
// jQuery( ".privacy-driven-disable label .rt-switch" ).bootstrapSwitch( "setActive", true );
|
615 |
-
// jQuery( ".privacy-driven-disable" ).parent().parent().css( "display", "block" );
|
616 |
-
// } else {
|
617 |
-
// jQuery( ".privacy-driven-disable label input" ).prop( "disabled", true );
|
618 |
-
// jQuery( ".privacy-driven-disable label .rt-switch" ).bootstrapSwitch( "setActive", false );
|
619 |
-
// jQuery( ".privacy-driven-disable" ).parent().parent().css( "display", "none" );
|
620 |
-
// }
|
621 |
-
// } );
|
622 |
-
|
623 |
if ( jQuery( '#rtmedia-bp-enable-activity' ).is( ":checked" ) ) {
|
624 |
jQuery( ".rtmedia-bp-activity-setting" ).prop( "readonly", false );
|
625 |
} else {
|
@@ -640,21 +751,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
640 |
onData = 'data-on-label="' + rtmedia_on_label + '"';
|
641 |
if ( rtmedia_off_label !== undefined )
|
642 |
offData = 'data-off-label="' + rtmedia_off_label + '"';
|
643 |
-
//jQuery( "[data-toggle='switch']" ).wrap( '<div class="rt-switch" ' + onData + ' ' + offData + ' />' ).parent().bootstrapSwitch();
|
644 |
-
|
645 |
-
// $( ".rtmedia-tab-title" ).click( function () {
|
646 |
-
// hash = $( this ).attr( 'href' );
|
647 |
-
// window.location.hash = hash.substring( 1, hash.length );
|
648 |
-
// } );
|
649 |
-
//
|
650 |
-
// function manageHash() {
|
651 |
-
//
|
652 |
-
// hash = window.location.hash;
|
653 |
-
// $( '#tab-' + hash.substr( 1, hash.length ) ).click();
|
654 |
-
// if ( $( '#tab-' + hash.substr( 1, hash.length ) ).length < 1 )
|
655 |
-
// return 1;
|
656 |
-
// return $( '#tab-' + hash.substr( 1, hash.length ) ).parent().index() + 1;
|
657 |
-
// }
|
658 |
|
659 |
jQuery( '#rtmedia-submit-request' ).click( function () {
|
660 |
var flag = true;
|
@@ -738,7 +834,8 @@ jQuery( document ).ready( function ( $ ) {
|
|
738 |
}
|
739 |
data = {
|
740 |
action: "rtmedia_submit_request",
|
741 |
-
form_data: form_data
|
|
|
742 |
};
|
743 |
jQuery.post( ajaxurl, data, function ( data ) {
|
744 |
data = data.trim();
|
@@ -785,4 +882,4 @@ function rtmedia_addon_do_not_show() {
|
|
785 |
|
786 |
jQuery( window ).load( function () {
|
787 |
jQuery( '.rtmedia-addon-thickbox' ).trigger( 'click' );
|
788 |
-
} );
|
1 |
+
var rtMediaAdmin = new Object();
|
2 |
+
|
3 |
+
rtMediaAdmin.templates = {
|
4 |
+
rtm_image : wp.template( 'rtm-image' ),
|
5 |
+
rtm_msg_div : wp.template( 'rtm-msg-div' ),
|
6 |
+
rtm_album_favourites_importer : wp.template( 'rtm-album-favourites-importer' ),
|
7 |
+
rtm_map_mapping_failure : wp.template( 'rtm-map-mapping-failure' ),
|
8 |
+
rtm_p_tag : wp.template( 'rtm-p-tag' ),
|
9 |
+
rtm_theme_overlay : wp.template( 'rtm-theme-overlay' )
|
10 |
+
};
|
11 |
+
|
12 |
jQuery( document ).ready( function ( $ ) {
|
13 |
|
14 |
+
var support_form_loader_div = document.createElement('div');
|
15 |
+
support_form_loader_div.className = 'support_form_loader';
|
16 |
+
|
17 |
// Hide settings saved message
|
18 |
if ( $( '.rtm-save-settings-msg' ).length > 0 ) {
|
19 |
setTimeout( function () {
|
35 |
jQuery( '#bp-media-settings-boxes' ).on( 'change', '#select-request', function () {
|
36 |
if ( jQuery( this ).val() ) {
|
37 |
jQuery( '#bp_media_settings_form .bp-media-metabox-holder' ).html();
|
38 |
+
|
39 |
+
//'<div class="support_form_loader"></div>'
|
40 |
+
|
41 |
+
jQuery( '#bp_media_settings_form .bp-media-metabox-holder' ).html( support_form_loader_div );
|
42 |
var data = {
|
43 |
action: 'rtmedia_select_request',
|
44 |
form: jQuery( this ).val()
|
56 |
jQuery( '#bp-media-settings-boxes' ).on( 'click', '#cancel-request', function () {
|
57 |
if ( jQuery( this ).val() ) {
|
58 |
jQuery( '#bp_media_settings_form .bp-media-metabox-holder' ).html();
|
59 |
+
|
60 |
+
// '<div class="support_form_loader"></div>'
|
61 |
+
|
62 |
+
jQuery( '#bp_media_settings_form .bp-media-metabox-holder' ).html( support_form_loader_div );
|
63 |
var data = {
|
64 |
action: 'rtmedia_cancel_request'
|
65 |
};
|
156 |
jQuery( document ).on( 'click', "#bpm-services .encoding-try-now,#rtm-services .encoding-try-now", function ( e ) {
|
157 |
e.preventDefault();
|
158 |
if ( confirm( rtmedia_admin_strings.are_you_sure ) ) {
|
159 |
+
var data = {
|
160 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif"
|
161 |
+
};
|
162 |
+
|
163 |
+
jQuery( this ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
164 |
+
|
165 |
var data = {
|
166 |
action: 'rtmedia_free_encoding_subscribe'
|
167 |
};
|
176 |
} else {
|
177 |
jQuery( '.encoding-try-now' ).next().remove();
|
178 |
jQuery( '#settings-error-encoding-error' ).remove();
|
179 |
+
|
180 |
+
var data = {
|
181 |
+
id : 'settings-error-encoding-error',
|
182 |
+
msg : response.error,
|
183 |
+
class : 'error'
|
184 |
+
};
|
185 |
+
|
186 |
+
jQuery( '#bp-media-settings-boxes' ).before( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
187 |
}
|
188 |
} );
|
189 |
}
|
193 |
e.preventDefault();
|
194 |
|
195 |
if ( jQuery( this ).next( 'img' ).length == 0 ) {
|
196 |
+
var data = {
|
197 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif"
|
198 |
+
};
|
199 |
+
|
200 |
+
jQuery( this ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
201 |
}
|
202 |
|
203 |
var data = {
|
222 |
document.location.href = tempUrl + hash;
|
223 |
} else {
|
224 |
jQuery( '#settings-error-api-key-error' ).remove();
|
225 |
+
|
226 |
+
var data = {
|
227 |
+
id : 'settings-error-api-key-error',
|
228 |
+
msg : response.error,
|
229 |
+
class : 'error'
|
230 |
+
};
|
231 |
+
|
232 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
233 |
}
|
234 |
|
235 |
jQuery( '#api-key-submit' ).next( 'img' ).remove();
|
239 |
jQuery( document ).on( 'click', '#disable-encoding', function ( e ) {
|
240 |
e.preventDefault();
|
241 |
if ( confirm( rtmedia_admin_strings.disable_encoding ) ) {
|
242 |
+
var data = {
|
243 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif"
|
244 |
+
};
|
245 |
+
|
246 |
+
jQuery( this ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
247 |
+
|
248 |
var data = {
|
249 |
action: 'rtmedia_disable_encoding'
|
250 |
};
|
257 |
if ( jQuery( '#settings-encoding-successfully-updated' ).length > 0 ) {
|
258 |
jQuery( '#settings-encoding-successfully-updated p' ).html( response );
|
259 |
} else {
|
260 |
+
var data = {
|
261 |
+
id : 'settings-encoding-successfully-updated',
|
262 |
+
msg : response,
|
263 |
+
class : 'updated'
|
264 |
+
};
|
265 |
+
|
266 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
267 |
}
|
268 |
|
269 |
jQuery( '#rtmedia-encoding-usage' ).hide();
|
272 |
jQuery( '#enable-encoding' ).show();
|
273 |
} else {
|
274 |
jQuery( '#settings-error-encoding-disabled' ).remove();
|
275 |
+
|
276 |
+
var data = {
|
277 |
+
id : 'settings-error-encoding-disabled',
|
278 |
+
msg : rtmedia_admin_strings.something_went_wrong,
|
279 |
+
class : 'error'
|
280 |
+
};
|
281 |
+
|
282 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
283 |
}
|
284 |
} );
|
285 |
}
|
288 |
jQuery( document ).on( 'click', '#enable-encoding', function ( e ) {
|
289 |
e.preventDefault();
|
290 |
if ( confirm( rtmedia_admin_strings.enable_encoding ) ) {
|
291 |
+
var data = {
|
292 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif"
|
293 |
+
};
|
294 |
+
|
295 |
+
jQuery( this ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
296 |
+
|
297 |
var data = {
|
298 |
action: 'rtmedia_enable_encoding'
|
299 |
};
|
300 |
+
|
301 |
jQuery.post( ajaxurl, data, function ( response ) {
|
302 |
if ( response ) {
|
303 |
jQuery( '.settings-error-encoding-enabled' ).remove();
|
305 |
if ( jQuery( '#settings-encoding-successfully-updated' ).length > 0 ) {
|
306 |
jQuery( '#settings-encoding-successfully-updated p' ).html( response );
|
307 |
} else {
|
308 |
+
var data = {
|
309 |
+
id : 'settings-encoding-successfully-updated',
|
310 |
+
msg : response,
|
311 |
+
class : 'updated'
|
312 |
+
};
|
313 |
+
|
314 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
315 |
}
|
316 |
|
317 |
jQuery( '#enable-encoding' ).next( 'img' ).remove();
|
319 |
jQuery( '#disable-encoding' ).show();
|
320 |
} else {
|
321 |
jQuery( '#settings-error-encoding-disabled' ).remove();
|
322 |
+
|
323 |
+
var data = {
|
324 |
+
id : 'settings-error-encoding-enabled',
|
325 |
+
msg : rtmedia_admin_strings.something_went_wrong,
|
326 |
+
class : 'error'
|
327 |
+
};
|
328 |
+
|
329 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
330 |
}
|
331 |
} );
|
332 |
}
|
334 |
|
335 |
jQuery( '.bp-media-encoding-table' ).on( 'click', '.bpm-unsubscribe', function ( e ) {
|
336 |
e.preventDefault();
|
337 |
+
|
338 |
jQuery( "#bpm-unsubscribe-dialog" ).dialog( {
|
339 |
dialogClass: "wp-dialog",
|
340 |
modal: true,
|
341 |
buttons: {
|
342 |
Unsubscribe: function () {
|
343 |
jQuery( this ).dialog( "close" );
|
344 |
+
|
345 |
+
var data = {
|
346 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif"
|
347 |
+
};
|
348 |
+
|
349 |
+
jQuery( '.bpm-unsubscribe' ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
350 |
+
|
351 |
var data = {
|
352 |
action: 'rtmedia_unsubscribe_encoding_service',
|
353 |
note: jQuery( '#bpm-unsubscribe-note' ).val(),
|
363 |
jQuery( '.bpm-unsubscribe' ).remove();
|
364 |
jQuery( '#settings-unsubscribed-successfully' ).remove();
|
365 |
jQuery( '#settings-unsubscribe-error' ).remove();
|
366 |
+
|
367 |
+
var data = {
|
368 |
+
id : 'settings-unsubscribed-successfully',
|
369 |
+
msg : response.updated,
|
370 |
+
class : 'updated'
|
371 |
+
};
|
372 |
+
|
373 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
374 |
window.location.hash = '#settings-unsubscribed-successfully';
|
375 |
} else {
|
376 |
jQuery( '.bpm-unsubscribe' ).next().remove();
|
377 |
jQuery( '#settings-unsubscribed-successfully' ).remove();
|
378 |
jQuery( '#settings-unsubscribe-error' ).remove();
|
379 |
+
|
380 |
+
var data = {
|
381 |
+
id : 'settings-unsubscribe-error',
|
382 |
+
msg : response.error,
|
383 |
+
class : 'error'
|
384 |
+
};
|
385 |
+
|
386 |
+
jQuery( 'h2:first' ).after( rtMediaAdmin.templates.rtm_msg_div( data ) );
|
387 |
window.location.hash = '#settings-unsubscribe-error';
|
388 |
}
|
389 |
} );
|
390 |
}
|
391 |
}
|
392 |
} );
|
|
|
393 |
} );
|
394 |
|
395 |
function fireRequest( data ) {
|
401 |
progw = 100;
|
402 |
redirect = true
|
403 |
}
|
|
|
404 |
jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
|
405 |
finished = jQuery( '#rtprivacyinstaller span.finished' ).html();
|
406 |
jQuery( '#rtprivacyinstaller span.finished' ).html( parseInt( finished ) + data.count );
|
412 |
} );
|
413 |
}
|
414 |
} else {
|
415 |
+
var map_data = {
|
416 |
+
msg : "Row " + response + " failed."
|
417 |
+
};
|
418 |
+
|
419 |
+
jQuery( '#map_progress_msgs' ).html( rtMediaAdmin.templates.rtm_map_mapping_failure( map_data ) );
|
420 |
}
|
421 |
} );
|
422 |
}
|
463 |
return fireRequest( v );
|
464 |
} );
|
465 |
} );
|
|
|
|
|
466 |
}
|
467 |
} );
|
468 |
} );
|
495 |
jQuery( '#bpmedia-bpalbumimporter .bp-album-users span.finished' ).html( parseInt( response.users ) );
|
496 |
if ( favorites ) {
|
497 |
favorite_data = {
|
498 |
+
'action': 'rtmedia_rt_album_import_favorites',
|
499 |
+
rtm_wpnonce: jQuery('#bpaimporter_wpnonce').val()
|
500 |
}
|
501 |
jQuery.post( ajaxurl, favorite_data, function ( response ) {
|
502 |
+
if (response.hasOwnProperty(favorites) && (response.favorites !== 0 || response.favorites !== '0')) {
|
503 |
+
if ( !jQuery( '.bp-album-favorites' ).length ) {
|
504 |
+
var data = {
|
505 |
+
users : response.users
|
506 |
+
}
|
507 |
+
|
508 |
+
jQuery( '.bp-album-comments' ).after( rtMediaAdmin.templates.rtm_album_favourites_importer( data ) );
|
509 |
+
}
|
510 |
+
|
511 |
$favorites = {};
|
512 |
if ( response.offset != 0 || response.offset != '0' )
|
513 |
start = response.offset * 1 + 1;
|
525 |
newvals = {
|
526 |
'action': 'rtmedia_rt_album_import_step_favorites',
|
527 |
'offset': ( i - 1 ) * 1,
|
528 |
+
'redirect': i == response.users,
|
529 |
+
'rtm_wpnonce': jQuery('#bpaimporter_wpnonce').val()
|
530 |
}
|
531 |
$favorites[ i ] = newvals;
|
532 |
}
|
537 |
return fireimportfavoriteRequest( v );
|
538 |
} );
|
539 |
} );
|
|
|
540 |
} else {
|
541 |
window.setTimeout( reload_url, 2000 );
|
542 |
}
|
543 |
}, 'json' );
|
544 |
}
|
545 |
} else {
|
546 |
+
if (data.hasOwnProperty(page)) {
|
547 |
+
var map_data = {
|
548 |
+
msg : "Row " + response.page + " failed."
|
549 |
+
};
|
550 |
+
|
551 |
+
jQuery('#map_progress_msgs').html( rtMediaAdmin.templates.rtm_map_mapping_failure( map_data ) );
|
552 |
+
} else {
|
553 |
+
var map_data = {
|
554 |
+
msg : "Request failed."
|
555 |
+
};
|
556 |
+
|
557 |
+
jQuery('#map_progress_msgs').html( rtMediaAdmin.templates.rtm_map_mapping_failure( map_data ) );
|
558 |
+
}
|
559 |
}
|
560 |
} );
|
561 |
}
|
585 |
jQuery( '#bpmedia-bpalbumimport-cleanup' ).click( function ( e ) {
|
586 |
e.preventDefault();
|
587 |
jQuery.post( ajaxurl, {
|
588 |
+
action: 'rtmedia_rt_album_cleanup',
|
589 |
+
rtm_wpnonce: jQuery('#bpaimporter_wpnonce').val()
|
590 |
}, function ( response ) {
|
591 |
window.location = settings_rt_album_import_url;
|
592 |
} );
|
617 |
jQuery( this ).prop( 'disabled', true );
|
618 |
}
|
619 |
wp_admin_url = ajaxurl.replace( 'admin-ajax.php', '' );
|
|
|
|
|
620 |
|
621 |
+
if ( !jQuery( '.bpm-ajax-loader' ).length ) {
|
622 |
+
var data = {
|
623 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif",
|
624 |
+
class : 'bpm-ajax-loader',
|
625 |
+
norefresh : rtmedia_admin_strings.no_refresh
|
626 |
+
};
|
627 |
+
|
628 |
+
jQuery( this ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
629 |
+
}
|
630 |
|
631 |
$progress_parent = jQuery( '#bpmedia-bpalbumimport' );
|
632 |
$values = [];
|
646 |
if ( $count == 0 ) {
|
647 |
$count = 5
|
648 |
}
|
|
|
649 |
}
|
650 |
newvals = {
|
651 |
'page': i,
|
652 |
'action': 'rtmedia_rt_album_import',
|
653 |
'count': $count,
|
654 |
+
'values': $values,
|
655 |
+
rtm_wpnonce: jQuery('#bpaimporter_wpnonce').val()
|
656 |
}
|
657 |
$data[ i ] = newvals;
|
658 |
}
|
663 |
return fireimportRequest( v );
|
664 |
} );
|
665 |
} );
|
|
|
|
|
666 |
} );
|
667 |
|
668 |
jQuery( '#bp-media-settings-boxes' ).on( 'click', '.interested', function () {
|
684 |
interested: jQuery( 'input[name="interested"]:checked' ).val()
|
685 |
}
|
686 |
jQuery.post( ajaxurl, data, function ( response ) {
|
687 |
+
var p_data = {
|
688 |
+
msg :response,
|
689 |
+
strong : 'yes'
|
690 |
+
};
|
691 |
+
|
692 |
+
jQuery( '#video-transcoding-main-container' ).html( rtMediaAdmin.templates.rtm_p_tag( p_data ) );
|
693 |
} );
|
694 |
return false;
|
695 |
} );
|
698 |
e.preventDefault();
|
699 |
$bpalbum = jQuery( this );
|
700 |
var data = {
|
701 |
+
action: 'rtmedia_rt_album_deactivate',
|
702 |
+
rtm_wpnonce: jQuery('#bpaimporter_wpnonce').val()
|
703 |
}
|
704 |
jQuery.get( ajaxurl, data, function ( response ) {
|
705 |
+
if ( response ) {
|
706 |
location.reload();
|
707 |
+
} else {
|
708 |
+
var p_data = {
|
709 |
+
msg : rtmedia_admin_strings.something_went_wrong
|
710 |
+
};
|
711 |
+
|
712 |
+
$bpalbum.parent().after( rtMediaAdmin.templates.rtm_p_tag( p_data ) );
|
713 |
+
}
|
714 |
} );
|
715 |
} );
|
716 |
|
717 |
jQuery( '.updated' ).on( 'click', '.bpm-hide-encoding-notice', function () {
|
718 |
+
var data = {
|
719 |
+
src : rtmedia_admin_url + "images/wpspin_light.gif"
|
720 |
+
};
|
721 |
+
|
722 |
+
jQuery( this ).after( rtMediaAdmin.templates.rtm_image( data ) );
|
723 |
+
|
724 |
var data = {
|
725 |
action: 'rtmedia_hide_encoding_notice'
|
726 |
}
|
731 |
} );
|
732 |
} );
|
733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
734 |
if ( jQuery( '#rtmedia-bp-enable-activity' ).is( ":checked" ) ) {
|
735 |
jQuery( ".rtmedia-bp-activity-setting" ).prop( "readonly", false );
|
736 |
} else {
|
751 |
onData = 'data-on-label="' + rtmedia_on_label + '"';
|
752 |
if ( rtmedia_off_label !== undefined )
|
753 |
offData = 'data-off-label="' + rtmedia_off_label + '"';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
|
755 |
jQuery( '#rtmedia-submit-request' ).click( function () {
|
756 |
var flag = true;
|
834 |
}
|
835 |
data = {
|
836 |
action: "rtmedia_submit_request",
|
837 |
+
form_data: form_data,
|
838 |
+
support_wpnonce: jQuery('#support_wpnonce').val()
|
839 |
};
|
840 |
jQuery.post( ajaxurl, data, function ( data ) {
|
841 |
data = data.trim();
|
882 |
|
883 |
jQuery( window ).load( function () {
|
884 |
jQuery( '.rtmedia-addon-thickbox' ).trigger( 'click' );
|
885 |
+
} );
|
app/assets/js/rtMedia.backbone.js
CHANGED
@@ -27,8 +27,11 @@ jQuery( function ( $ ) {
|
|
27 |
rtMedia.Context = Backbone.Model.extend( {
|
28 |
url: function () {
|
29 |
var url = rtmedia_media_slug + "/";
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
return url;
|
33 |
},
|
34 |
defaults: {
|
@@ -74,14 +77,17 @@ jQuery( function ( $ ) {
|
|
74 |
if ( temp.indexOf( "/" + rtmedia_media_slug + "/" ) == - 1 ) {
|
75 |
url = rtmedia_media_slug + '/';
|
76 |
} else {
|
77 |
-
if ( temp.indexOf( 'pg/' ) == - 1 )
|
78 |
url = temp;
|
79 |
-
else
|
80 |
url = window.location.pathname.substr( 0, window.location.pathname.lastIndexOf( "pg/" ) );
|
|
|
81 |
}
|
82 |
if ( ! upload_sync && nextpage > 1 ) {
|
83 |
-
if ( url.substr( url.length - 1 ) != "/" )
|
84 |
-
url += "/"
|
|
|
|
|
85 |
url += 'pg/' + nextpage + '/';
|
86 |
}
|
87 |
return url;
|
@@ -98,11 +104,7 @@ jQuery( function ( $ ) {
|
|
98 |
if ( jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=lightbox]' ).length > 0 ) {
|
99 |
template_url += '&lightbox=' + jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=lightbox]' ).val();
|
100 |
}
|
101 |
-
$( "#rtmedia-gallery-item-template" ).load( template_url, {
|
102 |
-
backbone: true,
|
103 |
-
is_album: o_is_album,
|
104 |
-
is_edit_allowed: o_is_edit_allowed
|
105 |
-
}, function () {
|
106 |
rtmedia_load_template_flag = false;
|
107 |
that.getNext( page, el, element );
|
108 |
} );
|
@@ -117,31 +119,34 @@ jQuery( function ( $ ) {
|
|
117 |
el = jQuery( ".rtmedia-list" ).parent().parent();
|
118 |
}
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
|
136 |
this.fetch( {
|
137 |
data: query,
|
138 |
success: function ( model, response ) {
|
139 |
jQuery( '.rtm-media-loading' ).hide();
|
140 |
var list_el = "";
|
141 |
-
|
|
|
142 |
list_el = $( ".rtmedia-list" )[0];
|
143 |
-
else
|
144 |
list_el = element.parent().siblings( '.rtmedia-list' );
|
|
|
|
|
145 |
nextpage = response.next;
|
146 |
|
147 |
if ( nextpage < 1 ) {
|
@@ -174,8 +179,6 @@ jQuery( function ( $ ) {
|
|
174 |
jQuery( '.rtmedia-container .rtmedia-list' ).css( 'opacity', '0.5' );
|
175 |
this.getNext();
|
176 |
}
|
177 |
-
|
178 |
-
|
179 |
} );
|
180 |
|
181 |
rtMedia.MediaView = Backbone.View.extend( {
|
@@ -242,7 +245,6 @@ jQuery( function ( $ ) {
|
|
242 |
}
|
243 |
} );
|
244 |
|
245 |
-
|
246 |
galleryObj = new rtMedia.Gallery();
|
247 |
|
248 |
$( "body" ).append( '<script id="rtmedia-gallery-item-template" type="text/template"></script>' );
|
@@ -257,446 +259,445 @@ jQuery( function ( $ ) {
|
|
257 |
e.preventDefault();
|
258 |
galleryObj.getNext( nextpage, $( this ).parent().parent().parent(), $( this ) );
|
259 |
} );
|
260 |
-
|
261 |
-
$( document ).on( "keypress", "#rtmedia_go_to_num", function( e ) {
|
262 |
-
if ( e.keyCode == 13 ) {
|
263 |
-
e.preventDefault();
|
264 |
-
|
265 |
-
if ( jQuery( '.rtm-media-loading' ).length == 0 ) {
|
266 |
-
$( '.rtm-pagination' ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" );
|
267 |
-
} else {
|
268 |
-
jQuery( '.rtm-media-loading' ).show();
|
269 |
-
}
|
270 |
-
|
271 |
-
if ( parseInt( $( '#rtmedia_go_to_num' ).val() ) > parseInt( $( '#rtmedia_last_page' ).val() ) ) {
|
272 |
-
nextpage = parseInt( $( '#rtmedia_last_page' ).val() );
|
273 |
-
} else {
|
274 |
-
nextpage = parseInt( $( '#rtmedia_go_to_num' ).val() );
|
275 |
-
}
|
276 |
-
|
277 |
-
galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() );
|
278 |
-
|
279 |
-
return false;
|
280 |
-
}
|
281 |
-
} );
|
282 |
-
|
283 |
-
$( document ).on( "click", ".rtmedia-page-link", function ( e ) {
|
284 |
-
if ( jQuery( '.rtm-media-loading' ).length == 0 ) {
|
285 |
-
$( '.rtm-pagination' ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" );
|
286 |
-
} else {
|
287 |
-
jQuery( '.rtm-media-loading' ).show();
|
288 |
-
}
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
} else if ( $( this ).data( 'page-type' ) == 'prev' ) {
|
294 |
-
if ( nextpage == - 1 ) {
|
295 |
-
nextpage = parseInt( $( '#rtmedia_last_page' ).val() ) - 1;
|
296 |
-
} else {
|
297 |
-
nextpage -= 2;
|
298 |
-
}
|
299 |
-
} else if ( $( this ).data( 'page-type' ) == 'num' ) {
|
300 |
-
if ( parseInt( $( '#rtmedia_go_to_num' ).val() ) > parseInt( $( '#rtmedia_last_page' ).val() ) ) {
|
301 |
-
nextpage = parseInt( $( '#rtmedia_last_page' ).val() );
|
302 |
-
} else {
|
303 |
-
nextpage = parseInt( $( '#rtmedia_go_to_num' ).val() );
|
304 |
-
}
|
305 |
-
}
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
} );
|
313 |
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
}
|
320 |
|
|
|
321 |
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
},
|
326 |
-
initialize: function ( config ) {
|
327 |
-
this.uploader = new plupload.Uploader( config );
|
328 |
-
},
|
329 |
-
render: function () {
|
330 |
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
347 |
} else {
|
348 |
-
|
349 |
}
|
350 |
-
|
351 |
|
352 |
-
|
353 |
-
$(
|
354 |
-
|
|
|
355 |
}
|
|
|
356 |
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
this.uploader.start();
|
363 |
-
return false;
|
364 |
}
|
365 |
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
|
|
|
|
|
|
|
|
|
376 |
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
galleryObj.reloadView();
|
383 |
}
|
|
|
|
|
384 |
}
|
385 |
-
jQuery( '#rtmedia_uploader_filelist li.plupload_queue_li' ).remove();
|
386 |
-
jQuery( '.start-media-upload' ).hide();
|
387 |
-
apply_rtMagnificPopup( jQuery( '.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' ) );
|
388 |
-
window.onbeforeunload = null;
|
389 |
-
} );
|
390 |
-
|
391 |
-
uploaderObj.uploader.bind( 'FilesAdded', function ( up, files ) {
|
392 |
-
var upload_size_error = false;
|
393 |
-
var upload_error = "";
|
394 |
-
var upload_error_sep = "";
|
395 |
-
var upload_remove_array = [ ];
|
396 |
-
$.each( files, function ( i, file ) {
|
397 |
-
//set file title along with file
|
398 |
-
rtm_file_name_array = file.name.split( '.' );
|
399 |
-
file.title = rtm_file_name_array[0];
|
400 |
|
401 |
-
|
402 |
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
}
|
|
|
|
|
|
|
|
|
|
|
408 |
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
if ( tmp_array.length > 1 ) {
|
425 |
-
var ext = tmp_array[tmp_array.length - 1];
|
426 |
-
ext = ext.toLowerCase();
|
427 |
-
if ( jQuery.inArray( ext, ext_array ) === - 1 ) {
|
428 |
return true;
|
429 |
}
|
430 |
-
} else {
|
431 |
-
return true;
|
432 |
-
}
|
433 |
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
|
440 |
-
|
441 |
-
|
|
|
|
|
|
|
442 |
|
443 |
-
|
444 |
-
|
445 |
-
e.preventDefault();
|
446 |
-
uploaderObj.uploader.removeFile( up.getFile( file.id ) );
|
447 |
-
$( "#" + file.id ).remove();
|
448 |
-
rtMediaHook.call( 'rtmedia_js_file_remove', [ up, file ] );
|
449 |
-
return false;
|
450 |
-
} );
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
rtm_file_title_wrapper_id = 'rtm_title_wp_' + file.id;
|
461 |
-
rtm_file_title_wrapper = '#' + rtm_file_title_wrapper_id;
|
462 |
-
|
463 |
-
rtm_file_desc_id = 'rtm_desc_' + file.id;
|
464 |
-
rtm_file_desc_input = '#' + rtm_file_desc_id;
|
465 |
-
rtm_file_desc_wrapper_id = 'rtm_desc_wp_' + file.id;
|
466 |
-
rtm_file_desc_wrapper = '#' + rtm_file_desc_wrapper_id;
|
467 |
-
|
468 |
-
rtm_file_save_id = 'save_' + file.id;
|
469 |
-
rtm_file_save_el = '#' + rtm_file_save_id;
|
470 |
-
|
471 |
-
jQuery( rtm_file_label ).hide();
|
472 |
-
jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ).hide();
|
473 |
-
|
474 |
-
// show/create text box to edit media title
|
475 |
-
if( jQuery( rtm_file_title_input ).length === 0 ) {
|
476 |
-
jQuery( rtm_file_label ).parent( '.plupload_file_name' ).prepend( '<div id="' + rtm_file_title_wrapper_id + '" class="rtm-upload-edit-title-wrapper"><label>' + rtmedia_edit_media_info_upload.title + '</label><input type="text" class="rtm-upload-edit-title" id="' + rtm_file_title_id + '" value="' + file.title + '" style="width: 75%;" /></div><div id="' + rtm_file_desc_wrapper_id + '" class="rtm-upload-edit-desc-wrapper"><label>' + rtmedia_edit_media_info_upload.description + '</label><textarea class="rtm-upload-edit-desc" id="' + rtm_file_desc_id + '"></textarea></div><span id="' + rtm_file_save_id + '" title="Save Change" class="rtmicon dashicons dashicons-yes"></span>' );
|
477 |
-
} else {
|
478 |
-
jQuery( rtm_file_title_wrapper ).show();
|
479 |
-
jQuery( rtm_file_desc_wrapper ).show();
|
480 |
-
jQuery( rtm_file_save_el ).show();
|
481 |
-
}
|
482 |
-
|
483 |
-
jQuery( rtm_file_title_input ).focus();
|
484 |
-
|
485 |
-
// set media title and description in file object
|
486 |
-
jQuery( rtm_file_save_el ).click( function(){
|
487 |
-
var file_title_val = jQuery( rtm_file_title_input ).val();
|
488 |
-
var file_desc_val = jQuery( rtm_file_desc_input ).val();
|
489 |
-
var file_name_wrapper_el = jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' );
|
490 |
-
|
491 |
-
if( file_title_val != '' ){
|
492 |
-
file_name_wrapper_el.text( file_title_val + "." + rtm_file_name_array[ 1 ] );
|
493 |
-
file.title = file_title_val;
|
494 |
-
}
|
495 |
-
|
496 |
-
if( file_desc_val != '' ){
|
497 |
-
file.description = file_desc_val;
|
498 |
-
}
|
499 |
-
|
500 |
-
jQuery( rtm_file_title_wrapper ).hide();
|
501 |
-
jQuery( rtm_file_desc_wrapper ).hide();
|
502 |
-
file_name_wrapper_el.show();
|
503 |
-
jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' )
|
504 |
-
jQuery( rtm_file_label ).show();
|
505 |
-
jQuery( this ).hide();
|
506 |
-
} );
|
507 |
-
} );
|
508 |
-
} );
|
509 |
-
|
510 |
-
$.each( upload_remove_array, function ( i, rfile ) {
|
511 |
-
if ( up.getFile( rfile ) )
|
512 |
-
up.removeFile( up.getFile( rfile ) );
|
513 |
-
} );
|
514 |
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true );
|
519 |
-
if ( allow_upload == false ) {
|
520 |
-
return false;
|
521 |
-
}
|
522 |
-
uploaderObj.uploadFiles();
|
523 |
-
}
|
524 |
|
525 |
-
|
526 |
|
527 |
-
|
|
|
|
|
|
|
528 |
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
}
|
538 |
-
}
|
539 |
-
}
|
540 |
-
else {
|
541 |
|
542 |
-
|
543 |
-
err.message = rtmedia_file_extension_error_msg;
|
544 |
-
}
|
545 |
|
546 |
-
|
547 |
-
|
|
|
|
|
|
|
|
|
|
|
548 |
|
549 |
-
jQuery( '.plupload_delete' ).on( 'click', function ( e ) {
|
550 |
-
e.preventDefault();
|
551 |
-
jQuery( this ).parent().parent( 'li' ).remove();
|
552 |
} );
|
553 |
-
return false;
|
554 |
|
555 |
-
|
556 |
-
|
557 |
-
jQuery( '.start-media-upload' ).on( 'click', function ( e ) {
|
558 |
-
e.preventDefault();
|
559 |
-
|
560 |
-
/**
|
561 |
-
* To check if any media file is selected or not for uploading
|
562 |
-
*/
|
563 |
-
if( jQuery( '#rtmedia_uploader_filelist').children( 'li').length > 0 ) {
|
564 |
-
var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true );
|
565 |
|
566 |
-
if (
|
567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
}
|
569 |
-
uploaderObj.uploadFiles();
|
570 |
-
}
|
571 |
-
} );
|
572 |
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
if ( file.percent == 100 ) {
|
579 |
-
$( "#" + file.id ).toggleClass( 'upload-success' );
|
580 |
-
}
|
581 |
|
582 |
-
|
583 |
-
var message = rtmedia_upload_progress_error_message;
|
584 |
-
return message;
|
585 |
-
};
|
586 |
-
} );
|
587 |
|
588 |
-
|
589 |
-
|
590 |
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
up.settings.multipart_params.redirect = up.files.length;
|
603 |
-
jQuery( "#rtmedia-uploader-form input[type=hidden]" ).each( function () {
|
604 |
-
up.settings.multipart_params[$( this ).attr( "name" )] = $( this ).val();
|
605 |
} );
|
606 |
-
up.settings.multipart_params.activity_id = activity_id;
|
607 |
-
if ( $( '#rtmedia-uploader-form .rtmedia-user-album-list' ).length > 0 )
|
608 |
-
up.settings.multipart_params.album_id = $( '#rtmedia-uploader-form .rtmedia-user-album-list' ).find( ":selected" ).val();
|
609 |
-
else if ( $( '#rtmedia-uploader-form .rtmedia-current-album' ).length > 0 )
|
610 |
-
up.settings.multipart_params.album_id = $( '#rtmedia-uploader-form .rtmedia-current-album' ).val();
|
611 |
|
612 |
-
|
613 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
614 |
|
615 |
-
|
616 |
-
|
617 |
-
|
|
|
|
|
618 |
|
619 |
-
|
620 |
-
|
621 |
-
|
|
|
|
|
|
|
|
|
622 |
}
|
623 |
-
}
|
624 |
-
var rtnObj;
|
625 |
-
try {
|
626 |
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
634 |
}
|
635 |
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
if (
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
}
|
|
|
|
|
648 |
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
|
|
|
|
|
|
654 |
|
655 |
-
|
656 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
657 |
|
|
|
|
|
|
|
658 |
|
659 |
-
|
|
|
|
|
|
|
|
|
660 |
|
661 |
-
|
|
|
662 |
|
663 |
-
|
664 |
-
uploaderObj.uploadFiles( e );
|
665 |
-
} );
|
666 |
-
$( "#rtMedia-start-upload" ).hide();
|
667 |
|
668 |
-
jQuery( document ).on( 'click', '#rtm_show_upload_ui', function () {
|
669 |
-
jQuery( '#rtm-media-gallery-uploader' ).slideToggle();
|
670 |
uploaderObj.uploader.refresh();//refresh the uploader for opera/IE fix on media page
|
671 |
-
jQuery( '#rtm_show_upload_ui' ).toggleClass( 'primary' );
|
672 |
-
} );
|
673 |
-
} else {
|
674 |
-
jQuery( document ).on( 'click', '#rtm_show_upload_ui', function () {
|
675 |
-
jQuery( '#rtm-media-gallery-uploader' ).slideToggle();
|
676 |
-
jQuery( '#rtm_show_upload_ui' ).toggleClass( 'primary' );
|
677 |
-
} );
|
678 |
-
}
|
679 |
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
var media_id = $( this ).attr( 'id' );
|
685 |
-
var data = {
|
686 |
-
action: 'delete_uploaded_media',
|
687 |
-
nonce: nonce,
|
688 |
-
media_id: media_id
|
689 |
-
}
|
690 |
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
|
|
|
|
|
|
|
|
696 |
} );
|
697 |
}
|
698 |
-
} );
|
699 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
700 |
|
701 |
} );
|
702 |
|
@@ -756,7 +757,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
756 |
$( '#rtmedia-whts-new-upload-container > div' ).css( 'left', '0' );
|
757 |
|
758 |
//Enable 'post update' button when media get select
|
759 |
-
$( '#aw-whats-new-submit' ).prop("disabled", false);
|
760 |
} );
|
761 |
//whats-new-post-in
|
762 |
|
@@ -834,7 +835,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
834 |
jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ).hide();
|
835 |
|
836 |
// show/create text box to edit media title
|
837 |
-
if( jQuery( rtm_file_title_input ).length === 0 ) {
|
838 |
jQuery( rtm_file_label ).parent( '.plupload_file_name' ).prepend( '<div id="' + rtm_file_title_wrapper_id + '" class="rtm-upload-edit-title-wrapper"><label>' + rtmedia_edit_media_info_upload.title + '</label><input type="text" class="rtm-upload-edit-title" id="' + rtm_file_title_id + '" value="' + file.title + '" style="width: 75%;" /></div><div id="' + rtm_file_desc_wrapper_id + '" class="rtm-upload-edit-desc-wrapper"><label>' + rtmedia_edit_media_info_upload.description + '</label><textarea class="rtm-upload-edit-desc" id="' + rtm_file_desc_id + '"></textarea></div><span id="' + rtm_file_save_id + '" title="Save Change" class="rtmicon dashicons dashicons-yes"></span>' );
|
839 |
} else {
|
840 |
jQuery( rtm_file_title_wrapper ).show();
|
@@ -844,17 +845,17 @@ jQuery( document ).ready( function ( $ ) {
|
|
844 |
|
845 |
jQuery( rtm_file_title_input ).focus();
|
846 |
|
847 |
-
jQuery( rtm_file_save_el).click( function(){
|
848 |
var file_title_val = jQuery( rtm_file_title_input ).val();
|
849 |
var file_desc_val = jQuery( rtm_file_desc_input ).val();
|
850 |
var file_name_wrapper_el = jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' );
|
851 |
|
852 |
-
if( file_title_val != '' ){
|
853 |
file_name_wrapper_el.text( file_title_val + "." + rtm_file_name_array[ 1 ] );
|
854 |
file.title = file_title_val;
|
855 |
}
|
856 |
|
857 |
-
if( file_desc_val != '' ){
|
858 |
file.description = file_desc_val;
|
859 |
}
|
860 |
|
@@ -869,15 +870,16 @@ jQuery( document ).ready( function ( $ ) {
|
|
869 |
} );
|
870 |
|
871 |
$.each( objUploadView.upload_remove_array, function ( i, rfile ) {
|
872 |
-
if ( upl.getFile( rfile ) )
|
873 |
upl.removeFile( upl.getFile( rfile ) );
|
|
|
874 |
} );
|
875 |
|
876 |
-
if( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' && jQuery.trim( jQuery( "#whats-new" ).val() ) != "" ) {
|
877 |
//Call upload event direct when direct upload is enabled (removed UPLOAD button and its triggered event)
|
878 |
var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true );
|
879 |
|
880 |
-
if( allow_upload == false ) {
|
881 |
return false;
|
882 |
}
|
883 |
|
@@ -891,10 +893,10 @@ jQuery( document ).ready( function ( $ ) {
|
|
891 |
|
892 |
if ( ieversion < 10 ) {
|
893 |
try {
|
894 |
-
if ( typeof JSON.parse( res.response ) !== "undefined" )
|
895 |
res.status = 200;
|
896 |
-
|
897 |
-
catch ( e ) {
|
898 |
}
|
899 |
}
|
900 |
}
|
@@ -906,7 +908,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
906 |
activity_attachemnt_ids.push( val );
|
907 |
if ( $( "#whats-new-form" ).find( "#rtmedia_attached_id_" + val ).length < 1 ) {
|
908 |
$( "#whats-new-form" ).append( "<input type='hidden' name='rtMedia_attached_files[]' data-mode='rtMedia-update' id='rtmedia_attached_id_" + val + "' value='"
|
909 |
-
|
910 |
}
|
911 |
} );
|
912 |
} catch ( e ) {
|
@@ -929,8 +931,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
929 |
rtmedia_selected_file_list( plupload, err.file, up, err );
|
930 |
}
|
931 |
}
|
932 |
-
}
|
933 |
-
else {
|
934 |
if ( err.code == - 601 ) { // file extension error
|
935 |
err.message = rtmedia_file_extension_error_msg;
|
936 |
}
|
@@ -950,14 +951,14 @@ jQuery( document ).ready( function ( $ ) {
|
|
950 |
objUploadView.uploader.bind( 'BeforeUpload', function ( up, files ) {
|
951 |
|
952 |
$.each( objUploadView.upload_remove_array, function ( i, rfile ) {
|
953 |
-
if ( up.getFile( rfile ) )
|
954 |
-
up.removeFile( up.getFile( rfile ) );
|
955 |
} );
|
956 |
|
957 |
var object = '';
|
958 |
var item_id = jQuery( "#whats-new-post-in" ).val();
|
959 |
-
if ( item_id == undefined )
|
960 |
-
item_id = 0;
|
961 |
if ( item_id > 0 ) {
|
962 |
object = "group";
|
963 |
} else {
|
@@ -968,7 +969,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
968 |
up.settings.multipart_params.context_id = item_id;
|
969 |
up.settings.multipart_params.title = files.title.split( '.' )[ 0 ];
|
970 |
|
971 |
-
if( typeof files.description != "undefined" ){
|
972 |
up.settings.multipart_params.description = files.description;
|
973 |
} else {
|
974 |
up.settings.multipart_params.description = '';
|
@@ -1022,15 +1023,15 @@ jQuery( document ).ready( function ( $ ) {
|
|
1022 |
while ( activity_attachemnt_ids.length > 0 ) {
|
1023 |
options.data += "&rtMedia_attached_files[]=" + activity_attachemnt_ids.pop();
|
1024 |
}
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
options.data += "&rtmedia-privacy=" + dynamic_privacy;
|
1035 |
activity_attachemnt_ids = temp;
|
1036 |
|
@@ -1041,9 +1042,9 @@ jQuery( document ).ready( function ( $ ) {
|
|
1041 |
*/
|
1042 |
var allowActivityPost = rtMediaHook.call( 'rtmedia_js_before_activity_added', true );
|
1043 |
|
1044 |
-
if( !allowActivityPost ) {
|
1045 |
-
$( '#rtmedia_upload_terms_conditions').removeAttr( 'disabled' );
|
1046 |
-
$( '#rtmedia-whts-new-upload-container').find('input').removeAttr( 'disabled' );
|
1047 |
|
1048 |
return false;
|
1049 |
}
|
@@ -1054,8 +1055,8 @@ jQuery( document ).ready( function ( $ ) {
|
|
1054 |
*Added $nbsp; as activity text to post activity without TEXT
|
1055 |
* Disabled TextBox color(transparent)
|
1056 |
*/
|
1057 |
-
$( "#whats-new").css('color', 'transparent');
|
1058 |
-
$( "#whats-new" ).val(' ');
|
1059 |
}
|
1060 |
}
|
1061 |
if ( ! media_uploading && objUploadView.uploader.files.length > 0 ) {
|
@@ -1069,7 +1070,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
1069 |
return true;
|
1070 |
}
|
1071 |
|
1072 |
-
|
1073 |
}
|
1074 |
options.success = function ( response ) {
|
1075 |
orignalSuccess( response );
|
@@ -1108,7 +1108,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
1108 |
$( "#whats-new-post-in" ).removeAttr( 'disabled' );
|
1109 |
$( "#rtmedia-add-media-button-post-update" ).removeAttr( 'disabled' );
|
1110 |
// Enabled TextBox color back to normal
|
1111 |
-
$( "#whats-new").css('color', '');
|
1112 |
|
1113 |
}
|
1114 |
}
|
@@ -1125,14 +1125,14 @@ jQuery( document ).ready( function ( $ ) {
|
|
1125 |
}
|
1126 |
|
1127 |
if ( originalOptions.data.action == 'post_update' || originalOptions.data.action == 'activity_widget_filter' ) {
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
options.data += "&rtmedia-privacy=" + dynamic_privacy;
|
1137 |
var orignalSuccess = originalOptions.success;
|
1138 |
options.success = function ( response ) {
|
@@ -1147,7 +1147,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
1147 |
|
1148 |
$( "#whats-new-post-in" ).removeAttr( 'disabled' );
|
1149 |
// Enabled TextBox color back to normal
|
1150 |
-
$( "#whats-new").css('color', '');
|
1151 |
|
1152 |
}
|
1153 |
}
|
@@ -1159,6 +1159,10 @@ jQuery( document ).ready( function ( $ ) {
|
|
1159 |
*/
|
1160 |
jQuery( document ).ready( function ( $ ) {
|
1161 |
jQuery( document ).on( "click", "#rt_media_comment_form #rt_media_comment_submit", function ( e ) {
|
|
|
|
|
|
|
|
|
1162 |
e.preventDefault();
|
1163 |
if ( $.trim( $( "#comment_content" ).val() ) == "" ) {
|
1164 |
rtmedia_single_media_alert_message( rtmedia_empty_comment_msg, 'warning' );
|
@@ -1167,20 +1171,22 @@ jQuery( document ).ready( function ( $ ) {
|
|
1167 |
|
1168 |
$( this ).attr( 'disabled', 'disabled' );
|
1169 |
|
|
|
|
|
|
|
1170 |
$.ajax( {
|
1171 |
-
url:
|
1172 |
type: 'post',
|
1173 |
-
data:
|
1174 |
success: function ( data ) {
|
1175 |
$( '#rtmedia-no-comments' ).remove();
|
1176 |
$( "#rtmedia_comment_ul" ).append( data );
|
1177 |
-
|
1178 |
-
$(
|
1179 |
rtMediaHook.call( 'rtmedia_js_after_comment_added', [ ] );
|
1180 |
}
|
1181 |
} );
|
1182 |
|
1183 |
-
|
1184 |
return false;
|
1185 |
} );
|
1186 |
|
@@ -1189,8 +1195,9 @@ jQuery( document ).ready( function ( $ ) {
|
|
1189 |
e.preventDefault();
|
1190 |
var ask_confirmation = true
|
1191 |
ask_confirmation = rtMediaHook.call( 'rtmedia_js_delete_comment_confirmation', [ ask_confirmation ] );
|
1192 |
-
if ( ask_confirmation && ! confirm( rtmedia_media_comment_delete_confirmation ) )
|
1193 |
return false;
|
|
|
1194 |
var current_comment = jQuery( this );
|
1195 |
var current_comment_parent = current_comment.parent();
|
1196 |
var comment_id = current_comment.data( 'id' );
|
@@ -1221,7 +1228,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
1221 |
$( document ).on( "click", '.rtmedia-like', function ( e ) {
|
1222 |
e.preventDefault();
|
1223 |
var that = this;
|
1224 |
-
var like_nonce = $(this).siblings('#rtm_media_like_nonce').val();
|
1225 |
$( this ).attr( 'disabled', 'disabled' );
|
1226 |
var url = $( this ).parent().attr( "action" );
|
1227 |
$( that ).prepend( "<img class='rtm-like-loading' src='" + rMedia_loading_file + "' style='width:10px' />" );
|
@@ -1248,13 +1255,12 @@ jQuery( document ).ready( function ( $ ) {
|
|
1248 |
}
|
1249 |
} );
|
1250 |
|
1251 |
-
|
1252 |
} );
|
1253 |
$( document ).on( "click", '.rtmedia-featured, .rtmedia-group-featured', function ( e ) {
|
1254 |
e.preventDefault();
|
1255 |
var that = this;
|
1256 |
$( this ).attr( 'disabled', 'disabled' );
|
1257 |
-
var featured_nonce = $(this).siblings('#rtm_media_featured_nonce').val();
|
1258 |
var url = $( this ).parent().attr( "action" );
|
1259 |
$( that ).prepend( "<img class='rtm-featured-loading' src='" + rMedia_loading_file + "' />" );
|
1260 |
$.ajax( {
|
@@ -1268,13 +1274,13 @@ jQuery( document ).ready( function ( $ ) {
|
|
1268 |
|
1269 |
}
|
1270 |
|
1271 |
-
if ( data.nonce ){
|
1272 |
-
rtmedia_single_media_alert_message( rtmedia_something_wrong_msg, 'warning');
|
1273 |
} else {
|
1274 |
if (data.action) {
|
1275 |
-
rtmedia_single_media_alert_message(rtmedia_set_featured_image_msg, 'success');
|
1276 |
} else {
|
1277 |
-
rtmedia_single_media_alert_message(rtmedia_unset_featured_image_msg, 'success');
|
1278 |
}
|
1279 |
}
|
1280 |
$( that ).find( 'span' ).html( data.next );
|
@@ -1283,7 +1289,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
1283 |
}
|
1284 |
} );
|
1285 |
|
1286 |
-
|
1287 |
} );
|
1288 |
jQuery( "#div-attache-rtmedia" ).find( "input[type=file]" ).each( function () {
|
1289 |
//$(this).attr("capture", "camera");
|
@@ -1299,33 +1304,33 @@ jQuery( document ).ready( function ( $ ) {
|
|
1299 |
} );
|
1300 |
|
1301 |
function rtmedia_selected_file_list( plupload, file, uploader, error ) {
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
upload_progress = '<div class="plupload_file_progress ui-widget-header" style="width: 0%;">';
|
1306 |
upload_progress += '</div>';
|
1307 |
-
|
1308 |
} else if ( error.code == - 600 ) {
|
1309 |
err_msg = ( uploader != '' ) ? rtmedia_max_file_msg + uploader.settings.max_file_size : window.file_size_info;
|
1310 |
-
|
1311 |
-
|
1312 |
} else if ( error.code == - 601 ) {
|
1313 |
err_msg = error.message + '. ' + window.file_extn_info;
|
1314 |
-
|
1315 |
-
|
1316 |
}
|
1317 |
-
|
1318 |
var rtmedia_plupload_file = '<li class="plupload_file ui-state-default plupload_queue_li" id="' + file.id + '" ' + title + '>';
|
1319 |
rtmedia_plupload_file += '<div id="file_thumb_' + file.id + '" class="plupload_file_thumb">';
|
1320 |
rtmedia_plupload_file += '</div>';
|
1321 |
rtmedia_plupload_file += '<div class="plupload_file_status">';
|
1322 |
-
|
1323 |
rtmedia_plupload_file += '</div>';
|
1324 |
rtmedia_plupload_file += '<div class="plupload_file_name" title="' + ( file.name ? file.name : '' ) + '">';
|
1325 |
rtmedia_plupload_file += '<span class="plupload_file_name_wrapper">';
|
1326 |
rtmedia_plupload_file += ( file.name ? file.name : '' );
|
1327 |
rtmedia_plupload_file += '</span>';
|
1328 |
-
|
1329 |
rtmedia_plupload_file += '</div>';
|
1330 |
rtmedia_plupload_file += '<div class="plupload_file_action">';
|
1331 |
rtmedia_plupload_file += '<div class="plupload_action_icon ui-icon plupload_delete">';
|
@@ -1341,41 +1346,41 @@ function rtmedia_selected_file_list( plupload, file, uploader, error ) {
|
|
1341 |
|
1342 |
jQuery( rtmedia_plupload_file ).appendTo( '#rtmedia_uploader_filelist' );
|
1343 |
var type = file.type;
|
1344 |
-
|
1345 |
-
|
1346 |
|
1347 |
if ( /image/i.test( type ) ) {
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
} else {
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
}
|
27 |
rtMedia.Context = Backbone.Model.extend( {
|
28 |
url: function () {
|
29 |
var url = rtmedia_media_slug + "/";
|
30 |
+
|
31 |
+
if ( ! upload_sync && nextpage > 0 ) {
|
32 |
+
url += 'pg/' + nextpage + '/';
|
33 |
+
}
|
34 |
+
|
35 |
return url;
|
36 |
},
|
37 |
defaults: {
|
77 |
if ( temp.indexOf( "/" + rtmedia_media_slug + "/" ) == - 1 ) {
|
78 |
url = rtmedia_media_slug + '/';
|
79 |
} else {
|
80 |
+
if ( temp.indexOf( 'pg/' ) == - 1 ) {
|
81 |
url = temp;
|
82 |
+
} else {
|
83 |
url = window.location.pathname.substr( 0, window.location.pathname.lastIndexOf( "pg/" ) );
|
84 |
+
}
|
85 |
}
|
86 |
if ( ! upload_sync && nextpage > 1 ) {
|
87 |
+
if ( url.substr( url.length - 1 ) != "/" ) {
|
88 |
+
url += "/";
|
89 |
+
}
|
90 |
+
|
91 |
url += 'pg/' + nextpage + '/';
|
92 |
}
|
93 |
return url;
|
104 |
if ( jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=lightbox]' ).length > 0 ) {
|
105 |
template_url += '&lightbox=' + jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=lightbox]' ).val();
|
106 |
}
|
107 |
+
$( "#rtmedia-gallery-item-template" ).load( template_url, { backbone: true, is_album: o_is_album, is_edit_allowed: o_is_edit_allowed }, function () {
|
|
|
|
|
|
|
|
|
108 |
rtmedia_load_template_flag = false;
|
109 |
that.getNext( page, el, element );
|
110 |
} );
|
119 |
el = jQuery( ".rtmedia-list" ).parent().parent();
|
120 |
}
|
121 |
|
122 |
+
if ( el != undefined ) {
|
123 |
+
if ( element != undefined ) {
|
124 |
+
$( element ).parent().parent().prevAll( "input[type=hidden]" ).not( "input[name=_wp_http_referer], input[name=rtmedia_media_delete_nonce], input[name=rtmedia_bulk_delete_nonce], input[name=bulk-action], input[name=rtmedia_create_album_nonce], input[name=rtmedia_media_nonce], input[name=rtmedia_upload_nonce], input[name=rtmedia_allow_upload_attribute]" ).each( function ( e ) {
|
125 |
+
if ( $( this ).attr( "name" ) ) {
|
126 |
+
query[ $( this ).attr( "name" ) ] = $( this ).val();
|
127 |
+
}
|
128 |
+
} );
|
129 |
+
}
|
130 |
+
|
131 |
+
$( el ).find( "input[type=hidden]" ).not( "input[name=_wp_http_referer], input[name=rtmedia_media_delete_nonce], input[name=rtmedia_bulk_delete_nonce], input[name=bulk-action], input[name=rtmedia_create_album_nonce], input[name=rtmedia_media_nonce], input[name=rtmedia_upload_nonce], input[name=rtmedia_allow_upload_attribute]" ).each( function ( e ) {
|
132 |
+
if ( $( this ).attr( "name" ) ) {
|
133 |
+
query[ $( this ).attr( "name" ) ] = $( this ).val();
|
134 |
+
}
|
135 |
+
} );
|
136 |
+
}
|
137 |
|
138 |
this.fetch( {
|
139 |
data: query,
|
140 |
success: function ( model, response ) {
|
141 |
jQuery( '.rtm-media-loading' ).hide();
|
142 |
var list_el = "";
|
143 |
+
|
144 |
+
if ( typeof ( element ) === "undefined" ) {
|
145 |
list_el = $( ".rtmedia-list" )[0];
|
146 |
+
} else {
|
147 |
list_el = element.parent().siblings( '.rtmedia-list' );
|
148 |
+
}
|
149 |
+
|
150 |
nextpage = response.next;
|
151 |
|
152 |
if ( nextpage < 1 ) {
|
179 |
jQuery( '.rtmedia-container .rtmedia-list' ).css( 'opacity', '0.5' );
|
180 |
this.getNext();
|
181 |
}
|
|
|
|
|
182 |
} );
|
183 |
|
184 |
rtMedia.MediaView = Backbone.View.extend( {
|
245 |
}
|
246 |
} );
|
247 |
|
|
|
248 |
galleryObj = new rtMedia.Gallery();
|
249 |
|
250 |
$( "body" ).append( '<script id="rtmedia-gallery-item-template" type="text/template"></script>' );
|
259 |
e.preventDefault();
|
260 |
galleryObj.getNext( nextpage, $( this ).parent().parent().parent(), $( this ) );
|
261 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
+
$( document ).on( "keypress", "#rtmedia_go_to_num", function( e ) {
|
264 |
+
if ( e.keyCode == 13 ) {
|
265 |
+
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
+
if ( jQuery( '.rtm-media-loading' ).length == 0 ) {
|
268 |
+
$( '.rtm-pagination' ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" );
|
269 |
+
} else {
|
270 |
+
jQuery( '.rtm-media-loading' ).show();
|
271 |
+
}
|
|
|
272 |
|
273 |
+
if ( parseInt( $( '#rtmedia_go_to_num' ).val() ) > parseInt( $( '#rtmedia_last_page' ).val() ) ) {
|
274 |
+
nextpage = parseInt( $( '#rtmedia_last_page' ).val() );
|
275 |
+
} else {
|
276 |
+
nextpage = parseInt( $( '#rtmedia_go_to_num' ).val() );
|
277 |
+
}
|
|
|
278 |
|
279 |
+
galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() );
|
280 |
|
281 |
+
return false;
|
282 |
+
}
|
283 |
+
} );
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
+
$( document ).on( "click", ".rtmedia-page-link", function ( e ) {
|
286 |
+
if ( jQuery( '.rtm-media-loading' ).length == 0 ) {
|
287 |
+
$( '.rtm-pagination' ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" );
|
288 |
+
} else {
|
289 |
+
jQuery( '.rtm-media-loading' ).show();
|
290 |
+
}
|
291 |
+
|
292 |
+
e.preventDefault();
|
293 |
+
if ( $( this ).data( 'page-type' ) == 'page' ) {
|
294 |
+
nextpage = $( this ).data( 'page' );
|
295 |
+
} else if ( $( this ).data( 'page-type' ) == 'prev' ) {
|
296 |
+
if ( nextpage == - 1 ) {
|
297 |
+
nextpage = parseInt( $( '#rtmedia_last_page' ).val() ) - 1;
|
298 |
+
} else {
|
299 |
+
nextpage -= 2;
|
300 |
+
}
|
301 |
+
} else if ( $( this ).data( 'page-type' ) == 'num' ) {
|
302 |
+
if ( parseInt( $( '#rtmedia_go_to_num' ).val() ) > parseInt( $( '#rtmedia_last_page' ).val() ) ) {
|
303 |
+
nextpage = parseInt( $( '#rtmedia_last_page' ).val() );
|
304 |
} else {
|
305 |
+
nextpage = parseInt( $( '#rtmedia_go_to_num' ).val() );
|
306 |
}
|
307 |
+
}
|
308 |
|
309 |
+
if ( $( this ).data( 'page-type' ) == 'num' ) {
|
310 |
+
galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() );
|
311 |
+
} else {
|
312 |
+
galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() );
|
313 |
}
|
314 |
+
} );
|
315 |
|
316 |
+
if ( window.location.pathname.indexOf( rtmedia_media_slug ) != - 1 ) {
|
317 |
+
var tempNext = window.location.pathname.substring( window.location.pathname.lastIndexOf( "pg/" ) + 5, window.location.pathname.lastIndexOf( "/" ) );
|
318 |
+
if ( isNaN( tempNext ) === false ) {
|
319 |
+
nextpage = parseInt( tempNext ) + 1;
|
320 |
+
}
|
|
|
|
|
321 |
}
|
322 |
|
323 |
+
window.UploadView = Backbone.View.extend( {
|
324 |
+
events: {
|
325 |
+
"click #rtMedia-start-upload": "uploadFiles"
|
326 |
+
},
|
327 |
+
initialize: function ( config ) {
|
328 |
+
this.uploader = new plupload.Uploader( config );
|
329 |
+
},
|
330 |
+
render: function () {
|
331 |
+
|
332 |
+
},
|
333 |
+
initUploader: function ( a ) {
|
334 |
+
if ( typeof ( a ) !== "undefined" ) {
|
335 |
+
a = false;// if rtmediapro widget calls the function, dont show max size note.
|
336 |
+
} this.uploader.init();
|
337 |
+
//The plupload HTML5 code gives a negative z-index making add files button unclickable
|
338 |
+
$( ".plupload.html5" ).css( {
|
339 |
+
zIndex: 0
|
340 |
+
} );
|
341 |
+
$( "#rtMedia-upload-button" ).css( {
|
342 |
+
zIndex: 2
|
343 |
+
} );
|
344 |
+
if ( a !== false ) {
|
345 |
+
window.file_size_info = rtmedia_max_file_msg + this.uploader.settings.max_file_size_msg;
|
346 |
+
if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9
|
347 |
+
file_extn = this.uploader.settings.filters.mime_types[0].extensions;
|
348 |
+
} else {
|
349 |
+
file_extn = this.uploader.settings.filters[0].extensions;
|
350 |
+
}
|
351 |
+
window.file_extn_info = rtmedia_allowed_file_formats + " : " + file_extn.split( ',' ).join( ', ' );
|
352 |
|
353 |
+
var info = window.file_size_info + "\n" + window.file_extn_info;
|
354 |
+
$( ".rtm-file-size-limit" ).attr( 'title', info );
|
355 |
+
//$("#rtMedia-upload-button").after("<span>( <strong>" + rtmedia_max_file_msg + "</strong> "+ this.uploader.settings.max_file_size_msg + ")</span>");
|
356 |
+
}
|
357 |
|
358 |
+
return this;
|
359 |
+
},
|
360 |
+
uploadFiles: function ( e ) {
|
361 |
+
if ( e != undefined ) {
|
362 |
+
e.preventDefault();
|
|
|
363 |
}
|
364 |
+
this.uploader.start();
|
365 |
+
return false;
|
366 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
+
} );
|
369 |
|
370 |
+
if ( $( "#rtMedia-upload-button" ).length > 0 ) {
|
371 |
+
if ( typeof rtmedia_upload_type_filter == "object" && rtmedia_upload_type_filter.length > 0 ) {
|
372 |
+
rtMedia_plupload_config.filters[0].extensions = rtmedia_upload_type_filter.join();
|
373 |
+
}
|
374 |
+
uploaderObj = new UploadView( rtMedia_plupload_config );
|
375 |
+
uploaderObj.initUploader();
|
376 |
+
|
377 |
+
uploaderObj.uploader.bind( 'UploadComplete', function ( up, files ) {
|
378 |
+
activity_id = - 1;
|
379 |
+
var hook_respo = rtMediaHook.call( 'rtmedia_js_after_files_uploaded' );
|
380 |
+
if ( typeof rtmedia_gallery_reload_on_upload != "undefined" && rtmedia_gallery_reload_on_upload == '1' ) { //reload gallery view when upload completes if enabled( by default enabled)
|
381 |
+
if ( hook_respo != false ) {
|
382 |
+
galleryObj.reloadView();
|
383 |
+
}
|
384 |
}
|
385 |
+
jQuery( '#rtmedia_uploader_filelist li.plupload_queue_li' ).remove();
|
386 |
+
jQuery( '.start-media-upload' ).hide();
|
387 |
+
apply_rtMagnificPopup( jQuery( '.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' ) );
|
388 |
+
window.onbeforeunload = null;
|
389 |
+
} );
|
390 |
|
391 |
+
uploaderObj.uploader.bind( 'FilesAdded', function ( up, files ) {
|
392 |
+
var upload_size_error = false;
|
393 |
+
var upload_error = "";
|
394 |
+
var upload_error_sep = "";
|
395 |
+
var upload_remove_array = [ ];
|
396 |
+
$.each( files, function ( i, file ) {
|
397 |
+
//set file title along with file
|
398 |
+
rtm_file_name_array = file.name.split( '.' );
|
399 |
+
file.title = rtm_file_name_array[0];
|
400 |
+
|
401 |
+
var hook_respo = rtMediaHook.call( 'rtmedia_js_file_added', [ up, file, "#rtmedia_uploader_filelist" ] );
|
402 |
+
|
403 |
+
if ( hook_respo == false ) {
|
404 |
+
file.status = - 1;
|
405 |
+
upload_remove_array.push( file.id );
|
|
|
|
|
|
|
|
|
406 |
return true;
|
407 |
}
|
|
|
|
|
|
|
408 |
|
409 |
+
jQuery( '.rtmedia-upload-input' ).attr( 'value', rtmedia_add_more_files_msg );
|
410 |
+
if ( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' ) {
|
411 |
+
jQuery( '.start-media-upload' ).hide();
|
412 |
+
} else {
|
413 |
+
jQuery( '.start-media-upload' ).show();
|
414 |
+
}
|
415 |
+
if ( uploaderObj.uploader.settings.max_file_size < file.size ) {
|
416 |
+
return true;
|
417 |
+
}
|
418 |
+
var tmp_array = file.name.split( "." );
|
419 |
+
if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9
|
420 |
+
var ext_array = uploaderObj.uploader.settings.filters.mime_types[0].extensions.split( ',' );
|
421 |
+
} else {
|
422 |
+
var ext_array = uploaderObj.uploader.settings.filters[0].extensions.split( ',' );
|
423 |
+
}
|
424 |
+
if ( tmp_array.length > 1 ) {
|
425 |
+
var ext = tmp_array[tmp_array.length - 1];
|
426 |
+
ext = ext.toLowerCase();
|
427 |
+
if ( jQuery.inArray( ext, ext_array ) === - 1 ) {
|
428 |
+
return true;
|
429 |
+
}
|
430 |
+
} else {
|
431 |
+
return true;
|
432 |
+
}
|
433 |
|
434 |
+
if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9
|
435 |
+
uploaderObj.uploader.settings.filters.mime_types[0].title;
|
436 |
+
} else {
|
437 |
+
uploaderObj.uploader.settings.filters[0].title;
|
438 |
+
}
|
439 |
|
440 |
+
// Creating list of media to preview selected files
|
441 |
+
rtmedia_selected_file_list( plupload, file, '', '' );
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
|
443 |
+
//Delete Function
|
444 |
+
$( "#" + file.id + " .plupload_delete .remove-from-queue" ).click( function ( e ) {
|
445 |
+
e.preventDefault();
|
446 |
+
uploaderObj.uploader.removeFile( up.getFile( file.id ) );
|
447 |
+
$( "#" + file.id ).remove();
|
448 |
+
rtMediaHook.call( 'rtmedia_js_file_remove', [ up, file ] );
|
449 |
+
return false;
|
450 |
+
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
+
// To change the name of the uploading file
|
453 |
+
$( "#label_" + file.id ).click( function ( e ) {
|
454 |
+
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
|
456 |
+
rtm_file_label = this;
|
457 |
|
458 |
+
rtm_file_title_id = 'text_' + file.id;
|
459 |
+
rtm_file_title_input = '#' + rtm_file_title_id;
|
460 |
+
rtm_file_title_wrapper_id = 'rtm_title_wp_' + file.id;
|
461 |
+
rtm_file_title_wrapper = '#' + rtm_file_title_wrapper_id;
|
462 |
|
463 |
+
rtm_file_desc_id = 'rtm_desc_' + file.id;
|
464 |
+
rtm_file_desc_input = '#' + rtm_file_desc_id;
|
465 |
+
rtm_file_desc_wrapper_id = 'rtm_desc_wp_' + file.id;
|
466 |
+
rtm_file_desc_wrapper = '#' + rtm_file_desc_wrapper_id;
|
467 |
+
|
468 |
+
rtm_file_save_id = 'save_' + file.id;
|
469 |
+
rtm_file_save_el = '#' + rtm_file_save_id;
|
470 |
+
|
471 |
+
jQuery( rtm_file_label ).hide();
|
472 |
+
jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ).hide();
|
473 |
+
|
474 |
+
// show/create text box to edit media title
|
475 |
+
if ( jQuery( rtm_file_title_input ).length === 0 ) {
|
476 |
+
jQuery( rtm_file_label ).parent( '.plupload_file_name' ).prepend( '<div id="' + rtm_file_title_wrapper_id + '" class="rtm-upload-edit-title-wrapper"><label>' + rtmedia_edit_media_info_upload.title + '</label><input type="text" class="rtm-upload-edit-title" id="' + rtm_file_title_id + '" value="' + file.title + '" style="width: 75%;" /></div><div id="' + rtm_file_desc_wrapper_id + '" class="rtm-upload-edit-desc-wrapper"><label>' + rtmedia_edit_media_info_upload.description + '</label><textarea class="rtm-upload-edit-desc" id="' + rtm_file_desc_id + '"></textarea></div><span id="' + rtm_file_save_id + '" title="Save Change" class="rtmicon dashicons dashicons-yes"></span>' );
|
477 |
+
} else {
|
478 |
+
jQuery( rtm_file_title_wrapper ).show();
|
479 |
+
jQuery( rtm_file_desc_wrapper ).show();
|
480 |
+
jQuery( rtm_file_save_el ).show();
|
481 |
+
}
|
482 |
+
|
483 |
+
jQuery( rtm_file_title_input ).focus();
|
484 |
+
|
485 |
+
// set media title and description in file object
|
486 |
+
jQuery( rtm_file_save_el ).click( function(){
|
487 |
+
var file_title_val = jQuery( rtm_file_title_input ).val();
|
488 |
+
var file_desc_val = jQuery( rtm_file_desc_input ).val();
|
489 |
+
var file_name_wrapper_el = jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' );
|
490 |
+
|
491 |
+
if ( file_title_val != '' ) {
|
492 |
+
file_name_wrapper_el.text( file_title_val + "." + rtm_file_name_array[ 1 ] );
|
493 |
+
file.title = file_title_val;
|
494 |
+
}
|
495 |
+
|
496 |
+
if ( file_desc_val != '' ) {
|
497 |
+
file.description = file_desc_val;
|
498 |
+
}
|
499 |
+
|
500 |
+
jQuery( rtm_file_title_wrapper ).hide();
|
501 |
+
jQuery( rtm_file_desc_wrapper ).hide();
|
502 |
+
file_name_wrapper_el.show();
|
503 |
+
jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' )
|
504 |
+
jQuery( rtm_file_label ).show();
|
505 |
+
jQuery( this ).hide();
|
506 |
+
} );
|
507 |
+
} );
|
508 |
+
} );
|
509 |
+
|
510 |
+
$.each( upload_remove_array, function ( i, rfile ) {
|
511 |
+
if ( up.getFile( rfile ) ) {
|
512 |
+
up.removeFile( up.getFile( rfile ) );
|
513 |
}
|
514 |
+
} );
|
|
|
|
|
515 |
|
516 |
+
rtMediaHook.call( 'rtmedia_js_after_files_added', [ up, files ] );
|
|
|
|
|
517 |
|
518 |
+
if ( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' ) {
|
519 |
+
var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true );
|
520 |
+
if ( allow_upload == false ) {
|
521 |
+
return false;
|
522 |
+
}
|
523 |
+
uploaderObj.uploadFiles();
|
524 |
+
}
|
525 |
|
|
|
|
|
|
|
526 |
} );
|
|
|
527 |
|
528 |
+
uploaderObj.uploader.bind( 'Error', function ( up, err ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
|
530 |
+
if ( err.code == - 600 ) { //file size error // if file size is greater than server's max allowed size
|
531 |
+
var tmp_array;
|
532 |
+
var ext = tr = '';
|
533 |
+
tmp_array = err.file.name.split( "." );
|
534 |
+
if ( tmp_array.length > 1 ) {
|
535 |
+
ext = tmp_array[tmp_array.length - 1];
|
536 |
+
if ( ! ( typeof ( up.settings.upload_size ) != "undefined" && typeof ( up.settings.upload_size[ext] ) != "undefined" && typeof ( up.settings.upload_size[ext]['size'] ) ) ) {
|
537 |
+
rtmedia_selected_file_list( plupload, err.file, up, err );
|
538 |
+
}
|
539 |
+
}
|
540 |
+
} else {
|
541 |
+
|
542 |
+
if ( err.code == - 601 ) { // file extension error
|
543 |
+
err.message = rtmedia_file_extension_error_msg;
|
544 |
+
}
|
545 |
+
|
546 |
+
rtmedia_selected_file_list( plupload, err.file, '', err );
|
547 |
}
|
|
|
|
|
|
|
548 |
|
549 |
+
jQuery( '.plupload_delete' ).on( 'click', function ( e ) {
|
550 |
+
e.preventDefault();
|
551 |
+
jQuery( this ).parent().parent( 'li' ).remove();
|
552 |
+
} );
|
553 |
+
return false;
|
|
|
|
|
|
|
554 |
|
555 |
+
} );
|
|
|
|
|
|
|
|
|
556 |
|
557 |
+
jQuery( '.start-media-upload' ).on( 'click', function ( e ) {
|
558 |
+
e.preventDefault();
|
559 |
|
560 |
+
/**
|
561 |
+
* To check if any media file is selected or not for uploading
|
562 |
+
*/
|
563 |
+
if ( jQuery( '#rtmedia_uploader_filelist' ).children( 'li' ).length > 0 ) {
|
564 |
+
var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true );
|
565 |
|
566 |
+
if ( allow_upload == false ) {
|
567 |
+
return false;
|
568 |
+
}
|
569 |
+
uploaderObj.uploadFiles();
|
570 |
+
}
|
|
|
|
|
|
|
571 |
} );
|
|
|
|
|
|
|
|
|
|
|
572 |
|
573 |
+
uploaderObj.uploader.bind( 'UploadProgress', function ( up, file ) {
|
574 |
+
//$("#" + file.id + " .plupload_file_status").html(file.percent + "%");
|
575 |
+
//$( "#" + file.id + " .plupload_file_status" ).html( rtmedia_uploading_msg + '( ' + file.percent + '% )' );
|
576 |
+
$( "#" + file.id + " .plupload_file_status" ).html( '<div class="plupload_file_progress ui-widget-header" style="width: ' + file.percent + '%;"></div>' );
|
577 |
+
$( "#" + file.id ).addClass( 'upload-progress' );
|
578 |
+
if ( file.percent == 100 ) {
|
579 |
+
$( "#" + file.id ).toggleClass( 'upload-success' );
|
580 |
+
}
|
581 |
|
582 |
+
window.onbeforeunload = function ( evt ) {
|
583 |
+
var message = rtmedia_upload_progress_error_message;
|
584 |
+
return message;
|
585 |
+
};
|
586 |
+
} );
|
587 |
|
588 |
+
uploaderObj.uploader.bind( 'BeforeUpload', function ( up, file ) {
|
589 |
+
up.settings.multipart_params.title = file.title.split( '.' )[ 0 ];
|
590 |
+
|
591 |
+
if ( typeof file.description != "undefined" ) {
|
592 |
+
up.settings.multipart_params.description = file.description;
|
593 |
+
} else {
|
594 |
+
up.settings.multipart_params.description = '';
|
595 |
}
|
|
|
|
|
|
|
596 |
|
597 |
+
var privacy = $( "#rtm-file_upload-ui select.privacy" ).val();
|
598 |
+
if ( privacy !== undefined ) {
|
599 |
+
up.settings.multipart_params.privacy = $( "#rtm-file_upload-ui select.privacy" ).val();
|
600 |
+
}
|
601 |
+
if ( jQuery( "#rt_upload_hf_redirect" ).length > 0 ) {
|
602 |
+
up.settings.multipart_params.redirect = up.files.length;
|
603 |
+
}
|
604 |
+
jQuery( "#rtmedia-uploader-form input[type=hidden]" ).each( function () {
|
605 |
+
up.settings.multipart_params[$( this ).attr( "name" )] = $( this ).val();
|
606 |
+
} );
|
607 |
+
up.settings.multipart_params.activity_id = activity_id;
|
608 |
+
if ( $( '#rtmedia-uploader-form .rtmedia-user-album-list' ).length > 0 ) {
|
609 |
+
up.settings.multipart_params.album_id = $( '#rtmedia-uploader-form .rtmedia-user-album-list' ).find( ":selected" ).val();
|
610 |
+
} else if ( $( '#rtmedia-uploader-form .rtmedia-current-album' ).length > 0 ) {
|
611 |
+
up.settings.multipart_params.album_id = $( '#rtmedia-uploader-form .rtmedia-current-album' ).val();
|
612 |
}
|
613 |
|
614 |
+
rtMediaHook.call( 'rtmedia_js_before_file_upload', [up, file] );
|
615 |
+
} );
|
616 |
+
|
617 |
+
uploaderObj.uploader.bind( 'FileUploaded', function ( up, file, res ) {
|
618 |
+
if ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) ) { //test for MSIE x.x;
|
619 |
+
var ieversion = new Number( RegExp.$1 ) // capture x.x portion and store as a number
|
620 |
+
|
621 |
+
if ( ieversion < 10 ) {
|
622 |
+
if ( typeof res.response !== "undefined" ) {
|
623 |
+
res.status = 200; }
|
624 |
+
}
|
625 |
}
|
626 |
+
var rtnObj;
|
627 |
+
try {
|
628 |
|
629 |
+
rtnObj = JSON.parse( res.response );
|
630 |
+
uploaderObj.uploader.settings.multipart_params.activity_id = rtnObj.activity_id;
|
631 |
+
activity_id = rtnObj.activity_id;
|
632 |
+
if ( rtnObj.permalink != '' ) {
|
633 |
+
$( "#" + file.id + " .plupload_file_name" ).html( "<a href='" + rtnObj.permalink + "' target='_blank' title='" + rtnObj.permalink + "'>" + file.title.substring( 0, 40 ).replace( /(<([^>]+)>)/ig, "" ) + "</a>" );
|
634 |
+
$( "#" + file.id + " .plupload_media_edit" ).html( "<a href='" + rtnObj.permalink + "edit' target='_blank'><span title='" + rtmedia_edit_media + "'><i class='dashicons dashicons-edit rtmicon'></i> " + rtmedia_edit + "</span></a>" );
|
635 |
+
$( "#" + file.id + " .plupload_delete" ).html( "<span id='" + rtnObj.media_id + "' class='rtmedia-delete-uploaded-media' title='" + rtmedia_delete + "'>×</span>" );
|
636 |
+
}
|
637 |
|
638 |
+
} catch ( e ) {
|
639 |
+
// console.log('Invalid Activity ID');
|
640 |
+
}
|
641 |
+
if ( res.status == 200 || res.status == 302 ) {
|
642 |
+
if ( uploaderObj.upload_count == undefined ) {
|
643 |
+
uploaderObj.upload_count = 1;
|
644 |
+
} else {
|
645 |
+
uploaderObj.upload_count ++;
|
646 |
+
}
|
647 |
|
648 |
+
if ( uploaderObj.upload_count == up.files.length && jQuery( "#rt_upload_hf_redirect" ).length > 0 && jQuery.trim( rtnObj.redirect_url.indexOf( "http" ) == 0 ) ) {
|
649 |
+
window.location = rtnObj.redirect_url;
|
650 |
+
}
|
651 |
|
652 |
+
$( "#" + file.id + " .plupload_file_status" ).html( rtmedia_uploaded_msg );
|
653 |
+
rtMediaHook.call( 'rtmedia_js_after_file_upload', [ up, file, res.response ] );
|
654 |
+
} else {
|
655 |
+
$( "#" + file.id + " .plupload_file_status" ).html( rtmedia_upload_failed_msg );
|
656 |
+
}
|
657 |
|
658 |
+
files = up.files;
|
659 |
+
lastfile = files[files.length - 1];
|
660 |
|
661 |
+
} );
|
|
|
|
|
|
|
662 |
|
|
|
|
|
663 |
uploaderObj.uploader.refresh();//refresh the uploader for opera/IE fix on media page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
|
665 |
+
$( "#rtMedia-start-upload" ).click( function ( e ) {
|
666 |
+
uploaderObj.uploadFiles( e );
|
667 |
+
} );
|
668 |
+
$( "#rtMedia-start-upload" ).hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
669 |
|
670 |
+
jQuery( document ).on( 'click', '#rtm_show_upload_ui', function () {
|
671 |
+
jQuery( '#rtm-media-gallery-uploader' ).slideToggle();
|
672 |
+
uploaderObj.uploader.refresh();//refresh the uploader for opera/IE fix on media page
|
673 |
+
jQuery( '#rtm_show_upload_ui' ).toggleClass( 'primary' );
|
674 |
+
} );
|
675 |
+
} else {
|
676 |
+
jQuery( document ).on( 'click', '#rtm_show_upload_ui', function () {
|
677 |
+
jQuery( '#rtm-media-gallery-uploader' ).slideToggle();
|
678 |
+
jQuery( '#rtm_show_upload_ui' ).toggleClass( 'primary' );
|
679 |
} );
|
680 |
}
|
|
|
681 |
|
682 |
+
jQuery( document ).on( 'click', '.plupload_delete .rtmedia-delete-uploaded-media', function () {
|
683 |
+
var that = $( this );
|
684 |
+
if ( confirm( rtmedia_delete_uploaded_media ) ) {
|
685 |
+
var nonce = $( '#rtmedia-upload-container #rtmedia_media_delete_nonce' ).val();
|
686 |
+
var media_id = $( this ).attr( 'id' );
|
687 |
+
var data = {
|
688 |
+
action: 'delete_uploaded_media',
|
689 |
+
nonce: nonce,
|
690 |
+
media_id: media_id
|
691 |
+
}
|
692 |
+
|
693 |
+
$.post( ajaxurl, data, function ( response ) {
|
694 |
+
if ( response == '1' ) {
|
695 |
+
that.closest( 'tr' ).remove();
|
696 |
+
$( '#' + media_id ).remove();
|
697 |
+
}
|
698 |
+
} );
|
699 |
+
}
|
700 |
+
} );
|
701 |
|
702 |
} );
|
703 |
|
757 |
$( '#rtmedia-whts-new-upload-container > div' ).css( 'left', '0' );
|
758 |
|
759 |
//Enable 'post update' button when media get select
|
760 |
+
$( '#aw-whats-new-submit' ).prop( "disabled", false );
|
761 |
} );
|
762 |
//whats-new-post-in
|
763 |
|
835 |
jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ).hide();
|
836 |
|
837 |
// show/create text box to edit media title
|
838 |
+
if ( jQuery( rtm_file_title_input ).length === 0 ) {
|
839 |
jQuery( rtm_file_label ).parent( '.plupload_file_name' ).prepend( '<div id="' + rtm_file_title_wrapper_id + '" class="rtm-upload-edit-title-wrapper"><label>' + rtmedia_edit_media_info_upload.title + '</label><input type="text" class="rtm-upload-edit-title" id="' + rtm_file_title_id + '" value="' + file.title + '" style="width: 75%;" /></div><div id="' + rtm_file_desc_wrapper_id + '" class="rtm-upload-edit-desc-wrapper"><label>' + rtmedia_edit_media_info_upload.description + '</label><textarea class="rtm-upload-edit-desc" id="' + rtm_file_desc_id + '"></textarea></div><span id="' + rtm_file_save_id + '" title="Save Change" class="rtmicon dashicons dashicons-yes"></span>' );
|
840 |
} else {
|
841 |
jQuery( rtm_file_title_wrapper ).show();
|
845 |
|
846 |
jQuery( rtm_file_title_input ).focus();
|
847 |
|
848 |
+
jQuery( rtm_file_save_el ).click( function(){
|
849 |
var file_title_val = jQuery( rtm_file_title_input ).val();
|
850 |
var file_desc_val = jQuery( rtm_file_desc_input ).val();
|
851 |
var file_name_wrapper_el = jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' );
|
852 |
|
853 |
+
if ( file_title_val != '' ) {
|
854 |
file_name_wrapper_el.text( file_title_val + "." + rtm_file_name_array[ 1 ] );
|
855 |
file.title = file_title_val;
|
856 |
}
|
857 |
|
858 |
+
if ( file_desc_val != '' ) {
|
859 |
file.description = file_desc_val;
|
860 |
}
|
861 |
|
870 |
} );
|
871 |
|
872 |
$.each( objUploadView.upload_remove_array, function ( i, rfile ) {
|
873 |
+
if ( upl.getFile( rfile ) ) {
|
874 |
upl.removeFile( upl.getFile( rfile ) );
|
875 |
+
}
|
876 |
} );
|
877 |
|
878 |
+
if ( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' && jQuery.trim( jQuery( "#whats-new" ).val() ) != "" ) {
|
879 |
//Call upload event direct when direct upload is enabled (removed UPLOAD button and its triggered event)
|
880 |
var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true );
|
881 |
|
882 |
+
if ( allow_upload == false ) {
|
883 |
return false;
|
884 |
}
|
885 |
|
893 |
|
894 |
if ( ieversion < 10 ) {
|
895 |
try {
|
896 |
+
if ( typeof JSON.parse( res.response ) !== "undefined" ) {
|
897 |
res.status = 200;
|
898 |
+
}
|
899 |
+
} catch ( e ) {
|
900 |
}
|
901 |
}
|
902 |
}
|
908 |
activity_attachemnt_ids.push( val );
|
909 |
if ( $( "#whats-new-form" ).find( "#rtmedia_attached_id_" + val ).length < 1 ) {
|
910 |
$( "#whats-new-form" ).append( "<input type='hidden' name='rtMedia_attached_files[]' data-mode='rtMedia-update' id='rtmedia_attached_id_" + val + "' value='"
|
911 |
+
+ val + "' />" );
|
912 |
}
|
913 |
} );
|
914 |
} catch ( e ) {
|
931 |
rtmedia_selected_file_list( plupload, err.file, up, err );
|
932 |
}
|
933 |
}
|
934 |
+
} else {
|
|
|
935 |
if ( err.code == - 601 ) { // file extension error
|
936 |
err.message = rtmedia_file_extension_error_msg;
|
937 |
}
|
951 |
objUploadView.uploader.bind( 'BeforeUpload', function ( up, files ) {
|
952 |
|
953 |
$.each( objUploadView.upload_remove_array, function ( i, rfile ) {
|
954 |
+
if ( up.getFile( rfile ) ) {
|
955 |
+
up.removeFile( up.getFile( rfile ) ); }
|
956 |
} );
|
957 |
|
958 |
var object = '';
|
959 |
var item_id = jQuery( "#whats-new-post-in" ).val();
|
960 |
+
if ( item_id == undefined ) {
|
961 |
+
item_id = 0; }
|
962 |
if ( item_id > 0 ) {
|
963 |
object = "group";
|
964 |
} else {
|
969 |
up.settings.multipart_params.context_id = item_id;
|
970 |
up.settings.multipart_params.title = files.title.split( '.' )[ 0 ];
|
971 |
|
972 |
+
if ( typeof files.description != "undefined" ) {
|
973 |
up.settings.multipart_params.description = files.description;
|
974 |
} else {
|
975 |
up.settings.multipart_params.description = '';
|
1023 |
while ( activity_attachemnt_ids.length > 0 ) {
|
1024 |
options.data += "&rtMedia_attached_files[]=" + activity_attachemnt_ids.pop();
|
1025 |
}
|
1026 |
+
|
1027 |
+
var dynamic_privacy = '';
|
1028 |
+
|
1029 |
+
if ( jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).length > 0 ) {
|
1030 |
+
dynamic_privacy = jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).val();
|
1031 |
+
} else if ( jQuery( 'input[name="privacy"]' ).length > 0 ) {
|
1032 |
+
dynamic_privacy = jQuery( 'input[name="privacy"]' ).val();
|
1033 |
+
}
|
1034 |
+
|
1035 |
options.data += "&rtmedia-privacy=" + dynamic_privacy;
|
1036 |
activity_attachemnt_ids = temp;
|
1037 |
|
1042 |
*/
|
1043 |
var allowActivityPost = rtMediaHook.call( 'rtmedia_js_before_activity_added', true );
|
1044 |
|
1045 |
+
if ( ! allowActivityPost ) {
|
1046 |
+
$( '#rtmedia_upload_terms_conditions' ).removeAttr( 'disabled' );
|
1047 |
+
$( '#rtmedia-whts-new-upload-container' ).find( 'input' ).removeAttr( 'disabled' );
|
1048 |
|
1049 |
return false;
|
1050 |
}
|
1055 |
*Added $nbsp; as activity text to post activity without TEXT
|
1056 |
* Disabled TextBox color(transparent)
|
1057 |
*/
|
1058 |
+
$( "#whats-new" ).css( 'color', 'transparent' );
|
1059 |
+
$( "#whats-new" ).val( ' ' );
|
1060 |
}
|
1061 |
}
|
1062 |
if ( ! media_uploading && objUploadView.uploader.files.length > 0 ) {
|
1070 |
return true;
|
1071 |
}
|
1072 |
|
|
|
1073 |
}
|
1074 |
options.success = function ( response ) {
|
1075 |
orignalSuccess( response );
|
1108 |
$( "#whats-new-post-in" ).removeAttr( 'disabled' );
|
1109 |
$( "#rtmedia-add-media-button-post-update" ).removeAttr( 'disabled' );
|
1110 |
// Enabled TextBox color back to normal
|
1111 |
+
$( "#whats-new" ).css( 'color', '' );
|
1112 |
|
1113 |
}
|
1114 |
}
|
1125 |
}
|
1126 |
|
1127 |
if ( originalOptions.data.action == 'post_update' || originalOptions.data.action == 'activity_widget_filter' ) {
|
1128 |
+
var dynamic_privacy = '';
|
1129 |
+
|
1130 |
+
if ( jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).length > 0 ) {
|
1131 |
+
dynamic_privacy = jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).val();
|
1132 |
+
} else if ( jQuery( 'input[name="privacy"]' ).length > 0 ) {
|
1133 |
+
dynamic_privacy = jQuery( 'input[name="privacy"]' ).val();
|
1134 |
+
}
|
1135 |
+
|
1136 |
options.data += "&rtmedia-privacy=" + dynamic_privacy;
|
1137 |
var orignalSuccess = originalOptions.success;
|
1138 |
options.success = function ( response ) {
|
1147 |
|
1148 |
$( "#whats-new-post-in" ).removeAttr( 'disabled' );
|
1149 |
// Enabled TextBox color back to normal
|
1150 |
+
$( "#whats-new" ).css( 'color', '' );
|
1151 |
|
1152 |
}
|
1153 |
}
|
1159 |
*/
|
1160 |
jQuery( document ).ready( function ( $ ) {
|
1161 |
jQuery( document ).on( "click", "#rt_media_comment_form #rt_media_comment_submit", function ( e ) {
|
1162 |
+
var comment_content_el = jQuery( '#comment_content' );
|
1163 |
+
var comment_form_el = jQuery( "#rt_media_comment_form" );
|
1164 |
+
var that = this;
|
1165 |
+
|
1166 |
e.preventDefault();
|
1167 |
if ( $.trim( $( "#comment_content" ).val() ) == "" ) {
|
1168 |
rtmedia_single_media_alert_message( rtmedia_empty_comment_msg, 'warning' );
|
1171 |
|
1172 |
$( this ).attr( 'disabled', 'disabled' );
|
1173 |
|
1174 |
+
// sanitize comment content and escape html tags
|
1175 |
+
comment_content_el.val( jQuery( '<span/>' ).text( jQuery.trim( comment_content_el.val() ) ).html() );
|
1176 |
+
|
1177 |
$.ajax( {
|
1178 |
+
url: comment_form_el.attr( "action" ),
|
1179 |
type: 'post',
|
1180 |
+
data: comment_form_el.serialize() + "&rtajax=true",
|
1181 |
success: function ( data ) {
|
1182 |
$( '#rtmedia-no-comments' ).remove();
|
1183 |
$( "#rtmedia_comment_ul" ).append( data );
|
1184 |
+
comment_content_el.val( "" );
|
1185 |
+
$( that ).removeAttr( 'disabled' );
|
1186 |
rtMediaHook.call( 'rtmedia_js_after_comment_added', [ ] );
|
1187 |
}
|
1188 |
} );
|
1189 |
|
|
|
1190 |
return false;
|
1191 |
} );
|
1192 |
|
1195 |
e.preventDefault();
|
1196 |
var ask_confirmation = true
|
1197 |
ask_confirmation = rtMediaHook.call( 'rtmedia_js_delete_comment_confirmation', [ ask_confirmation ] );
|
1198 |
+
if ( ask_confirmation && ! confirm( rtmedia_media_comment_delete_confirmation ) ) {
|
1199 |
return false;
|
1200 |
+
}
|
1201 |
var current_comment = jQuery( this );
|
1202 |
var current_comment_parent = current_comment.parent();
|
1203 |
var comment_id = current_comment.data( 'id' );
|
1228 |
$( document ).on( "click", '.rtmedia-like', function ( e ) {
|
1229 |
e.preventDefault();
|
1230 |
var that = this;
|
1231 |
+
var like_nonce = $( this ).siblings( '#rtm_media_like_nonce' ).val();
|
1232 |
$( this ).attr( 'disabled', 'disabled' );
|
1233 |
var url = $( this ).parent().attr( "action" );
|
1234 |
$( that ).prepend( "<img class='rtm-like-loading' src='" + rMedia_loading_file + "' style='width:10px' />" );
|
1255 |
}
|
1256 |
} );
|
1257 |
|
|
|
1258 |
} );
|
1259 |
$( document ).on( "click", '.rtmedia-featured, .rtmedia-group-featured', function ( e ) {
|
1260 |
e.preventDefault();
|
1261 |
var that = this;
|
1262 |
$( this ).attr( 'disabled', 'disabled' );
|
1263 |
+
var featured_nonce = $( this ).siblings( '#rtm_media_featured_nonce' ).val();
|
1264 |
var url = $( this ).parent().attr( "action" );
|
1265 |
$( that ).prepend( "<img class='rtm-featured-loading' src='" + rMedia_loading_file + "' />" );
|
1266 |
$.ajax( {
|
1274 |
|
1275 |
}
|
1276 |
|
1277 |
+
if ( data.nonce ) {
|
1278 |
+
rtmedia_single_media_alert_message( rtmedia_something_wrong_msg, 'warning' );
|
1279 |
} else {
|
1280 |
if (data.action) {
|
1281 |
+
rtmedia_single_media_alert_message( rtmedia_set_featured_image_msg, 'success' );
|
1282 |
} else {
|
1283 |
+
rtmedia_single_media_alert_message( rtmedia_unset_featured_image_msg, 'success' );
|
1284 |
}
|
1285 |
}
|
1286 |
$( that ).find( 'span' ).html( data.next );
|
1289 |
}
|
1290 |
} );
|
1291 |
|
|
|
1292 |
} );
|
1293 |
jQuery( "#div-attache-rtmedia" ).find( "input[type=file]" ).each( function () {
|
1294 |
//$(this).attr("capture", "camera");
|
1304 |
} );
|
1305 |
|
1306 |
function rtmedia_selected_file_list( plupload, file, uploader, error ) {
|
1307 |
+
var icon = '', err_msg = '', upload_progress = '', title = '';
|
1308 |
+
|
1309 |
+
if ( error == '' ) {
|
1310 |
upload_progress = '<div class="plupload_file_progress ui-widget-header" style="width: 0%;">';
|
1311 |
upload_progress += '</div>';
|
1312 |
+
icon = '<span id="label_' + file.id + '" class="dashicons dashicons-edit rtmicon" title="Edit File Name"></span>';
|
1313 |
} else if ( error.code == - 600 ) {
|
1314 |
err_msg = ( uploader != '' ) ? rtmedia_max_file_msg + uploader.settings.max_file_size : window.file_size_info;
|
1315 |
+
title = "title='" + err_msg + "'";
|
1316 |
+
icon = '<i class="dashicons dashicons-info rtmicon" ' + title + '></i>';
|
1317 |
} else if ( error.code == - 601 ) {
|
1318 |
err_msg = error.message + '. ' + window.file_extn_info;
|
1319 |
+
title = "title='" + err_msg + "'";
|
1320 |
+
icon = '<i class="dashicons dashicons-info rtmicon" ' + title + '></i>';
|
1321 |
}
|
1322 |
+
|
1323 |
var rtmedia_plupload_file = '<li class="plupload_file ui-state-default plupload_queue_li" id="' + file.id + '" ' + title + '>';
|
1324 |
rtmedia_plupload_file += '<div id="file_thumb_' + file.id + '" class="plupload_file_thumb">';
|
1325 |
rtmedia_plupload_file += '</div>';
|
1326 |
rtmedia_plupload_file += '<div class="plupload_file_status">';
|
1327 |
+
rtmedia_plupload_file += upload_progress;
|
1328 |
rtmedia_plupload_file += '</div>';
|
1329 |
rtmedia_plupload_file += '<div class="plupload_file_name" title="' + ( file.name ? file.name : '' ) + '">';
|
1330 |
rtmedia_plupload_file += '<span class="plupload_file_name_wrapper">';
|
1331 |
rtmedia_plupload_file += ( file.name ? file.name : '' );
|
1332 |
rtmedia_plupload_file += '</span>';
|
1333 |
+
rtmedia_plupload_file += icon;
|
1334 |
rtmedia_plupload_file += '</div>';
|
1335 |
rtmedia_plupload_file += '<div class="plupload_file_action">';
|
1336 |
rtmedia_plupload_file += '<div class="plupload_action_icon ui-icon plupload_delete">';
|
1346 |
|
1347 |
jQuery( rtmedia_plupload_file ).appendTo( '#rtmedia_uploader_filelist' );
|
1348 |
var type = file.type;
|
1349 |
+
var media_title = file.name;
|
1350 |
+
var ext = media_title.substring( media_title.lastIndexOf( "." ) + 1, media_title.length );
|
1351 |
|
1352 |
if ( /image/i.test( type ) ) {
|
1353 |
+
if ( ext === 'gif' ) {
|
1354 |
+
jQuery( '<img src="' + rtmedia_media_thumbs[ 'photo' ] + '" />' ).appendTo( '#file_thumb_' + file.id );
|
1355 |
+
} else {
|
1356 |
+
var img = new mOxie.Image();
|
1357 |
+
|
1358 |
+
img.onload = function () {
|
1359 |
+
this.embed( jQuery( '#file_thumb_' + file.id ).get( 0 ), {
|
1360 |
+
width: 100,
|
1361 |
+
height: 60,
|
1362 |
+
crop: true
|
1363 |
+
} );
|
1364 |
+
};
|
1365 |
+
|
1366 |
+
img.onembedded = function () {
|
1367 |
+
this.destroy();
|
1368 |
+
};
|
1369 |
+
|
1370 |
+
img.onerror = function () {
|
1371 |
+
this.destroy();
|
1372 |
+
};
|
1373 |
+
|
1374 |
+
img.load( file.getSource() );
|
1375 |
+
}
|
1376 |
+
} else {
|
1377 |
+
jQuery.each( rtmedia_exteansions, function( key, value ) {
|
1378 |
+
if ( value.indexOf( ext ) >= 0 ) {
|
1379 |
+
jQuery( '<img src="' + rtmedia_media_thumbs[ key ] + '" />' ).appendTo( '#file_thumb_' + file.id );
|
1380 |
+
|
1381 |
+
return false;
|
1382 |
+
}
|
1383 |
+
} );
|
1384 |
+
}
|
1385 |
+
|
1386 |
}
|
app/assets/js/rtMedia.js
CHANGED
@@ -36,10 +36,10 @@ function apply_rtMagnificPopup( selector ) {
|
|
36 |
callbacks: {
|
37 |
ajaxContentAdded: function () {
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
// When last second media is encountered in lightbox, load more medias if available
|
44 |
var mfp = jQuery.magnificPopup.instance;
|
45 |
var current_media = mfp.currItem.el;
|
@@ -62,21 +62,18 @@ function apply_rtMagnificPopup( selector ) {
|
|
62 |
|
63 |
var settings = { };
|
64 |
|
65 |
-
if ( typeof _wpmejsSettings !== 'undefined' )
|
66 |
settings.pluginPath = _wpmejsSettings.pluginPath;
|
|
|
67 |
$( '.mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video' ).mediaelementplayer( {
|
68 |
// if the <video width> is not specified, this is the default
|
69 |
defaultVideoWidth: 480,
|
70 |
// if the <video height> is not specified, this is the default
|
71 |
defaultVideoHeight: 270,
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
success: function (mediaElement, domObject) {
|
77 |
-
// call the play method
|
78 |
-
mediaElement.play();
|
79 |
-
},
|
80 |
} );
|
81 |
$( '.mfp-content .mejs-audio .mejs-controls' ).css( 'position', 'relative' );
|
82 |
rtMediaHook.call( 'rtmedia_js_popup_after_content_added', [ ] );
|
@@ -98,22 +95,23 @@ var rtMediaHook = {
|
|
98 |
hooks: [ ],
|
99 |
is_break: false,
|
100 |
register: function ( name, callback ) {
|
101 |
-
if ( 'undefined' == typeof ( rtMediaHook.hooks[name] ) )
|
102 |
-
rtMediaHook.hooks[name] = [ ]
|
103 |
-
|
|
|
104 |
},
|
105 |
call: function ( name, arguments ) {
|
106 |
-
if ( 'undefined' != typeof ( rtMediaHook.hooks[name] ) )
|
107 |
for ( i = 0; i < rtMediaHook.hooks[name].length; ++ i ) {
|
108 |
if ( true != rtMediaHook.hooks[name][i]( arguments ) ) {
|
109 |
rtMediaHook.is_break = true;
|
110 |
return false;
|
111 |
break;
|
112 |
}
|
113 |
-
}
|
114 |
return true;
|
115 |
}
|
116 |
-
}
|
117 |
|
118 |
//drop-down js
|
119 |
function rtmedia_init_action_dropdown() {
|
@@ -137,7 +135,7 @@ function rtmedia_init_action_dropdown() {
|
|
137 |
jQuery( 'document' ).ready( function ( $ ) {
|
138 |
|
139 |
// Tabs
|
140 |
-
if( typeof $.fn.rtTab !== 'undefined' ) {
|
141 |
$( '.rtm-tabs' ).rtTab();
|
142 |
}
|
143 |
|
@@ -152,10 +150,10 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
152 |
|
153 |
$( "#rt_media_comment_form" ).submit( function ( e ) {
|
154 |
if ( $.trim( $( "#comment_content" ).val() ) == "" ) {
|
155 |
-
if ( jQuery('#rtmedia-single-media-container').length == 0 ) {
|
156 |
-
rtmedia_gallery_action_alert_message(rtmedia_empty_comment_msg, 'warning');
|
157 |
} else {
|
158 |
-
rtmedia_single_media_alert_message(rtmedia_empty_comment_msg, 'warning');
|
159 |
}
|
160 |
return false;
|
161 |
} else {
|
@@ -169,21 +167,21 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
169 |
$( this ).addClass( "no-popup" );
|
170 |
} );
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
try{
|
183 |
if (originalOptions.data == null || typeof(originalOptions.data) == "undefined" || typeof(originalOptions.data.action) == "undefined" ) {
|
184 |
return true;
|
185 |
}
|
186 |
-
}catch(e){
|
187 |
return true;
|
188 |
}
|
189 |
|
@@ -191,9 +189,9 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
191 |
if (originalOptions.data.action == 'activity_get_older_updates') {
|
192 |
var orignalSuccess = originalOptions.success;
|
193 |
options.success = function(response) {
|
194 |
-
orignalSuccess(response);
|
195 |
-
apply_rtMagnificPopup('.rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content');
|
196 |
-
rtMediaHook.call('rtmedia_js_after_activity_added', []);
|
197 |
}
|
198 |
} else if ( originalOptions.data.action == 'get_single_activity_content' ) {
|
199 |
// Handle lightbox in BuddyPress single activity loadmore
|
@@ -201,21 +199,17 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
201 |
options.success = function ( response ) {
|
202 |
orignalSuccess( response );
|
203 |
setTimeout( function(){
|
204 |
-
apply_rtMagnificPopup('.rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content');
|
205 |
jQuery( 'ul.activity-list li.rtmedia_update:first-child .wp-audio-shortcode, ul.activity-list li.rtmedia_update:first-child .wp-video-shortcode' ).mediaelementplayer( {
|
206 |
// if the <video width> is not specified, this is the default
|
207 |
defaultVideoWidth: 480,
|
208 |
// if the <video height> is not specified, this is the default
|
209 |
defaultVideoHeight: 270
|
210 |
-
// if set, overrides <video width>
|
211 |
-
//videoWidth: 1,
|
212 |
-
// if set, overrides <video height>
|
213 |
-
//videoHeight: 1
|
214 |
} );
|
215 |
}, 900 );
|
216 |
}
|
217 |
}
|
218 |
-
|
219 |
|
220 |
jQuery.ajaxPrefilter( function ( options, originalOptions, jqXHR ) {
|
221 |
try {
|
@@ -236,10 +230,6 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
236 |
defaultVideoWidth: 480,
|
237 |
// if the <video height> is not specified, this is the default
|
238 |
defaultVideoHeight: 270
|
239 |
-
// if set, overrides <video width>
|
240 |
-
//videoWidth: 1,
|
241 |
-
// if set, overrides <video height>
|
242 |
-
//videoHeight: 1
|
243 |
} );
|
244 |
|
245 |
rtMediaHook.call( 'rtmedia_js_after_activity_added', [ ] );
|
@@ -271,7 +261,7 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
271 |
} );
|
272 |
|
273 |
jQuery( '#rtmedia-create-album-modal' ).on( 'click', '#rtmedia_create_new_album', function ( e ) {
|
274 |
-
$albumname = jQuery( '<span/>' ).text( jQuery.trim( jQuery( '#rtmedia_album_name' ).val()
|
275 |
$context = jQuery.trim( jQuery( '#rtmedia_album_context' ).val() );
|
276 |
$context_id = jQuery.trim( jQuery( '#rtmedia_album_context_id' ).val() );
|
277 |
$privacy = jQuery.trim( jQuery( '#rtmedia_select_album_privacy' ).val() );
|
@@ -296,9 +286,8 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
296 |
$( "#rtmedia_create_new_album" ).prepend( "<img src='" + rMedia_loading_file + "' />" );
|
297 |
|
298 |
jQuery.post( rtmedia_ajax_url, data, function ( response ) {
|
299 |
-
response = jQuery.parseJSON(response);
|
300 |
if ( typeof response.album != 'undefined' ) {
|
301 |
-
response =
|
302 |
var flag = true;
|
303 |
|
304 |
jQuery( '.rtmedia-user-album-list' ).each( function () {
|
@@ -335,14 +324,14 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
335 |
}, 2000 );
|
336 |
} else if ( typeof response.error != 'undefined' ) {
|
337 |
rtmedia_gallery_action_alert_message( response.error, 'warning' );
|
338 |
-
|
339 |
rtmedia_gallery_action_alert_message( rtmedia_something_wrong_msg, 'warning' );
|
340 |
}
|
341 |
|
342 |
$( "#rtmedia_create_new_album" ).removeAttr( 'disabled' );
|
343 |
$( "#rtmedia_create_new_album" ).html( old_val );
|
344 |
} );
|
345 |
-
|
346 |
rtmedia_gallery_action_alert_message( rtmedia_empty_album_name_msg, 'warning' );
|
347 |
}
|
348 |
} );
|
@@ -350,7 +339,7 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
350 |
jQuery( '.rtmedia-container' ).on( 'click', '.rtmedia-delete-selected', function ( e ) {
|
351 |
if ( jQuery( '.rtmedia-list :checkbox:checked' ).length > 0 ) {
|
352 |
if ( confirm( rtmedia_selected_media_delete_confirmation ) ) {
|
353 |
-
|
354 |
}
|
355 |
} else {
|
356 |
rtmedia_gallery_action_alert_message( rtmedia_no_media_selected, 'warning' );
|
@@ -368,46 +357,44 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
368 |
|
369 |
} );
|
370 |
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
|
404 |
function rtmedia_media_view_counts() {
|
405 |
//var view_count_action = jQuery('#rtmedia-media-view-form').attr("action");
|
406 |
if ( jQuery( '#rtmedia-media-view-form' ).length > 0 ) {
|
407 |
var url = jQuery( '#rtmedia-media-view-form' ).attr( "action" );
|
408 |
-
jQuery.post( url,
|
409 |
-
{
|
410 |
-
}, function ( data ) {
|
411 |
|
412 |
} );
|
413 |
}
|
@@ -415,13 +402,13 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
415 |
|
416 |
rtmedia_media_view_counts();
|
417 |
rtMediaHook.register( 'rtmedia_js_popup_after_content_added',
|
418 |
-
|
419 |
rtmedia_media_view_counts();
|
420 |
rtmedia_init_media_deleting();
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
|
426 |
rtmedia_disable_popup_navigation_comment_focus();
|
427 |
var height = $( window ).height();
|
@@ -456,7 +443,7 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
456 |
$( 'li.total' ).html( counts );
|
457 |
|
458 |
return true;
|
459 |
-
|
460 |
);
|
461 |
|
462 |
function rtmedia_init_popup_navigation() {
|
@@ -483,36 +470,36 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
483 |
}
|
484 |
|
485 |
function rtmedia_disable_popup_navigation_comment_focus() {
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
// activityArea.css('height','150px');
|
516 |
dragArea.addClass( 'rtm-drag-drop-active' );
|
517 |
jQuery( '#rtm-drop-files-title' ).show();
|
518 |
} )
|
@@ -536,7 +523,6 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
536 |
jQuery( '#rtm-drop-files-title' ).hide();
|
537 |
} );
|
538 |
|
539 |
-
|
540 |
function rtmedia_init_media_deleting() {
|
541 |
jQuery( '.rtmedia-container' ).on( 'click', '.rtmedia-delete-media', function ( e ) {
|
542 |
e.preventDefault();
|
@@ -580,7 +566,7 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
580 |
} );
|
581 |
}
|
582 |
|
583 |
-
// masonry code
|
584 |
if ( typeof rtmedia_masonry_layout != "undefined" && rtmedia_masonry_layout == "true" && jQuery( '.rtmedia-container .rtmedia-list.rtm-no-masonry' ).length == 0 ) {
|
585 |
rtm_masonry_container = jQuery( '.rtmedia-container .rtmedia-list' )
|
586 |
rtm_masonry_container.masonry( {
|
@@ -597,30 +583,30 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
597 |
} );
|
598 |
}
|
599 |
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
jQuery( this ).parents( '.rtm-uploader-tabs' ).siblings('[data-id="' + class_name + '"]').show();
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
|
618 |
// delete media from gallery page under the user's profile when user clicks the delete button on the gallery item.
|
619 |
jQuery( '.rtmedia-container' ).on( 'click', '.rtm-delete-media', function ( e ) {
|
620 |
e.preventDefault();
|
621 |
var confirmation = 'Are you sure you want to delete this media?';
|
622 |
|
623 |
-
if( typeof rtmedia_media_delete_confirmation != 'undefined' ){
|
624 |
confirmation = rtmedia_media_delete_confirmation;
|
625 |
}
|
626 |
|
@@ -654,15 +640,49 @@ jQuery( 'document' ).ready( function ( $ ) {
|
|
654 |
} );
|
655 |
}
|
656 |
} );
|
657 |
-
}
|
658 |
-
|
659 |
-
|
660 |
|
661 |
//Legacy media element for old activities
|
662 |
function bp_media_create_element( id ) {
|
663 |
return false;
|
664 |
}
|
665 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
666 |
/*
|
667 |
* To change this license header, choose License Headers in Project Properties.
|
668 |
* To change this template file, choose Tools | Templates
|
@@ -686,24 +706,23 @@ function bp_media_create_element( id ) {
|
|
686 |
|
687 |
$( document ).on( { click: function () {
|
688 |
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
$this.parent().prev().toggle();
|
698 |
$this.prev().toggle();
|
699 |
return false;
|
700 |
-
|
701 |
-
}, '.morelink' );
|
702 |
|
703 |
return this.each( function () {
|
704 |
var $this = $( this );
|
705 |
-
if ( $this.hasClass( "shortened" ) )
|
706 |
-
return;
|
707 |
|
708 |
$this.addClass( "shortened" );
|
709 |
var content = $this.html();
|
@@ -720,37 +739,6 @@ function bp_media_create_element( id ) {
|
|
720 |
|
721 |
} )( jQuery );
|
722 |
|
723 |
-
function rtmedia_version_compare( left, right ) {
|
724 |
-
if ( typeof left + typeof right != 'stringstring' )
|
725 |
-
return false;
|
726 |
-
var a = left.split( '.' )
|
727 |
-
, b = right.split( '.' )
|
728 |
-
, i = 0, len = Math.max( a.length, b.length );
|
729 |
-
for ( ; i < len; i ++ ) {
|
730 |
-
if ( ( a[i] && ! b[i] && parseInt( a[i] ) > 0 ) || ( parseInt( a[i] ) > parseInt( b[i] ) ) ) {
|
731 |
-
return true;
|
732 |
-
} else if ( ( b[i] && ! a[i] && parseInt( b[i] ) > 0 ) || ( parseInt( a[i] ) < parseInt( b[i] ) ) ) {
|
733 |
-
return false;
|
734 |
-
}
|
735 |
-
}
|
736 |
-
return true;
|
737 |
-
}
|
738 |
-
|
739 |
-
function rtm_is_element_exist( el ) {
|
740 |
-
if ( jQuery( el ).length > 0 ) {
|
741 |
-
return true;
|
742 |
-
} else {
|
743 |
-
return false;
|
744 |
-
}
|
745 |
-
}
|
746 |
-
|
747 |
-
function rtm_masonry_reload( el ) {
|
748 |
-
setTimeout( function () {
|
749 |
-
// we make masonry recalculate the element based on their current state.
|
750 |
-
el.masonry( 'reload' );
|
751 |
-
}, 250 );
|
752 |
-
}
|
753 |
-
|
754 |
window.onload = function () {
|
755 |
if ( typeof rtmedia_masonry_layout != "undefined" && rtmedia_masonry_layout == "true" && jQuery( '.rtmedia-container .rtmedia-list.rtm-no-masonry' ).length == 0 ) {
|
756 |
rtm_masonry_reload( rtm_masonry_container );
|
@@ -766,24 +754,24 @@ function rtmediaGetParameterByName( name ) {
|
|
766 |
}
|
767 |
|
768 |
function rtmedia_single_media_alert_message( msg, action ) {
|
769 |
-
|
770 |
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
|
775 |
-
|
776 |
-
|
777 |
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
}
|
788 |
|
789 |
function rtmedia_gallery_action_alert_message( msg, action ) {
|
@@ -794,12 +782,12 @@ function rtmedia_gallery_action_alert_message( msg, action ) {
|
|
794 |
}
|
795 |
var container = '<div class="rtmedia-gallery-alert-container"> </div>';
|
796 |
jQuery( 'body' ).append( container );
|
797 |
-
jQuery( '.rtmedia-gallery-alert-container' ).append( "<div class='rtmedia-gallery-message-box'><span class='"+ action_class +"'>" + msg + " </span></div>" );
|
798 |
|
799 |
setTimeout( function() { jQuery( ".rtmedia-gallery-alert-container" ).remove();
|
800 |
}, 3000 );
|
801 |
|
802 |
-
jQuery('.rtmedia-gallery-message-box').click( function() {
|
803 |
jQuery( ".rtmedia-gallery-alert-container" ).remove();
|
804 |
} );
|
805 |
}
|
36 |
callbacks: {
|
37 |
ajaxContentAdded: function () {
|
38 |
|
39 |
+
mfp = jQuery.magnificPopup.instance;
|
40 |
+
if ( jQuery( mfp.items ).size() === 1 ) {
|
41 |
+
jQuery( ".mfp-arrow" ).remove();
|
42 |
+
}
|
43 |
// When last second media is encountered in lightbox, load more medias if available
|
44 |
var mfp = jQuery.magnificPopup.instance;
|
45 |
var current_media = mfp.currItem.el;
|
62 |
|
63 |
var settings = { };
|
64 |
|
65 |
+
if ( typeof _wpmejsSettings !== 'undefined' ) {
|
66 |
settings.pluginPath = _wpmejsSettings.pluginPath;
|
67 |
+
}
|
68 |
$( '.mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video' ).mediaelementplayer( {
|
69 |
// if the <video width> is not specified, this is the default
|
70 |
defaultVideoWidth: 480,
|
71 |
// if the <video height> is not specified, this is the default
|
72 |
defaultVideoHeight: 270,
|
73 |
+
success: function (mediaElement, domObject) {
|
74 |
+
// call the play method
|
75 |
+
mediaElement.play();
|
76 |
+
},
|
|
|
|
|
|
|
|
|
77 |
} );
|
78 |
$( '.mfp-content .mejs-audio .mejs-controls' ).css( 'position', 'relative' );
|
79 |
rtMediaHook.call( 'rtmedia_js_popup_after_content_added', [ ] );
|
95 |
hooks: [ ],
|
96 |
is_break: false,
|
97 |
register: function ( name, callback ) {
|
98 |
+
if ( 'undefined' == typeof ( rtMediaHook.hooks[name] ) ) {
|
99 |
+
rtMediaHook.hooks[name] = [ ];
|
100 |
+
}
|
101 |
+
rtMediaHook.hooks[name].push( callback );
|
102 |
},
|
103 |
call: function ( name, arguments ) {
|
104 |
+
if ( 'undefined' != typeof ( rtMediaHook.hooks[name] ) ) {
|
105 |
for ( i = 0; i < rtMediaHook.hooks[name].length; ++ i ) {
|
106 |
if ( true != rtMediaHook.hooks[name][i]( arguments ) ) {
|
107 |
rtMediaHook.is_break = true;
|
108 |
return false;
|
109 |
break;
|
110 |
}
|
111 |
+
} }
|
112 |
return true;
|
113 |
}
|
114 |
+
};
|
115 |
|
116 |
//drop-down js
|
117 |
function rtmedia_init_action_dropdown() {
|
135 |
jQuery( 'document' ).ready( function ( $ ) {
|
136 |
|
137 |
// Tabs
|
138 |
+
if ( typeof $.fn.rtTab !== 'undefined' ) {
|
139 |
$( '.rtm-tabs' ).rtTab();
|
140 |
}
|
141 |
|
150 |
|
151 |
$( "#rt_media_comment_form" ).submit( function ( e ) {
|
152 |
if ( $.trim( $( "#comment_content" ).val() ) == "" ) {
|
153 |
+
if ( jQuery( '#rtmedia-single-media-container' ).length == 0 ) {
|
154 |
+
rtmedia_gallery_action_alert_message( rtmedia_empty_comment_msg, 'warning' );
|
155 |
} else {
|
156 |
+
rtmedia_single_media_alert_message( rtmedia_empty_comment_msg, 'warning' );
|
157 |
}
|
158 |
return false;
|
159 |
} else {
|
167 |
$( this ).addClass( "no-popup" );
|
168 |
} );
|
169 |
|
170 |
+
//Remove title from popup duplication
|
171 |
+
$( "li.rtmedia-list-item p a" ).each(function(e) {
|
172 |
+
$( this ).addClass( "no-popup" );
|
173 |
+
})
|
174 |
+
//rtmedia_lightbox_enabled from setting
|
175 |
+
if (typeof(rtmedia_lightbox_enabled) != 'undefined' && rtmedia_lightbox_enabled == "1") {
|
176 |
+
apply_rtMagnificPopup( '.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container' );
|
177 |
+
}
|
178 |
+
|
179 |
+
jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) {
|
180 |
+
try {
|
181 |
if (originalOptions.data == null || typeof(originalOptions.data) == "undefined" || typeof(originalOptions.data.action) == "undefined" ) {
|
182 |
return true;
|
183 |
}
|
184 |
+
} catch (e) {
|
185 |
return true;
|
186 |
}
|
187 |
|
189 |
if (originalOptions.data.action == 'activity_get_older_updates') {
|
190 |
var orignalSuccess = originalOptions.success;
|
191 |
options.success = function(response) {
|
192 |
+
orignalSuccess( response );
|
193 |
+
apply_rtMagnificPopup( '.rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' );
|
194 |
+
rtMediaHook.call( 'rtmedia_js_after_activity_added', [] );
|
195 |
}
|
196 |
} else if ( originalOptions.data.action == 'get_single_activity_content' ) {
|
197 |
// Handle lightbox in BuddyPress single activity loadmore
|
199 |
options.success = function ( response ) {
|
200 |
orignalSuccess( response );
|
201 |
setTimeout( function(){
|
202 |
+
apply_rtMagnificPopup( '.rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' );
|
203 |
jQuery( 'ul.activity-list li.rtmedia_update:first-child .wp-audio-shortcode, ul.activity-list li.rtmedia_update:first-child .wp-video-shortcode' ).mediaelementplayer( {
|
204 |
// if the <video width> is not specified, this is the default
|
205 |
defaultVideoWidth: 480,
|
206 |
// if the <video height> is not specified, this is the default
|
207 |
defaultVideoHeight: 270
|
|
|
|
|
|
|
|
|
208 |
} );
|
209 |
}, 900 );
|
210 |
}
|
211 |
}
|
212 |
+
});
|
213 |
|
214 |
jQuery.ajaxPrefilter( function ( options, originalOptions, jqXHR ) {
|
215 |
try {
|
230 |
defaultVideoWidth: 480,
|
231 |
// if the <video height> is not specified, this is the default
|
232 |
defaultVideoHeight: 270
|
|
|
|
|
|
|
|
|
233 |
} );
|
234 |
|
235 |
rtMediaHook.call( 'rtmedia_js_after_activity_added', [ ] );
|
261 |
} );
|
262 |
|
263 |
jQuery( '#rtmedia-create-album-modal' ).on( 'click', '#rtmedia_create_new_album', function ( e ) {
|
264 |
+
$albumname = jQuery( '<span/>' ).text( jQuery.trim( jQuery( '#rtmedia_album_name' ).val() ) ).html();
|
265 |
$context = jQuery.trim( jQuery( '#rtmedia_album_context' ).val() );
|
266 |
$context_id = jQuery.trim( jQuery( '#rtmedia_album_context_id' ).val() );
|
267 |
$privacy = jQuery.trim( jQuery( '#rtmedia_select_album_privacy' ).val() );
|
286 |
$( "#rtmedia_create_new_album" ).prepend( "<img src='" + rMedia_loading_file + "' />" );
|
287 |
|
288 |
jQuery.post( rtmedia_ajax_url, data, function ( response ) {
|
|
|
289 |
if ( typeof response.album != 'undefined' ) {
|
290 |
+
response = jQuery.trim( response.album );
|
291 |
var flag = true;
|
292 |
|
293 |
jQuery( '.rtmedia-user-album-list' ).each( function () {
|
324 |
}, 2000 );
|
325 |
} else if ( typeof response.error != 'undefined' ) {
|
326 |
rtmedia_gallery_action_alert_message( response.error, 'warning' );
|
327 |
+
} else {
|
328 |
rtmedia_gallery_action_alert_message( rtmedia_something_wrong_msg, 'warning' );
|
329 |
}
|
330 |
|
331 |
$( "#rtmedia_create_new_album" ).removeAttr( 'disabled' );
|
332 |
$( "#rtmedia_create_new_album" ).html( old_val );
|
333 |
} );
|
334 |
+
} else {
|
335 |
rtmedia_gallery_action_alert_message( rtmedia_empty_album_name_msg, 'warning' );
|
336 |
}
|
337 |
} );
|
339 |
jQuery( '.rtmedia-container' ).on( 'click', '.rtmedia-delete-selected', function ( e ) {
|
340 |
if ( jQuery( '.rtmedia-list :checkbox:checked' ).length > 0 ) {
|
341 |
if ( confirm( rtmedia_selected_media_delete_confirmation ) ) {
|
342 |
+
jQuery( this ).closest( 'form' ).attr( 'action', '../../../' + rtmedia_media_slug + '/delete' ).submit();
|
343 |
}
|
344 |
} else {
|
345 |
rtmedia_gallery_action_alert_message( rtmedia_no_media_selected, 'warning' );
|
357 |
|
358 |
} );
|
359 |
|
360 |
+
jQuery( '#buddypress' ).on( 'change', '.rtm-activity-privacy-opt', function(){
|
361 |
+
|
362 |
+
var activity_id = jQuery( this ).attr( 'id' );
|
363 |
+
activity_id = activity_id.split( '-' );
|
364 |
+
activity_id = activity_id[ activity_id.length - 1 ];
|
365 |
+
|
366 |
+
var that = this;
|
367 |
+
|
368 |
+
data = {
|
369 |
+
activity_id : activity_id,
|
370 |
+
privacy : jQuery( this ).val(),
|
371 |
+
nonce : jQuery( '#rtmedia_activity_privacy_nonce' ).val(),
|
372 |
+
action : 'rtm_change_activity_privacy'
|
373 |
+
};
|
374 |
+
|
375 |
+
jQuery.post( ajaxurl, data, function( res ){
|
376 |
+
var message = '';
|
377 |
+
var css_class = '';
|
378 |
+
if ( res == "true" ) {
|
379 |
+
message = "Privacy updated successfully.";
|
380 |
+
css_class = 'success';
|
381 |
+
} else {
|
382 |
+
message = "Couldn't change privacy, please try again.";
|
383 |
+
css_class = 'fail';
|
384 |
+
}
|
385 |
+
|
386 |
+
jQuery( that ).after( '<p class="rtm-ac-privacy-updated ' + css_class + '">' + message + '</p>' );
|
387 |
+
setTimeout( function(){
|
388 |
+
jQuery( that ).siblings( '.rtm-ac-privacy-updated' ).remove();
|
389 |
+
}, 2000 );
|
390 |
+
} );
|
391 |
+
} );
|
392 |
|
393 |
function rtmedia_media_view_counts() {
|
394 |
//var view_count_action = jQuery('#rtmedia-media-view-form').attr("action");
|
395 |
if ( jQuery( '#rtmedia-media-view-form' ).length > 0 ) {
|
396 |
var url = jQuery( '#rtmedia-media-view-form' ).attr( "action" );
|
397 |
+
jQuery.post( url, { }, function ( data ) {
|
|
|
|
|
398 |
|
399 |
} );
|
400 |
}
|
402 |
|
403 |
rtmedia_media_view_counts();
|
404 |
rtMediaHook.register( 'rtmedia_js_popup_after_content_added',
|
405 |
+
function () {
|
406 |
rtmedia_media_view_counts();
|
407 |
rtmedia_init_media_deleting();
|
408 |
+
mfp = jQuery.magnificPopup.instance;
|
409 |
+
if ( jQuery( mfp.items ).size() > 1 ) {
|
410 |
+
rtmedia_init_popup_navigation();
|
411 |
+
}
|
412 |
|
413 |
rtmedia_disable_popup_navigation_comment_focus();
|
414 |
var height = $( window ).height();
|
443 |
$( 'li.total' ).html( counts );
|
444 |
|
445 |
return true;
|
446 |
+
}
|
447 |
);
|
448 |
|
449 |
function rtmedia_init_popup_navigation() {
|
470 |
}
|
471 |
|
472 |
function rtmedia_disable_popup_navigation_comment_focus() {
|
473 |
+
jQuery( document ).on( 'focusin', '#comment_content', function() {
|
474 |
+
jQuery( document ).unbind( 'keydown' );
|
475 |
+
} );
|
476 |
+
jQuery( document ).on( 'focusout', '#comment_content', function() {
|
477 |
+
var rtm_mfp = jQuery.magnificPopup.instance;
|
478 |
+
jQuery( document ).on( 'keydown', function( e ) {
|
479 |
+
if ( e.keyCode === 37 ) {
|
480 |
+
rtm_mfp.prev();
|
481 |
+
} else if ( e.keyCode === 39 ) {
|
482 |
+
rtm_mfp.next();
|
483 |
+
}
|
484 |
+
} );
|
485 |
+
} );
|
486 |
+
}
|
487 |
+
|
488 |
+
var dragArea = jQuery( "#drag-drop-area" );
|
489 |
+
var activityArea = jQuery( '#whats-new' );
|
490 |
+
var content = dragArea.html();
|
491 |
+
jQuery( '#rtmedia-upload-container' ).after( "<div id='rtm-drop-files-title'>" + rtmedia_drop_media_msg + "</div>" );
|
492 |
+
if ( typeof rtmedia_bp_enable_activity != "undefined" && rtmedia_bp_enable_activity == "1" ) {
|
493 |
+
jQuery( '#whats-new-textarea' ).append( "<div id='rtm-drop-files-title'>" + rtmedia_drop_media_msg + "</div>" );
|
494 |
+
}
|
495 |
+
jQuery( document )
|
496 |
+
.on( 'dragover', function( e ) {
|
497 |
+
jQuery( '#rtm-media-gallery-uploader' ).show();
|
498 |
+
if ( typeof rtmedia_bp_enable_activity != "undefined" && rtmedia_bp_enable_activity == "1" ) {
|
499 |
+
activityArea.addClass( 'rtm-drag-drop-active' );
|
500 |
+
}
|
501 |
+
|
502 |
+
// activityArea.css('height','150px');
|
503 |
dragArea.addClass( 'rtm-drag-drop-active' );
|
504 |
jQuery( '#rtm-drop-files-title' ).show();
|
505 |
} )
|
523 |
jQuery( '#rtm-drop-files-title' ).hide();
|
524 |
} );
|
525 |
|
|
|
526 |
function rtmedia_init_media_deleting() {
|
527 |
jQuery( '.rtmedia-container' ).on( 'click', '.rtmedia-delete-media', function ( e ) {
|
528 |
e.preventDefault();
|
566 |
} );
|
567 |
}
|
568 |
|
569 |
+
// masonry code
|
570 |
if ( typeof rtmedia_masonry_layout != "undefined" && rtmedia_masonry_layout == "true" && jQuery( '.rtmedia-container .rtmedia-list.rtm-no-masonry' ).length == 0 ) {
|
571 |
rtm_masonry_container = jQuery( '.rtmedia-container .rtmedia-list' )
|
572 |
rtm_masonry_container.masonry( {
|
583 |
} );
|
584 |
}
|
585 |
|
586 |
+
if ( jQuery( '.rtm-uploader-tabs' ).length > 0 ) {
|
587 |
+
jQuery( '.rtm-uploader-tabs li' ).click( function( e ){
|
588 |
+
if ( ! jQuery( this ).hasClass( 'active' ) ) {
|
589 |
+
jQuery( this ).siblings().removeClass( 'active' );
|
590 |
+
jQuery( this ).parents( '.rtm-uploader-tabs' ).siblings().hide();
|
591 |
+
class_name = jQuery( this ).attr( 'class' );
|
592 |
+
jQuery( this ).parents( '.rtm-uploader-tabs' ).siblings( '[data-id="' + class_name + '"]' ).show();
|
593 |
+
jQuery( this ).addClass( 'active' );
|
594 |
+
|
595 |
+
if ( class_name != 'rtm-upload-tab' ) {
|
596 |
+
jQuery( 'div.moxie-shim' ).children( 'input[type=file]' ).hide();
|
597 |
+
} else {
|
598 |
+
jQuery( 'div.moxie-shim' ).children( 'input[type=file]' ).show();
|
599 |
+
}
|
600 |
+
}
|
601 |
+
});
|
602 |
+
}
|
603 |
|
604 |
// delete media from gallery page under the user's profile when user clicks the delete button on the gallery item.
|
605 |
jQuery( '.rtmedia-container' ).on( 'click', '.rtm-delete-media', function ( e ) {
|
606 |
e.preventDefault();
|
607 |
var confirmation = 'Are you sure you want to delete this media?';
|
608 |
|
609 |
+
if ( typeof rtmedia_media_delete_confirmation != 'undefined' ) {
|
610 |
confirmation = rtmedia_media_delete_confirmation;
|
611 |
}
|
612 |
|
640 |
} );
|
641 |
}
|
642 |
} );
|
643 |
+
} );
|
|
|
|
|
644 |
|
645 |
//Legacy media element for old activities
|
646 |
function bp_media_create_element( id ) {
|
647 |
return false;
|
648 |
}
|
649 |
|
650 |
+
function rtmedia_version_compare( left, right ) {
|
651 |
+
if ( typeof left + typeof right != 'stringstring' ) {
|
652 |
+
return false;
|
653 |
+
}
|
654 |
+
|
655 |
+
var a = left.split( '.' ),
|
656 |
+
b = right.split( '.' ),
|
657 |
+
i = 0,
|
658 |
+
len = Math.max( a.length, b.length );
|
659 |
+
|
660 |
+
for ( ; i < len; i ++ ) {
|
661 |
+
if ( ( a[i] && ! b[i] && parseInt( a[i] ) > 0 ) || ( parseInt( a[i] ) > parseInt( b[i] ) ) ) {
|
662 |
+
return true;
|
663 |
+
} else if ( ( b[i] && ! a[i] && parseInt( b[i] ) > 0 ) || ( parseInt( a[i] ) < parseInt( b[i] ) ) ) {
|
664 |
+
return false;
|
665 |
+
}
|
666 |
+
}
|
667 |
+
|
668 |
+
return true;
|
669 |
+
}
|
670 |
+
|
671 |
+
function rtm_is_element_exist( el ) {
|
672 |
+
if ( jQuery( el ).length > 0 ) {
|
673 |
+
return true;
|
674 |
+
} else {
|
675 |
+
return false;
|
676 |
+
}
|
677 |
+
}
|
678 |
+
|
679 |
+
function rtm_masonry_reload( el ) {
|
680 |
+
setTimeout( function () {
|
681 |
+
// we make masonry recalculate the element based on their current state.
|
682 |
+
el.masonry( 'reload' );
|
683 |
+
}, 250 );
|
684 |
+
}
|
685 |
+
|
686 |
/*
|
687 |
* To change this license header, choose License Headers in Project Properties.
|
688 |
* To change this template file, choose Tools | Templates
|
706 |
|
707 |
$( document ).on( { click: function () {
|
708 |
|
709 |
+
var $this = $( this );
|
710 |
+
if ( $this.hasClass( 'less' ) ) {
|
711 |
+
$this.removeClass( 'less' );
|
712 |
+
$this.html( config.moreText );
|
713 |
+
} else {
|
714 |
+
$this.addClass( 'less' );
|
715 |
+
$this.html( config.lessText );
|
716 |
+
}
|
717 |
$this.parent().prev().toggle();
|
718 |
$this.prev().toggle();
|
719 |
return false;
|
720 |
+
} }, '.morelink' );
|
|
|
721 |
|
722 |
return this.each( function () {
|
723 |
var $this = $( this );
|
724 |
+
if ( $this.hasClass( "shortened" ) ) {
|
725 |
+
return; }
|
726 |
|
727 |
$this.addClass( "shortened" );
|
728 |
var content = $this.html();
|
739 |
|
740 |
} )( jQuery );
|
741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
window.onload = function () {
|
743 |
if ( typeof rtmedia_masonry_layout != "undefined" && rtmedia_masonry_layout == "true" && jQuery( '.rtmedia-container .rtmedia-list.rtm-no-masonry' ).length == 0 ) {
|
744 |
rtm_masonry_reload( rtm_masonry_container );
|
754 |
}
|
755 |
|
756 |
function rtmedia_single_media_alert_message( msg, action ) {
|
757 |
+
var action_class = 'rtmedia-success';
|
758 |
|
759 |
+
if ( 'warning' == action ) {
|
760 |
+
action_class = 'rtmedia-warning';
|
761 |
+
}
|
762 |
|
763 |
+
jQuery( '.rtmedia-single-media .rtmedia-media' ).css( 'opacity', '0.2' );
|
764 |
+
jQuery( '.rtmedia-single-media .rtmedia-media' ).after( "<div class='rtmedia-message-container'><span class='" + action_class + "'>" + msg + " </span></div>" );
|
765 |
|
766 |
+
setTimeout( function() {
|
767 |
+
jQuery( '.rtmedia-single-media .rtmedia-media' ).css( 'opacity', '1' );
|
768 |
+
jQuery( ".rtmedia-message-container" ).remove();
|
769 |
+
}, 3000 );
|
770 |
|
771 |
+
jQuery( '.rtmedia-message-container' ).click( function() {
|
772 |
+
jQuery( '.rtmedia-single-media .rtmedia-media' ).css( 'opacity', '1' );
|
773 |
+
jQuery( ".rtmedia-message-container" ).remove();
|
774 |
+
} );
|
775 |
}
|
776 |
|
777 |
function rtmedia_gallery_action_alert_message( msg, action ) {
|
782 |
}
|
783 |
var container = '<div class="rtmedia-gallery-alert-container"> </div>';
|
784 |
jQuery( 'body' ).append( container );
|
785 |
+
jQuery( '.rtmedia-gallery-alert-container' ).append( "<div class='rtmedia-gallery-message-box'><span class='" + action_class + "'>" + msg + " </span></div>" );
|
786 |
|
787 |
setTimeout( function() { jQuery( ".rtmedia-gallery-alert-container" ).remove();
|
788 |
}, 3000 );
|
789 |
|
790 |
+
jQuery( '.rtmedia-gallery-message-box' ).click( function() {
|
791 |
jQuery( ".rtmedia-gallery-alert-container" ).remove();
|
792 |
} );
|
793 |
}
|
app/assets/js/rtmedia.min.js
CHANGED
@@ -3,4 +3,4 @@
|
|
3 |
* @package rtMedia
|
4 |
*/
|
5 |
function apply_rtMagnificPopup(a){jQuery("document").ready(function(b){var c="";c="undefined"==typeof rtmedia_load_more?"Loading media":rtmedia_load_more,"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&(b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").length>0&&b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").addClass("no-popup"),rtMagnificPopup=jQuery(a).magnificPopup({delegate:"a:not(.no-popup, .mejs-time-slider, .mejs-volume-slider, .mejs-horizontal-volume-slider)",type:"ajax",tLoading:c+" #%curr%...",mainClass:"mfp-img-mobile",preload:[1,3],closeOnBgClick:!0,gallery:{enabled:!0,navigateByImgClick:!0,arrowMarkup:"",preload:[0,1]},image:{tError:'<a href="%url%">The image #%curr%</a> could not be loaded.',titleSrc:function(a){return a.el.attr("title")+"<small>by Marsel Van Oosten</small>"}},callbacks:{ajaxContentAdded:function(){a=jQuery.magnificPopup.instance,1===jQuery(a.items).size()&&jQuery(".mfp-arrow").remove();var a=jQuery.magnificPopup.instance,c=a.currItem.el,d=c.parent();if(d.is("li")||(d=d.parent()),d.is(":nth-last-child(2)")||d.is(":last-child")){d.next();"block"==jQuery("#rtMedia-galary-next").css("display")&&jQuery("#rtMedia-galary-next").click()}var e=a.items.length;if(a.index==e-1&&!d.is(":last-child"))return void c.click();var f={};"undefined"!=typeof _wpmejsSettings&&(f.pluginPath=_wpmejsSettings.pluginPath),b(".mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270,success:function(a,b){a.play()}}),b(".mfp-content .mejs-audio .mejs-controls").css("position","relative"),rtMediaHook.call("rtmedia_js_popup_after_content_added",[])},close:function(a){rtmedia_init_action_dropdown()},BeforeChange:function(a){}}}))})}function rtmedia_init_action_dropdown(){var a,b;jQuery(".click-nav > span, .click-nav > div").toggleClass("no-js js"),jQuery(".click-nav .js ul").hide(),jQuery(".click-nav .clicker").click(function(c){a=jQuery("#rtm-media-options .click-nav .clicker").next("ul"),b=jQuery(this).next("ul"),jQuery.each(a,function(a,c){jQuery(c).html()!=b.html()&&jQuery(c).hide()}),jQuery(b).toggle(),c.stopPropagation()})}function bp_media_create_element(a){return!1}function rtmedia_version_compare(a,b){if(typeof a+typeof b!="stringstring")return!1;for(var c=a.split("."),d=b.split("."),e=0,f=Math.max(c.length,d.length);f>e;e++){if(c[e]&&!d[e]&&parseInt(c[e])>0||parseInt(c[e])>parseInt(d[e]))return!0;if(d[e]&&!c[e]&&parseInt(d[e])>0||parseInt(c[e])<parseInt(d[e]))return!1}return!0}function rtm_is_element_exist(a){return jQuery(a).length>0}function rtm_masonry_reload(a){setTimeout(function(){a.masonry("reload")},250)}function rtmediaGetParameterByName(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null==c?"":decodeURIComponent(c[1].replace(/\+/g," "))}function rtmedia_single_media_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning"),jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","0.2"),jQuery(".rtmedia-single-media .rtmedia-media").after("<div class='rtmedia-message-container'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()},3e3),jQuery(".rtmedia-message-container").click(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()})}function rtmedia_gallery_action_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning");var d='<div class="rtmedia-gallery-alert-container"> </div>';jQuery("body").append(d),jQuery(".rtmedia-gallery-alert-container").append("<div class='rtmedia-gallery-message-box'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-gallery-alert-container").remove()},3e3),jQuery(".rtmedia-gallery-message-box").click(function(){jQuery(".rtmedia-gallery-alert-container").remove()})}!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isIE7=-1!==c.indexOf("MSIE 7."),b.isIE8=-1!==c.indexOf("MSIE 8."),b.isLowIE=b.isIE7||b.isIE8,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e<h.length;e++)if(g=h[e],g.parsed&&(g=g.el[0]),g===c.el[0]){b.index=e;break}}else b.items=a.isArray(c.items)?c.items:[c.items],b.index=c.index||0;if(b.isOpen)return void b.updateItemHTML();b.types=[],f="",c.mainEl&&c.mainEl.length?b.ev=c.mainEl.eq(0):b.ev=d,c.key?(b.popupsCache[c.key]||(b.popupsCache[c.key]={}),b.currTemplate=b.popupsCache[c.key]):b.currTemplate={},b.st=a.extend(!0,{},a.magnificPopup.defaults,c),b.fixedContentPos="auto"===b.st.fixedContentPos?!b.probablyMobile:b.st.fixedContentPos,b.st.modal&&(b.st.closeOnContentClick=!1,b.st.closeOnBgClick=!1,b.st.showCloseBtn=!1,b.st.enableEscapeKey=!1),b.bgOverlay||(b.bgOverlay=x("bg").on("click"+p,function(){b.close()}),b.wrap=x("wrap").attr("tabindex",-1).on("click"+p,function(a){b._checkIfClose(a.target)&&b.close()}),b.container=x("container",b.wrap)),b.contentContainer=x("content"),b.st.preloader&&(b.preloader=x("preloader",b.container,b.st.tLoading));var i=a.magnificPopup.modules;for(e=0;e<i.length;e++){var j=i[e];j=j.charAt(0).toUpperCase()+j.slice(1),b["init"+j].call(b)}y("BeforeOpen"),b.st.showCloseBtn&&(b.st.closeBtnInside?(w(l,function(a,b,c,d){c.close_replaceWith=z(d.type)}),f+=" mfp-close-btn-in"):b.wrap.append(z())),b.st.alignTop&&(f+=" mfp-align-top"),b.fixedContentPos?b.wrap.css({overflow:b.st.overflowY,overflowX:"hidden",overflowY:b.st.overflowY}):b.wrap.css({top:v.scrollTop(),position:"absolute"}),(b.st.fixedBgPos===!1||"auto"===b.st.fixedBgPos&&!b.fixedContentPos)&&b.bgOverlay.css({height:d.height(),position:"absolute"}),b.st.enableEscapeKey&&d.on("keyup"+p,function(a){27===a.keyCode&&b.close()}),v.on("resize"+p,function(){b.updateSize()}),b.st.closeOnContentClick||(f+=" mfp-auto-cursor"),f&&b.wrap.addClass(f);var k=b.wH=v.height(),n={};if(b.fixedContentPos&&b._hasScrollBar(k)){var o=b._getScrollbarSize();o&&(n.marginRight=o)}b.fixedContentPos&&(b.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var r=b.st.mainClass;return b.isIE7&&(r+=" mfp-ie7"),r&&b._addClassToMFP(r),b.updateItemHTML(),y("BuildControls"),a("html").css(n),b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo||a(document.body)),b._lastFocusedEl=document.activeElement,setTimeout(function(){b.content?(b._addClassToMFP(q),b._setFocus()):b.bgOverlay.addClass(q),d.on("focusin"+p,b._onFocusIn)},16),b.isOpen=!0,b.updateSize(k),y(m),c},close:function(){b.isOpen&&(y(i),b.isOpen=!1,b.st.removalDelay&&!b.isLowIE&&b.supportsTransition?(b._addClassToMFP(r),setTimeout(function(){b._close()},b.st.removalDelay)):b._close())},_close:function(){y(h);var c=r+" "+q+" ";if(b.bgOverlay.detach(),b.wrap.detach(),b.container.empty(),b.st.mainClass&&(c+=b.st.mainClass+" "),b._removeClassFromMFP(c),b.fixedContentPos){var e={marginRight:""};b.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}d.off("keyup"+p+" focusin"+p),b.ev.off(p),b.wrap.attr("class","mfp-wrap").removeAttr("style"),b.bgOverlay.attr("class","mfp-bg"),b.container.attr("class","mfp-container"),!b.st.showCloseBtn||b.st.closeBtnInside&&b.currTemplate[b.currItem.type]!==!0||b.currTemplate.closeBtn&&b.currTemplate.closeBtn.detach(),b._lastFocusedEl&&a(b._lastFocusedEl).focus(),b.currItem=null,b.content=null,b.currTemplate=null,b.prevHeight=0,y(j)},updateSize:function(a){if(b.isIOS){var c=document.documentElement.clientWidth/window.innerWidth,d=window.innerHeight*c;b.wrap.css("height",d),b.wH=d}else b.wH=a||v.height();b.fixedContentPos||b.wrap.css("height",b.wH),y("Resize")},updateItemHTML:function(){var c=b.items[b.index];b.contentContainer.detach(),b.content&&b.content.detach(),c.parsed||(c=b.parseEl(b.index));var d=c.type;if(y("BeforeChange",[b.currItem?b.currItem.type:"",d]),b.currItem=c,!b.currTemplate[d]){var f=b.st[d]?b.st[d].markup:!1;y("FirstMarkupParse",f),f?b.currTemplate[d]=a(f):b.currTemplate[d]=!0}e&&e!==c.type&&b.container.removeClass("mfp-"+e+"-holder");var g=b["get"+d.charAt(0).toUpperCase()+d.slice(1)](c,b.currTemplate[d]);b.appendContent(g,d),c.preloaded=!0,y(n,c),e=c.type,b.container.prepend(b.contentContainer),y("AfterChange")},appendContent:function(a,c){b.content=a,a?b.st.showCloseBtn&&b.st.closeBtnInside&&b.currTemplate[c]===!0?b.content.find(".mfp-close").length||b.content.append(z()):b.content=a:b.content="",y(k),b.container.addClass("mfp-"+c+"-holder"),b.contentContainer.append(b.content)},parseEl:function(c){var d,e=b.items[c];if(e.tagName?e={el:a(e)}:(d=e.type,e={data:e,src:e.src}),e.el){for(var f=b.types,g=0;g<f.length;g++)if(e.el.hasClass("mfp-"+f[g])){d=f[g];break}e.src=e.el.attr("data-mfp-src"),e.src||(e.src=e.el.attr("href"))}return e.type=d||b.st.type||"inline",e.index=c,e.parsed=!0,b.items[c]=e,y("ElementParse",e),b.items[c]},addGroup:function(a,c){var d=function(d){d.mfpEl=this,b._openClick(d,a,c)};c||(c={});var e="click.magnificPopup";c.mainEl=a,c.items?(c.isObj=!0,a.off(e).on(e,d)):(c.isObj=!1,c.delegate?a.off(e).on(e,c.delegate,d):(c.items=a,a.off(e).on(e,d)))},_openClick:function(c,d,e){var f=void 0!==e.midClick?e.midClick:a.magnificPopup.defaults.midClick;if(f||2!==c.which&&!c.ctrlKey&&!c.metaKey){var g=void 0!==e.disableOn?e.disableOn:a.magnificPopup.defaults.disableOn;if(g)if(a.isFunction(g)){if(!g.call(b))return!0}else if(v.width()<g)return!0;c.type&&(c.preventDefault(),b.isOpen&&c.stopPropagation()),e.el=a(c.mfpEl),e.delegate&&(e.items=d.find(e.delegate)),b.open(e)}},updateStatus:function(a,d){if(b.preloader){c!==a&&b.container.removeClass("mfp-s-"+c),d||"loading"!==a||(d=b.st.tLoading);var e={status:a,text:d};y("UpdateStatus",e),a=e.status,d=e.text,b.preloader.html(d),b.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),b.container.addClass("mfp-s-"+a),c=a}},_checkIfClose:function(c){if(!a(c).hasClass(s)){var d=b.st.closeOnContentClick,e=b.st.closeOnBgClick;if(d&&e)return!0;if(!b.content||a(c).hasClass("mfp-close")||b.preloader&&c===b.preloader[0])return!0;if(c===b.content[0]||a.contains(b.content[0],c)){if(d)return!0}else if(e&&a.contains(document,c))return!0;return!1}},_addClassToMFP:function(a){b.bgOverlay.addClass(a),b.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),b.wrap.removeClass(a)},_hasScrollBar:function(a){return(b.isIE7?d.height():document.body.scrollHeight)>(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(a,c){if(void 0===c||c===!1)return!0;if(e=a.split("_"),e.length>1){var d=b.find(p+"-"+e[0]);if(d.length>0){var f=e[1];"replaceWith"===f?d[0]!==c[0]&&d.replaceWith(c):"img"===f?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(e[1],c)}}else b.find(p+"-"+a).html(c)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">×</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("<div>");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=b.st.gallery,e=".mfp-gallery",g=Boolean(a.fn.mfpFastClick);return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s),h=g?"mfpFastClick":"click";e[h](function(){b.prev()}),f[h](function(){b.next()}),b.isIE7&&(x("b",e[0],!1,!0),x("a",e[0],!1,!0),x("b",f[0],!1,!0),x("a",f[0],!1,!0)),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowLeft&&g&&b.arrowLeft.add(b.arrowRight).destroyMfpFastClick(),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('<img class="mfp-img" />').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){v.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g,h=a(this);if(c){var i,j,k,l,m,n;h.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,v.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0],(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)&&(l=!0,d())}).on("touchend"+f,function(a){d(),l||n>1||(g=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){g=!1},b),e())})})}h.on("click"+f,function(){g||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&v.off("touchmove"+f+" touchend"+f)}}(),A()}),"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a,b,c,d){var e={init:function(b,c){var d=this;d.elem=c,d.$elem=a(c),d.options=a.extend({},a.fn.rtTab.options,b),d.rtTabs()},rtTabs:function(){var c=this,d=c.options.activeTab;c.$elem.find("li:nth-child("+d+")").addClass("active"),c.rtTabContent(activeTabContent="yes"),c.rtClick();var e="false"!==c.$elem.attr("data-hash");if(e===!0){var f=b.location.hash;f&&c.$elem.find("li").find('a[href="'+f+'"]').trigger("click"),a(b).on("hashchange",function(){var a=b.location.hash;c.$elem.find("li").find('a[href="'+a+'"]').trigger("click")})}},rtClick:function(){var c=this,d=c.$elem.find("li"),e=d.find("a");e.on("click",function(e){e.preventDefault(),d.removeClass("active"),c.rtTabContent(),a(this).parent().addClass("active");var f=a(this).attr("href");a(f).removeClass("hide");var g="false"!==c.$elem.attr("data-hash");if(g===!0){var h=a(b).scrollTop();location.hash=a(this).attr("href"),a(b).scrollTop(h)}"function"==typeof c.options.onComplete&&c.options.onComplete.apply(c.elem,arguments)})},rtTabContent:function(b){var c=this,d=c.$elem.find("li"),e=d.find("a");e.each(function(){var c=a(this),d=c.attr("href");"yes"===b?c.parent().hasClass("active")||a(d).addClass("hide"):a(d).addClass("hide")})}};a.fn.rtTab=function(b){return this.each(function(){var c=Object.create(e);c.init(b,this),a.data(this,"rtTab",c)})},a.fn.rtTab.options={activeTab:1,onComplete:null}}(jQuery,window,document);var rtMagnificPopup,rtm_masonry_container,rtMediaHook={hooks:[],is_break:!1,register:function(a,b){"undefined"==typeof rtMediaHook.hooks[a]&&(rtMediaHook.hooks[a]=[]),rtMediaHook.hooks[a].push(b)},call:function(a,arguments){if("undefined"!=typeof rtMediaHook.hooks[a])for(i=0;i<rtMediaHook.hooks[a].length;++i)if(1!=rtMediaHook.hooks[a][i](arguments))return rtMediaHook.is_break=!0,!1;return!0}};jQuery("document").ready(function(a){function b(){if(jQuery("#rtmedia-media-view-form").length>0){var a=jQuery("#rtmedia-media-view-form").attr("action");jQuery.post(a,{},function(a){})}}function c(){var a=jQuery.magnificPopup.instance;jQuery(".mfp-arrow-right").on("click",function(b){a.next()}),jQuery(".mfp-arrow-left").on("click",function(b){a.prev()}),jQuery(".mfp-content .rtmedia-media").swipe({swipeLeft:function(b,c,d,e,f){a.next()},swipeRight:function(b,c,d,e,f){a.prev()},threshold:0})}function d(){jQuery(document).on("focusin","#comment_content",function(){jQuery(document).unbind("keydown")}),jQuery(document).on("focusout","#comment_content",function(){var a=jQuery.magnificPopup.instance;jQuery(document).on("keydown",function(b){37===b.keyCode?a.prev():39===b.keyCode&&a.next()})})}function e(){jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()})}"undefined"!=typeof a.fn.rtTab&&a(".rtm-tabs").rtTab(),jQuery(".rtmedia-modal-link").length>0&&a(".rtmedia-modal-link").magnificPopup({type:"inline",midClick:!0,closeBtnInside:!0}),a("#rt_media_comment_form").submit(function(b){return""==a.trim(a("#comment_content").val())?(0==jQuery("#rtmedia-single-media-container").length?rtmedia_gallery_action_alert_message(rtmedia_empty_comment_msg,"warning"):rtmedia_single_media_alert_message(rtmedia_empty_comment_msg,"warning"),!1):!0}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&apply_rtMagnificPopup(".rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container"),jQuery.ajaxPrefilter(function(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}else if("get_single_activity_content"==b.data.action){var e=b.success;a.success=function(a){e(a),setTimeout(function(){apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),jQuery("ul.activity-list li.rtmedia_update:first-child .wp-audio-shortcode, ul.activity-list li.rtmedia_update:first-child .wp-video-shortcode").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270})},900)}}}),jQuery.ajaxPrefilter(function(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),jQuery("ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > audio.wp-audio-shortcode, ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > video.wp-video-shortcode").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270}),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}}),jQuery(".rtmedia-container").on("click",".select-all",function(a){jQuery(this).toggleClass("unselect-all").toggleClass("select-all"),jQuery(this).attr("title",rtmedia_unselect_all_visible),jQuery(".rtmedia-list input").each(function(){jQuery(this).prop("checked",!0)}),jQuery(".rtmedia-list-item").addClass("bulk-selected")}),jQuery(".rtmedia-container").on("click",".unselect-all",function(a){jQuery(this).toggleClass("select-all").toggleClass("unselect-all"),jQuery(this).attr("title",rtmedia_select_all_visible),jQuery(".rtmedia-list input").each(function(){jQuery(this).prop("checked",!1)}),jQuery(".rtmedia-list-item").removeClass("bulk-selected")}),jQuery(".rtmedia-container").on("click",".rtmedia-move",function(a){jQuery(".rtmedia-delete-container").slideUp(),jQuery(".rtmedia-move-container").slideToggle()}),jQuery("#rtmedia-create-album-modal").on("click","#rtmedia_create_new_album",function(b){if($albumname=jQuery("<span/>").text(jQuery.trim(jQuery("#rtmedia_album_name").val())).html(),
|
6 |
-
$context=jQuery.trim(jQuery("#rtmedia_album_context").val()),$context_id=jQuery.trim(jQuery("#rtmedia_album_context_id").val()),$privacy=jQuery.trim(jQuery("#rtmedia_select_album_privacy").val()),$create_album_nonce=jQuery.trim(jQuery("#rtmedia_create_album_nonce").val()),""!=$albumname){var c={action:"rtmedia_create_album",name:$albumname,context:$context,context_id:$context_id,create_album_nonce:$create_album_nonce};""!==$privacy&&(c.privacy=$privacy),a("#rtmedia_create_new_album").attr("disabled","disabled");var d=a("#rtmedia_create_new_album").html();a("#rtmedia_create_new_album").prepend("<img src='"+rMedia_loading_file+"' />"),jQuery.post(rtmedia_ajax_url,c,function(b){if(
|
3 |
* @package rtMedia
|
4 |
*/
|
5 |
function apply_rtMagnificPopup(a){jQuery("document").ready(function(b){var c="";c="undefined"==typeof rtmedia_load_more?"Loading media":rtmedia_load_more,"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&(b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").length>0&&b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").addClass("no-popup"),rtMagnificPopup=jQuery(a).magnificPopup({delegate:"a:not(.no-popup, .mejs-time-slider, .mejs-volume-slider, .mejs-horizontal-volume-slider)",type:"ajax",tLoading:c+" #%curr%...",mainClass:"mfp-img-mobile",preload:[1,3],closeOnBgClick:!0,gallery:{enabled:!0,navigateByImgClick:!0,arrowMarkup:"",preload:[0,1]},image:{tError:'<a href="%url%">The image #%curr%</a> could not be loaded.',titleSrc:function(a){return a.el.attr("title")+"<small>by Marsel Van Oosten</small>"}},callbacks:{ajaxContentAdded:function(){a=jQuery.magnificPopup.instance,1===jQuery(a.items).size()&&jQuery(".mfp-arrow").remove();var a=jQuery.magnificPopup.instance,c=a.currItem.el,d=c.parent();if(d.is("li")||(d=d.parent()),d.is(":nth-last-child(2)")||d.is(":last-child")){d.next();"block"==jQuery("#rtMedia-galary-next").css("display")&&jQuery("#rtMedia-galary-next").click()}var e=a.items.length;if(a.index==e-1&&!d.is(":last-child"))return void c.click();var f={};"undefined"!=typeof _wpmejsSettings&&(f.pluginPath=_wpmejsSettings.pluginPath),b(".mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270,success:function(a,b){a.play()}}),b(".mfp-content .mejs-audio .mejs-controls").css("position","relative"),rtMediaHook.call("rtmedia_js_popup_after_content_added",[])},close:function(a){rtmedia_init_action_dropdown()},BeforeChange:function(a){}}}))})}function rtmedia_init_action_dropdown(){var a,b;jQuery(".click-nav > span, .click-nav > div").toggleClass("no-js js"),jQuery(".click-nav .js ul").hide(),jQuery(".click-nav .clicker").click(function(c){a=jQuery("#rtm-media-options .click-nav .clicker").next("ul"),b=jQuery(this).next("ul"),jQuery.each(a,function(a,c){jQuery(c).html()!=b.html()&&jQuery(c).hide()}),jQuery(b).toggle(),c.stopPropagation()})}function bp_media_create_element(a){return!1}function rtmedia_version_compare(a,b){if(typeof a+typeof b!="stringstring")return!1;for(var c=a.split("."),d=b.split("."),e=0,f=Math.max(c.length,d.length);f>e;e++){if(c[e]&&!d[e]&&parseInt(c[e])>0||parseInt(c[e])>parseInt(d[e]))return!0;if(d[e]&&!c[e]&&parseInt(d[e])>0||parseInt(c[e])<parseInt(d[e]))return!1}return!0}function rtm_is_element_exist(a){return jQuery(a).length>0}function rtm_masonry_reload(a){setTimeout(function(){a.masonry("reload")},250)}function rtmediaGetParameterByName(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null==c?"":decodeURIComponent(c[1].replace(/\+/g," "))}function rtmedia_single_media_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning"),jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","0.2"),jQuery(".rtmedia-single-media .rtmedia-media").after("<div class='rtmedia-message-container'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()},3e3),jQuery(".rtmedia-message-container").click(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()})}function rtmedia_gallery_action_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning");var d='<div class="rtmedia-gallery-alert-container"> </div>';jQuery("body").append(d),jQuery(".rtmedia-gallery-alert-container").append("<div class='rtmedia-gallery-message-box'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-gallery-alert-container").remove()},3e3),jQuery(".rtmedia-gallery-message-box").click(function(){jQuery(".rtmedia-gallery-alert-container").remove()})}!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isIE7=-1!==c.indexOf("MSIE 7."),b.isIE8=-1!==c.indexOf("MSIE 8."),b.isLowIE=b.isIE7||b.isIE8,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e<h.length;e++)if(g=h[e],g.parsed&&(g=g.el[0]),g===c.el[0]){b.index=e;break}}else b.items=a.isArray(c.items)?c.items:[c.items],b.index=c.index||0;if(b.isOpen)return void b.updateItemHTML();b.types=[],f="",c.mainEl&&c.mainEl.length?b.ev=c.mainEl.eq(0):b.ev=d,c.key?(b.popupsCache[c.key]||(b.popupsCache[c.key]={}),b.currTemplate=b.popupsCache[c.key]):b.currTemplate={},b.st=a.extend(!0,{},a.magnificPopup.defaults,c),b.fixedContentPos="auto"===b.st.fixedContentPos?!b.probablyMobile:b.st.fixedContentPos,b.st.modal&&(b.st.closeOnContentClick=!1,b.st.closeOnBgClick=!1,b.st.showCloseBtn=!1,b.st.enableEscapeKey=!1),b.bgOverlay||(b.bgOverlay=x("bg").on("click"+p,function(){b.close()}),b.wrap=x("wrap").attr("tabindex",-1).on("click"+p,function(a){b._checkIfClose(a.target)&&b.close()}),b.container=x("container",b.wrap)),b.contentContainer=x("content"),b.st.preloader&&(b.preloader=x("preloader",b.container,b.st.tLoading));var i=a.magnificPopup.modules;for(e=0;e<i.length;e++){var j=i[e];j=j.charAt(0).toUpperCase()+j.slice(1),b["init"+j].call(b)}y("BeforeOpen"),b.st.showCloseBtn&&(b.st.closeBtnInside?(w(l,function(a,b,c,d){c.close_replaceWith=z(d.type)}),f+=" mfp-close-btn-in"):b.wrap.append(z())),b.st.alignTop&&(f+=" mfp-align-top"),b.fixedContentPos?b.wrap.css({overflow:b.st.overflowY,overflowX:"hidden",overflowY:b.st.overflowY}):b.wrap.css({top:v.scrollTop(),position:"absolute"}),(b.st.fixedBgPos===!1||"auto"===b.st.fixedBgPos&&!b.fixedContentPos)&&b.bgOverlay.css({height:d.height(),position:"absolute"}),b.st.enableEscapeKey&&d.on("keyup"+p,function(a){27===a.keyCode&&b.close()}),v.on("resize"+p,function(){b.updateSize()}),b.st.closeOnContentClick||(f+=" mfp-auto-cursor"),f&&b.wrap.addClass(f);var k=b.wH=v.height(),n={};if(b.fixedContentPos&&b._hasScrollBar(k)){var o=b._getScrollbarSize();o&&(n.marginRight=o)}b.fixedContentPos&&(b.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var r=b.st.mainClass;return b.isIE7&&(r+=" mfp-ie7"),r&&b._addClassToMFP(r),b.updateItemHTML(),y("BuildControls"),a("html").css(n),b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo||a(document.body)),b._lastFocusedEl=document.activeElement,setTimeout(function(){b.content?(b._addClassToMFP(q),b._setFocus()):b.bgOverlay.addClass(q),d.on("focusin"+p,b._onFocusIn)},16),b.isOpen=!0,b.updateSize(k),y(m),c},close:function(){b.isOpen&&(y(i),b.isOpen=!1,b.st.removalDelay&&!b.isLowIE&&b.supportsTransition?(b._addClassToMFP(r),setTimeout(function(){b._close()},b.st.removalDelay)):b._close())},_close:function(){y(h);var c=r+" "+q+" ";if(b.bgOverlay.detach(),b.wrap.detach(),b.container.empty(),b.st.mainClass&&(c+=b.st.mainClass+" "),b._removeClassFromMFP(c),b.fixedContentPos){var e={marginRight:""};b.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}d.off("keyup"+p+" focusin"+p),b.ev.off(p),b.wrap.attr("class","mfp-wrap").removeAttr("style"),b.bgOverlay.attr("class","mfp-bg"),b.container.attr("class","mfp-container"),!b.st.showCloseBtn||b.st.closeBtnInside&&b.currTemplate[b.currItem.type]!==!0||b.currTemplate.closeBtn&&b.currTemplate.closeBtn.detach(),b._lastFocusedEl&&a(b._lastFocusedEl).focus(),b.currItem=null,b.content=null,b.currTemplate=null,b.prevHeight=0,y(j)},updateSize:function(a){if(b.isIOS){var c=document.documentElement.clientWidth/window.innerWidth,d=window.innerHeight*c;b.wrap.css("height",d),b.wH=d}else b.wH=a||v.height();b.fixedContentPos||b.wrap.css("height",b.wH),y("Resize")},updateItemHTML:function(){var c=b.items[b.index];b.contentContainer.detach(),b.content&&b.content.detach(),c.parsed||(c=b.parseEl(b.index));var d=c.type;if(y("BeforeChange",[b.currItem?b.currItem.type:"",d]),b.currItem=c,!b.currTemplate[d]){var f=b.st[d]?b.st[d].markup:!1;y("FirstMarkupParse",f),f?b.currTemplate[d]=a(f):b.currTemplate[d]=!0}e&&e!==c.type&&b.container.removeClass("mfp-"+e+"-holder");var g=b["get"+d.charAt(0).toUpperCase()+d.slice(1)](c,b.currTemplate[d]);b.appendContent(g,d),c.preloaded=!0,y(n,c),e=c.type,b.container.prepend(b.contentContainer),y("AfterChange")},appendContent:function(a,c){b.content=a,a?b.st.showCloseBtn&&b.st.closeBtnInside&&b.currTemplate[c]===!0?b.content.find(".mfp-close").length||b.content.append(z()):b.content=a:b.content="",y(k),b.container.addClass("mfp-"+c+"-holder"),b.contentContainer.append(b.content)},parseEl:function(c){var d,e=b.items[c];if(e.tagName?e={el:a(e)}:(d=e.type,e={data:e,src:e.src}),e.el){for(var f=b.types,g=0;g<f.length;g++)if(e.el.hasClass("mfp-"+f[g])){d=f[g];break}e.src=e.el.attr("data-mfp-src"),e.src||(e.src=e.el.attr("href"))}return e.type=d||b.st.type||"inline",e.index=c,e.parsed=!0,b.items[c]=e,y("ElementParse",e),b.items[c]},addGroup:function(a,c){var d=function(d){d.mfpEl=this,b._openClick(d,a,c)};c||(c={});var e="click.magnificPopup";c.mainEl=a,c.items?(c.isObj=!0,a.off(e).on(e,d)):(c.isObj=!1,c.delegate?a.off(e).on(e,c.delegate,d):(c.items=a,a.off(e).on(e,d)))},_openClick:function(c,d,e){var f=void 0!==e.midClick?e.midClick:a.magnificPopup.defaults.midClick;if(f||2!==c.which&&!c.ctrlKey&&!c.metaKey){var g=void 0!==e.disableOn?e.disableOn:a.magnificPopup.defaults.disableOn;if(g)if(a.isFunction(g)){if(!g.call(b))return!0}else if(v.width()<g)return!0;c.type&&(c.preventDefault(),b.isOpen&&c.stopPropagation()),e.el=a(c.mfpEl),e.delegate&&(e.items=d.find(e.delegate)),b.open(e)}},updateStatus:function(a,d){if(b.preloader){c!==a&&b.container.removeClass("mfp-s-"+c),d||"loading"!==a||(d=b.st.tLoading);var e={status:a,text:d};y("UpdateStatus",e),a=e.status,d=e.text,b.preloader.html(d),b.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),b.container.addClass("mfp-s-"+a),c=a}},_checkIfClose:function(c){if(!a(c).hasClass(s)){var d=b.st.closeOnContentClick,e=b.st.closeOnBgClick;if(d&&e)return!0;if(!b.content||a(c).hasClass("mfp-close")||b.preloader&&c===b.preloader[0])return!0;if(c===b.content[0]||a.contains(b.content[0],c)){if(d)return!0}else if(e&&a.contains(document,c))return!0;return!1}},_addClassToMFP:function(a){b.bgOverlay.addClass(a),b.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),b.wrap.removeClass(a)},_hasScrollBar:function(a){return(b.isIE7?d.height():document.body.scrollHeight)>(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(a,c){if(void 0===c||c===!1)return!0;if(e=a.split("_"),e.length>1){var d=b.find(p+"-"+e[0]);if(d.length>0){var f=e[1];"replaceWith"===f?d[0]!==c[0]&&d.replaceWith(c):"img"===f?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(e[1],c)}}else b.find(p+"-"+a).html(c)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">×</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("<div>");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=b.st.gallery,e=".mfp-gallery",g=Boolean(a.fn.mfpFastClick);return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s),h=g?"mfpFastClick":"click";e[h](function(){b.prev()}),f[h](function(){b.next()}),b.isIE7&&(x("b",e[0],!1,!0),x("a",e[0],!1,!0),x("b",f[0],!1,!0),x("a",f[0],!1,!0)),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowLeft&&g&&b.arrowLeft.add(b.arrowRight).destroyMfpFastClick(),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('<img class="mfp-img" />').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){v.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g,h=a(this);if(c){var i,j,k,l,m,n;h.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,v.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0],(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)&&(l=!0,d())}).on("touchend"+f,function(a){d(),l||n>1||(g=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){g=!1},b),e())})})}h.on("click"+f,function(){g||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&v.off("touchmove"+f+" touchend"+f)}}(),A()}),"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a,b,c,d){var e={init:function(b,c){var d=this;d.elem=c,d.$elem=a(c),d.options=a.extend({},a.fn.rtTab.options,b),d.rtTabs()},rtTabs:function(){var c=this,d=c.options.activeTab;c.$elem.find("li:nth-child("+d+")").addClass("active"),c.rtTabContent(activeTabContent="yes"),c.rtClick();var e="false"!==c.$elem.attr("data-hash");if(e===!0){var f=b.location.hash;f&&c.$elem.find("li").find('a[href="'+f+'"]').trigger("click"),a(b).on("hashchange",function(){var a=b.location.hash;c.$elem.find("li").find('a[href="'+a+'"]').trigger("click")})}},rtClick:function(){var c=this,d=c.$elem.find("li"),e=d.find("a");e.on("click",function(e){e.preventDefault(),d.removeClass("active"),c.rtTabContent(),a(this).parent().addClass("active");var f=a(this).attr("href");a(f).removeClass("hide");var g="false"!==c.$elem.attr("data-hash");if(g===!0){var h=a(b).scrollTop();location.hash=a(this).attr("href"),a(b).scrollTop(h)}"function"==typeof c.options.onComplete&&c.options.onComplete.apply(c.elem,arguments)})},rtTabContent:function(b){var c=this,d=c.$elem.find("li"),e=d.find("a");e.each(function(){var c=a(this),d=c.attr("href");"yes"===b?c.parent().hasClass("active")||a(d).addClass("hide"):a(d).addClass("hide")})}};a.fn.rtTab=function(b){return this.each(function(){var c=Object.create(e);c.init(b,this),a.data(this,"rtTab",c)})},a.fn.rtTab.options={activeTab:1,onComplete:null}}(jQuery,window,document);var rtMagnificPopup,rtm_masonry_container,rtMediaHook={hooks:[],is_break:!1,register:function(a,b){"undefined"==typeof rtMediaHook.hooks[a]&&(rtMediaHook.hooks[a]=[]),rtMediaHook.hooks[a].push(b)},call:function(a,arguments){if("undefined"!=typeof rtMediaHook.hooks[a])for(i=0;i<rtMediaHook.hooks[a].length;++i)if(1!=rtMediaHook.hooks[a][i](arguments))return rtMediaHook.is_break=!0,!1;return!0}};jQuery("document").ready(function(a){function b(){if(jQuery("#rtmedia-media-view-form").length>0){var a=jQuery("#rtmedia-media-view-form").attr("action");jQuery.post(a,{},function(a){})}}function c(){var a=jQuery.magnificPopup.instance;jQuery(".mfp-arrow-right").on("click",function(b){a.next()}),jQuery(".mfp-arrow-left").on("click",function(b){a.prev()}),jQuery(".mfp-content .rtmedia-media").swipe({swipeLeft:function(b,c,d,e,f){a.next()},swipeRight:function(b,c,d,e,f){a.prev()},threshold:0})}function d(){jQuery(document).on("focusin","#comment_content",function(){jQuery(document).unbind("keydown")}),jQuery(document).on("focusout","#comment_content",function(){var a=jQuery.magnificPopup.instance;jQuery(document).on("keydown",function(b){37===b.keyCode?a.prev():39===b.keyCode&&a.next()})})}function e(){jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()})}"undefined"!=typeof a.fn.rtTab&&a(".rtm-tabs").rtTab(),jQuery(".rtmedia-modal-link").length>0&&a(".rtmedia-modal-link").magnificPopup({type:"inline",midClick:!0,closeBtnInside:!0}),a("#rt_media_comment_form").submit(function(b){return""==a.trim(a("#comment_content").val())?(0==jQuery("#rtmedia-single-media-container").length?rtmedia_gallery_action_alert_message(rtmedia_empty_comment_msg,"warning"):rtmedia_single_media_alert_message(rtmedia_empty_comment_msg,"warning"),!1):!0}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&apply_rtMagnificPopup(".rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container"),jQuery.ajaxPrefilter(function(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}else if("get_single_activity_content"==b.data.action){var e=b.success;a.success=function(a){e(a),setTimeout(function(){apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),jQuery("ul.activity-list li.rtmedia_update:first-child .wp-audio-shortcode, ul.activity-list li.rtmedia_update:first-child .wp-video-shortcode").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270})},900)}}}),jQuery.ajaxPrefilter(function(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),jQuery("ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > audio.wp-audio-shortcode, ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > video.wp-video-shortcode").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270}),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}}),jQuery(".rtmedia-container").on("click",".select-all",function(a){jQuery(this).toggleClass("unselect-all").toggleClass("select-all"),jQuery(this).attr("title",rtmedia_unselect_all_visible),jQuery(".rtmedia-list input").each(function(){jQuery(this).prop("checked",!0)}),jQuery(".rtmedia-list-item").addClass("bulk-selected")}),jQuery(".rtmedia-container").on("click",".unselect-all",function(a){jQuery(this).toggleClass("select-all").toggleClass("unselect-all"),jQuery(this).attr("title",rtmedia_select_all_visible),jQuery(".rtmedia-list input").each(function(){jQuery(this).prop("checked",!1)}),jQuery(".rtmedia-list-item").removeClass("bulk-selected")}),jQuery(".rtmedia-container").on("click",".rtmedia-move",function(a){jQuery(".rtmedia-delete-container").slideUp(),jQuery(".rtmedia-move-container").slideToggle()}),jQuery("#rtmedia-create-album-modal").on("click","#rtmedia_create_new_album",function(b){if($albumname=jQuery("<span/>").text(jQuery.trim(jQuery("#rtmedia_album_name").val())).html(),
|
6 |
+
$context=jQuery.trim(jQuery("#rtmedia_album_context").val()),$context_id=jQuery.trim(jQuery("#rtmedia_album_context_id").val()),$privacy=jQuery.trim(jQuery("#rtmedia_select_album_privacy").val()),$create_album_nonce=jQuery.trim(jQuery("#rtmedia_create_album_nonce").val()),""!=$albumname){var c={action:"rtmedia_create_album",name:$albumname,context:$context,context_id:$context_id,create_album_nonce:$create_album_nonce};""!==$privacy&&(c.privacy=$privacy),a("#rtmedia_create_new_album").attr("disabled","disabled");var d=a("#rtmedia_create_new_album").html();a("#rtmedia_create_new_album").prepend("<img src='"+rMedia_loading_file+"' />"),jQuery.post(rtmedia_ajax_url,c,function(b){if("undefined"!=typeof b.album){b=jQuery.trim(b.album);var c=!0;jQuery(".rtmedia-user-album-list").each(function(){if(jQuery(this).children("optgroup").each(function(){return jQuery(this).attr("value")===$context?(c=!1,void jQuery(this).append('<option value="'+b+'">'+$albumname+"</option>")):void 0}),c){var a=$context.charAt(0).toUpperCase()+$context.slice(1),d='<optgroup value="'+$context+'" label="'+a+' Albums"><option value="'+b+'">'+$albumname+"</option></optgroup>";jQuery(this).append(d)}}),jQuery('select.rtmedia-user-album-list option[value="'+b+'"]').prop("selected",!0),jQuery(".rtmedia-create-new-album-container").slideToggle(),jQuery("#rtmedia_album_name").val(""),jQuery("#rtmedia-create-album-modal").append("<div class='rtmedia-success rtmedia-create-album-alert'><b>"+$albumname+"</b>"+rtmedia_album_created_msg+"</div>"),setTimeout(function(){jQuery(".rtmedia-create-album-alert").remove()},4e3),setTimeout(function(){galleryObj.reloadView(),jQuery(".close-reveal-modal").click()},2e3)}else"undefined"!=typeof b.error?rtmedia_gallery_action_alert_message(b.error,"warning"):rtmedia_gallery_action_alert_message(rtmedia_something_wrong_msg,"warning");a("#rtmedia_create_new_album").removeAttr("disabled"),a("#rtmedia_create_new_album").html(d)})}else rtmedia_gallery_action_alert_message(rtmedia_empty_album_name_msg,"warning")}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-selected",function(a){jQuery(".rtmedia-list :checkbox:checked").length>0?confirm(rtmedia_selected_media_delete_confirmation)&&jQuery(this).closest("form").attr("action","../../../"+rtmedia_media_slug+"/delete").submit():rtmedia_gallery_action_alert_message(rtmedia_no_media_selected,"warning")}),jQuery(".rtmedia-container").on("click",".rtmedia-move-selected",function(a){jQuery(".rtmedia-list :checkbox:checked").length>0?confirm(rtmedia_selected_media_move_confirmation)&&jQuery(this).closest("form").attr("action","").submit():rtmedia_gallery_action_alert_message(rtmedia_no_media_selected,"warning")}),jQuery("#buddypress").on("change",".rtm-activity-privacy-opt",function(){var a=jQuery(this).attr("id");a=a.split("-"),a=a[a.length-1];var b=this;data={activity_id:a,privacy:jQuery(this).val(),nonce:jQuery("#rtmedia_activity_privacy_nonce").val(),action:"rtm_change_activity_privacy"},jQuery.post(ajaxurl,data,function(a){var c="",d="";"true"==a?(c="Privacy updated successfully.",d="success"):(c="Couldn't change privacy, please try again.",d="fail"),jQuery(b).after('<p class="rtm-ac-privacy-updated '+d+'">'+c+"</p>"),setTimeout(function(){jQuery(b).siblings(".rtm-ac-privacy-updated").remove()},2e3)})}),b(),rtMediaHook.register("rtmedia_js_popup_after_content_added",function(){b(),e(),mfp=jQuery.magnificPopup.instance,jQuery(mfp.items).size()>1&&c(),d();var f=a(window).height();jQuery(".rtm-lightbox-container .mejs-video").css({height:.8*f,"max-height":.8*f,"over-flow":"hidden"}),jQuery(".mfp-content .rtmedia-media").css({"max-height":.87*f,"over-flow":"hidden"}),rtmedia_init_action_dropdown(),jQuery(".rtmedia-comment-link").on("click",function(a){a.preventDefault(),jQuery("#comment_content").focus()}),jQuery(".rtm-more").shorten({showChars:130});var g=a(".rtm-gallery-title"),h="";h=a.isEmptyObject(g)?a("#subnav.item-list-tabs li.selected ").html():g.html(),""!=h&&a(".rtm-ltb-gallery-title .ltb-title").html(h);var i=a("#subnav.item-list-tabs li.selected span").html();return a("li.total").html(i),!0});var f=jQuery("#drag-drop-area"),g=jQuery("#whats-new");f.html();jQuery("#rtmedia-upload-container").after("<div id='rtm-drop-files-title'>"+rtmedia_drop_media_msg+"</div>"),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&jQuery("#whats-new-textarea").append("<div id='rtm-drop-files-title'>"+rtmedia_drop_media_msg+"</div>"),jQuery(document).on("dragover",function(a){jQuery("#rtm-media-gallery-uploader").show(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&g.addClass("rtm-drag-drop-active"),f.addClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").show()}).on("dragleave",function(a){a.preventDefault(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(g.removeClass("rtm-drag-drop-active"),g.removeAttr("style")),f.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}).on("drop",function(a){a.preventDefault(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(g.removeClass("rtm-drag-drop-active"),g.removeAttr("style")),f.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-album",function(a){a.preventDefault(),confirm(rtmedia_album_delete_confirmation)&&jQuery(this).closest("form").submit()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()}),rtmedia_init_action_dropdown(),a(document).click(function(){a(".click-nav ul").is(":visible")&&a(".click-nav ul",this).hide()}),jQuery(".rtmedia-comment-link").on("click",function(a){a.preventDefault(),jQuery("#comment_content").focus()}),jQuery(".rtm-more").length>0&&a(".rtm-more").shorten({showChars:200}),"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&0==jQuery(".rtmedia-container .rtmedia-list.rtm-no-masonry").length&&(rtm_masonry_container=jQuery(".rtmedia-container .rtmedia-list"),rtm_masonry_container.masonry({itemSelector:".rtmedia-list-item"}),setInterval(function(){jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),function(a,b){jQuery(b).width(jQuery(b).siblings(".rtmedia-item-thumbnail").children("img").width())}),rtm_masonry_reload(rtm_masonry_container)},1e3),jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),function(a,b){jQuery(b).width(jQuery(b).siblings(".rtmedia-item-thumbnail").children("img").width())})),jQuery(".rtm-uploader-tabs").length>0&&jQuery(".rtm-uploader-tabs li").click(function(a){jQuery(this).hasClass("active")||(jQuery(this).siblings().removeClass("active"),jQuery(this).parents(".rtm-uploader-tabs").siblings().hide(),class_name=jQuery(this).attr("class"),jQuery(this).parents(".rtm-uploader-tabs").siblings('[data-id="'+class_name+'"]').show(),jQuery(this).addClass("active"),"rtm-upload-tab"!=class_name?jQuery("div.moxie-shim").children("input[type=file]").hide():jQuery("div.moxie-shim").children("input[type=file]").show())}),jQuery(".rtmedia-container").on("click",".rtm-delete-media",function(a){a.preventDefault();var b="Are you sure you want to delete this media?";if("undefined"!=typeof rtmedia_media_delete_confirmation&&(b=rtmedia_media_delete_confirmation),confirm(b)){var c=jQuery(this).closest("li"),d=jQuery("#rtmedia_media_delete_nonce").val(),e={action:"delete_uploaded_media",nonce:d,media_id:c.attr("id")};jQuery.ajax({url:ajaxurl,type:"post",data:e,success:function(a){"1"==a?(rtmedia_gallery_action_alert_message("file deleted successfully.","success"),c.remove(),"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&0==jQuery(".rtmedia-container .rtmedia-list.rtm-no-masonry").length&&rtm_masonry_reload(rtm_masonry_container)):rtmedia_gallery_action_alert_message(rtmedia_file_not_deleted,"warning")}})}})}),function(a){a.fn.shorten=function(b){var c={showChars:100,ellipsesText:"...",moreText:"more",lessText:"less"};return b&&a.extend(c,b),a(document).off("click",".morelink"),a(document).on({click:function(){var b=a(this);return b.hasClass("less")?(b.removeClass("less"),b.html(c.moreText)):(b.addClass("less"),b.html(c.lessText)),b.parent().prev().toggle(),b.prev().toggle(),!1}},".morelink"),this.each(function(){var b=a(this);if(!b.hasClass("shortened")){b.addClass("shortened");var d=b.html();if(d.length>c.showChars){var e=d.substr(0,c.showChars),f=d.substr(c.showChars,d.length-c.showChars),g=e+'<span class="moreellipses">'+c.ellipsesText+' </span><span class="morecontent"><span>'+f+'</span> <a href="#" class="morelink">'+c.moreText+"</a></span>";b.html(g),a(".morecontent span").hide()}}})}}(jQuery),window.onload=function(){"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&0==jQuery(".rtmedia-container .rtmedia-list.rtm-no-masonry").length&&rtm_masonry_reload(rtm_masonry_container)};
|
app/helper/BPMediaBranding.php
CHANGED
@@ -9,14 +9,13 @@
|
|
9 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
10 |
* @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
|
11 |
*/
|
12 |
-
if ( ! class_exists( 'BPMediaBranding' ) ){
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
;
|
18 |
-
}
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
}
|
9 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
10 |
* @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
|
11 |
*/
|
12 |
+
if ( ! class_exists( 'BPMediaBranding' ) ) {
|
13 |
|
14 |
+
class BPMediaBranding {
|
15 |
|
16 |
+
public function __construct() {
|
|
|
|
|
17 |
|
18 |
+
}
|
19 |
+
}
|
20 |
|
21 |
+
}
|
app/helper/RTMediaActivityModel.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Time: 2:32 PM
|
7 |
*/
|
8 |
|
9 |
-
if ( ! class_exists( 'RTDBModel' ) ){
|
10 |
return;
|
11 |
}
|
12 |
|
@@ -18,36 +18,38 @@ class RTMediaActivityModel extends RTDBModel {
|
|
18 |
|
19 |
function get( $columns, $offset = false, $per_page = false, $order_by = 'activity_id DESC' ) {
|
20 |
$columns['blog_id'] = get_current_blog_id();
|
|
|
21 |
return parent::get( $columns, $offset, $per_page, $order_by );
|
22 |
}
|
23 |
|
24 |
function insert( $row ) {
|
25 |
$row['blog_id'] = get_current_blog_id();
|
|
|
26 |
return parent::insert( $row );
|
27 |
}
|
28 |
|
29 |
function update( $data, $where ) {
|
30 |
$where['blog_id'] = get_current_blog_id();
|
|
|
31 |
return parent::update( $data, $where );
|
32 |
}
|
33 |
|
34 |
public function check( $activity_id = '' ) {
|
35 |
-
if ( $activity_id
|
36 |
return false;
|
37 |
}
|
38 |
|
39 |
$columns = array(
|
40 |
'activity_id' => $activity_id,
|
41 |
-
'blog_id'
|
42 |
);
|
43 |
|
44 |
$results = $this->get( $columns );
|
45 |
|
46 |
-
if ( $results ){
|
47 |
return true;
|
48 |
} else {
|
49 |
return false;
|
50 |
}
|
51 |
}
|
52 |
-
|
53 |
-
}
|
6 |
* Time: 2:32 PM
|
7 |
*/
|
8 |
|
9 |
+
if ( ! class_exists( 'RTDBModel' ) ) {
|
10 |
return;
|
11 |
}
|
12 |
|
18 |
|
19 |
function get( $columns, $offset = false, $per_page = false, $order_by = 'activity_id DESC' ) {
|
20 |
$columns['blog_id'] = get_current_blog_id();
|
21 |
+
|
22 |
return parent::get( $columns, $offset, $per_page, $order_by );
|
23 |
}
|
24 |
|
25 |
function insert( $row ) {
|
26 |
$row['blog_id'] = get_current_blog_id();
|
27 |
+
|
28 |
return parent::insert( $row );
|
29 |
}
|
30 |
|
31 |
function update( $data, $where ) {
|
32 |
$where['blog_id'] = get_current_blog_id();
|
33 |
+
|
34 |
return parent::update( $data, $where );
|
35 |
}
|
36 |
|
37 |
public function check( $activity_id = '' ) {
|
38 |
+
if ( '' === $activity_id ) {
|
39 |
return false;
|
40 |
}
|
41 |
|
42 |
$columns = array(
|
43 |
'activity_id' => $activity_id,
|
44 |
+
'blog_id' => get_current_blog_id(),
|
45 |
);
|
46 |
|
47 |
$results = $this->get( $columns );
|
48 |
|
49 |
+
if ( $results ) {
|
50 |
return true;
|
51 |
} else {
|
52 |
return false;
|
53 |
}
|
54 |
}
|
55 |
+
}
|
|
app/helper/RTMediaAddon.php
CHANGED
@@ -23,10 +23,10 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
23 |
*
|
24 |
* @param void
|
25 |
*
|
26 |
-
* @return
|
27 |
*/
|
28 |
public function coming_soon_div() {
|
29 |
-
return '<div class="coming-soon coming-soon-l"></div> <a class="coming-soon coming-soon-r" href="' . $this->enquiry_link . '" target="_blank"></a>';
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -47,18 +47,18 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
-
foreach ( (
|
51 |
|
52 |
-
if ( $section[
|
53 |
-
call_user_func( $section[
|
54 |
}
|
55 |
|
56 |
-
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section[
|
57 |
continue;
|
58 |
}
|
59 |
|
60 |
echo '<table class="form-table">';
|
61 |
-
do_settings_fields( $page, $section[
|
62 |
echo '</table>';
|
63 |
}
|
64 |
}
|
@@ -75,20 +75,23 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
75 |
public function get_addons() {
|
76 |
$tabs = array();
|
77 |
global $rtmedia_admin;
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
|
86 |
$tabs[] = array(
|
87 |
-
'title'
|
88 |
-
'name'
|
89 |
-
'href'
|
90 |
-
'icon'
|
91 |
-
'callback' => array( $rtmedia_admin->rtmedia_encoding, 'encoding_service_intro' )
|
92 |
);
|
93 |
|
94 |
RTMediaAdmin::render_admin_ui( self::$page, $tabs );
|
@@ -104,445 +107,445 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
104 |
* @return void
|
105 |
*/
|
106 |
public function plugins_content( $args = '' ) {
|
107 |
-
$img_src = RTMEDIA_URL . 'app/assets/admin/img/';
|
108 |
$rtcamp_upload_url = 'https://cdn.rtmedia.io/wp-content/uploads/';
|
109 |
-
|
110 |
-
$addons
|
111 |
array(
|
112 |
-
'title'
|
113 |
-
'img_src'
|
114 |
'product_link' => 'https://rtmedia.io/products/rtmedia-seo/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
115 |
-
'desc'
|
116 |
-
'price'
|
117 |
-
'demo_link'
|
118 |
-
'buy_now'
|
119 |
-
'category'
|
120 |
-
'purchased'
|
121 |
-
),
|
122 |
-
|
123 |
-
'
|
|
|
124 |
'product_link' => 'https://rtmedia.io/products/rtmedia-moderation/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
125 |
-
'desc'
|
126 |
-
'price'
|
127 |
-
'demo_link'
|
128 |
-
'buy_now'
|
129 |
-
'category'
|
130 |
-
'purchased'
|
131 |
),
|
132 |
array(
|
133 |
-
'title'
|
134 |
-
'img_src'
|
135 |
'product_link' => 'https://rtmedia.io/products/rtmedia-custom-attributes/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
136 |
-
'desc'
|
137 |
-
'price'
|
138 |
-
'demo_link'
|
139 |
-
'buy_now'
|
140 |
-
'category'
|
141 |
-
'purchased'
|
142 |
),
|
143 |
array(
|
144 |
-
'title'
|
145 |
-
'img_src'
|
146 |
'product_link' => 'https://rtmedia.io/products/rtmedia-docs-files/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
147 |
-
'desc'
|
148 |
-
'price'
|
149 |
-
'demo_link'
|
150 |
-
'buy_now'
|
151 |
-
'category'
|
152 |
-
'purchased'
|
153 |
),
|
154 |
array(
|
155 |
-
'title'
|
156 |
-
'img_src'
|
157 |
'product_link' => 'https://rtmedia.io/products/rtmedia-default-albums/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
158 |
-
'desc'
|
159 |
-
'price'
|
160 |
-
'demo_link'
|
161 |
-
'buy_now'
|
162 |
-
'category'
|
163 |
-
'purchased'
|
164 |
),
|
165 |
array(
|
166 |
-
'title'
|
167 |
-
'img_src'
|
168 |
'product_link' => 'https://rtmedia.io/products/rtmedia-podcast-feed/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
169 |
-
'desc'
|
170 |
-
'price'
|
171 |
-
'demo_link'
|
172 |
-
'buy_now'
|
173 |
-
'category'
|
174 |
-
'purchased'
|
175 |
),
|
176 |
array(
|
177 |
-
'title'
|
178 |
-
'img_src'
|
179 |
'product_link' => 'https://rtmedia.io/products/rtmedia-playlists/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
180 |
-
'desc'
|
181 |
-
'price'
|
182 |
-
'demo_link'
|
183 |
-
'buy_now'
|
184 |
-
'category'
|
185 |
-
'purchased'
|
186 |
),
|
187 |
array(
|
188 |
-
'title'
|
189 |
-
'img_src'
|
190 |
'product_link' => 'https://rtmedia.io/products/rtmedia-favorites/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
191 |
-
'desc'
|
192 |
-
'price'
|
193 |
-
'demo_link'
|
194 |
-
'buy_now'
|
195 |
-
'category'
|
196 |
-
'purchased'
|
197 |
),
|
198 |
array(
|
199 |
-
'title'
|
200 |
-
'img_src'
|
201 |
'product_link' => 'https://rtmedia.io/products/rtmedia-restrictions/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
202 |
-
'desc'
|
203 |
-
'price'
|
204 |
-
'demo_link'
|
205 |
-
'buy_now'
|
206 |
-
'category'
|
207 |
-
'purchased'
|
208 |
),
|
209 |
array(
|
210 |
-
'title'
|
211 |
-
'img_src'
|
212 |
'product_link' => 'https://rtmedia.io/products/rtmedia-bbpress-attachments/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
213 |
-
'desc'
|
214 |
-
'price'
|
215 |
-
'demo_link'
|
216 |
-
'buy_now'
|
217 |
-
'category'
|
218 |
-
'purchased'
|
219 |
),
|
220 |
array(
|
221 |
-
'title'
|
222 |
-
'img_src'
|
223 |
'product_link' => 'https://rtmedia.io/products/rtmedia-wordpress-sitewide-gallery/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
224 |
-
'desc'
|
225 |
-
'price'
|
226 |
-
'demo_link'
|
227 |
-
'buy_now'
|
228 |
-
'category'
|
229 |
-
'purchased'
|
230 |
),
|
231 |
array(
|
232 |
-
'title'
|
233 |
-
'img_src'
|
234 |
'product_link' => 'https://rtmedia.io/products/rtmedia-wordpress-comment-attachments/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
235 |
-
'desc'
|
236 |
-
'price'
|
237 |
-
'demo_link'
|
238 |
-
'buy_now'
|
239 |
-
'category'
|
240 |
-
'purchased'
|
241 |
),
|
242 |
array(
|
243 |
-
'title'
|
244 |
-
'img_src'
|
245 |
'product_link' => 'https://rtmedia.io/products/rtmedia-social-sharing/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
246 |
-
'desc'
|
247 |
-
'price'
|
248 |
-
'demo_link'
|
249 |
-
'buy_now'
|
250 |
-
'category'
|
251 |
-
'purchased'
|
252 |
),
|
253 |
array(
|
254 |
-
'title'
|
255 |
-
'img_src'
|
256 |
'product_link' => 'https://rtmedia.io/products/rtmedia-sidebar-widgets/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
257 |
-
'desc'
|
258 |
-
'price'
|
259 |
-
'demo_link'
|
260 |
-
'buy_now'
|
261 |
-
'category'
|
262 |
-
'purchased'
|
263 |
),
|
264 |
array(
|
265 |
-
'title'
|
266 |
-
'img_src'
|
267 |
'product_link' => 'https://rtmedia.io/products/rtmedia-star-ratings/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
268 |
-
'desc'
|
269 |
-
'price'
|
270 |
-
'demo_link'
|
271 |
-
'buy_now'
|
272 |
-
'category'
|
273 |
-
'purchased'
|
274 |
),
|
275 |
array(
|
276 |
-
'title'
|
277 |
-
'img_src'
|
278 |
'product_link' => 'https://rtmedia.io/products/rtmedia-edit-mp3-info/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
279 |
-
'desc'
|
280 |
-
'price'
|
281 |
-
'demo_link'
|
282 |
-
'buy_now'
|
283 |
-
'category'
|
284 |
-
'purchased'
|
285 |
),
|
286 |
array(
|
287 |
-
'title'
|
288 |
-
'img_src'
|
289 |
'product_link' => 'https://rtmedia.io/products/rtmedia-sorting/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
290 |
-
'desc'
|
291 |
-
'price'
|
292 |
-
'demo_link'
|
293 |
-
'buy_now'
|
294 |
-
'category'
|
295 |
-
'purchased'
|
296 |
),
|
297 |
array(
|
298 |
-
'title'
|
299 |
-
'img_src'
|
300 |
'product_link' => 'https://rtmedia.io/products/rtmedia-bulk-edit/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
301 |
-
'desc'
|
302 |
-
'price'
|
303 |
-
'demo_link'
|
304 |
-
'buy_now'
|
305 |
-
'category'
|
306 |
-
'purchased'
|
307 |
),
|
308 |
array(
|
309 |
-
'title'
|
310 |
-
'img_src'
|
311 |
'product_link' => 'https://rtmedia.io/products/rtmedia-buddypress-profile-picture/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
312 |
-
'desc'
|
313 |
-
'price'
|
314 |
-
'demo_link'
|
315 |
-
'buy_now'
|
316 |
-
'category'
|
317 |
-
'purchased'
|
318 |
),
|
319 |
array(
|
320 |
-
'title'
|
321 |
-
'img_src'
|
322 |
'product_link' => 'https://rtmedia.io/products/rtmedia-album-cover-art/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
323 |
-
'desc'
|
324 |
-
'price'
|
325 |
-
'demo_link'
|
326 |
-
'buy_now'
|
327 |
-
'category'
|
328 |
-
'purchased'
|
329 |
),
|
330 |
array(
|
331 |
-
'title'
|
332 |
-
'img_src'
|
333 |
'product_link' => 'https://rtmedia.io/products/rtmedia-direct-download-link/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
334 |
-
'desc'
|
335 |
-
'price'
|
336 |
-
'demo_link'
|
337 |
-
'buy_now'
|
338 |
-
'category'
|
339 |
-
'purchased'
|
340 |
),
|
341 |
array(
|
342 |
-
'title'
|
343 |
-
'img_src'
|
344 |
'product_link' => 'https://rtmedia.io/products/rtmedia-upload-by-url/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
345 |
-
'desc'
|
346 |
-
'price'
|
347 |
-
'demo_link'
|
348 |
-
'buy_now'
|
349 |
-
'category'
|
350 |
-
'purchased'
|
351 |
),
|
352 |
array(
|
353 |
-
'title'
|
354 |
-
'img_src'
|
355 |
'product_link' => 'https://rtmedia.io/products/rtmedia-likes/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
356 |
-
'desc'
|
357 |
-
'price'
|
358 |
-
'demo_link'
|
359 |
-
'buy_now'
|
360 |
-
'category'
|
361 |
-
'purchased'
|
362 |
),
|
363 |
array(
|
364 |
-
'title'
|
365 |
-
'img_src'
|
366 |
'product_link' => 'https://rtmedia.io/products/rtmedia-activity-url-preview/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
367 |
-
'desc'
|
368 |
-
'price'
|
369 |
-
'demo_link'
|
370 |
-
'buy_now'
|
371 |
-
'category'
|
372 |
-
'purchased'
|
373 |
),
|
374 |
array(
|
375 |
-
'title'
|
376 |
-
'img_src'
|
377 |
'product_link' => 'https://rtmedia.io/products/rtmedia-view-counter/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
378 |
-
'desc'
|
379 |
-
'price'
|
380 |
-
'demo_link'
|
381 |
-
'buy_now'
|
382 |
-
'category'
|
383 |
-
'purchased'
|
384 |
),
|
385 |
array(
|
386 |
-
'title'
|
387 |
-
'img_src'
|
388 |
'product_link' => 'https://rtmedia.io/products/rtmedia-shortcode-generator/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
389 |
-
'desc'
|
390 |
-
'price'
|
391 |
-
'demo_link'
|
392 |
-
'buy_now'
|
393 |
-
'category'
|
394 |
-
'purchased'
|
395 |
),
|
396 |
array(
|
397 |
-
'title'
|
398 |
-
'img_src'
|
399 |
'product_link' => 'https://rtmedia.io/products/rtmedia-album-privacy/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
400 |
-
'desc'
|
401 |
-
'price'
|
402 |
-
'demo_link'
|
403 |
-
'buy_now'
|
404 |
-
'category'
|
405 |
-
'purchased'
|
406 |
),
|
407 |
array(
|
408 |
-
'title'
|
409 |
-
'img_src'
|
410 |
'product_link' => 'https://rtmedia.io/products/rtmedia-buddypress-group-media-control/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
411 |
-
'desc'
|
412 |
-
'price'
|
413 |
-
'demo_link'
|
414 |
-
'buy_now'
|
415 |
-
'category'
|
416 |
-
'purchased'
|
417 |
),
|
418 |
array(
|
419 |
-
'title'
|
420 |
-
'img_src'
|
421 |
'product_link' => 'https://rtmedia.io/products/rtmedia-set-custom-thumbnail-for-audiovideo/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
422 |
-
'desc'
|
423 |
-
'price'
|
424 |
-
'demo_link'
|
425 |
-
'buy_now'
|
426 |
-
'category'
|
427 |
-
'purchased'
|
428 |
),
|
429 |
array(
|
430 |
-
'title'
|
431 |
-
'img_src'
|
432 |
'product_link' => 'https://rtmedia.io/products/rtmedia-mycred/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
433 |
-
'desc'
|
434 |
-
'price'
|
435 |
-
'demo_link'
|
436 |
-
'buy_now'
|
437 |
-
'category'
|
438 |
-
'purchased'
|
439 |
),
|
440 |
array(
|
441 |
-
'title'
|
442 |
-
'img_src'
|
443 |
'product_link' => 'https://rtmedia.io/products/rtmedia-upload-terms/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
444 |
-
'desc'
|
445 |
-
'price'
|
446 |
-
'demo_link'
|
447 |
-
'buy_now'
|
448 |
-
'category'
|
449 |
-
'purchased'
|
450 |
),
|
451 |
array(
|
452 |
-
'title'
|
453 |
-
'img_src'
|
454 |
'product_link' => 'https://rtmedia.io/products/rtmedia-cubepoints/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
455 |
-
'desc'
|
456 |
-
'price'
|
457 |
-
'demo_link'
|
458 |
-
'buy_now'
|
459 |
-
'category'
|
460 |
-
'purchased'
|
461 |
),
|
462 |
array(
|
463 |
-
'title'
|
464 |
-
'img_src'
|
465 |
'product_link' => 'https://rtmedia.io/products/rtmedia-social-sync/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
466 |
-
'desc'
|
467 |
-
'price'
|
468 |
-
'demo_link'
|
469 |
-
'buy_now'
|
470 |
-
'category'
|
471 |
-
'purchased'
|
472 |
),
|
473 |
array(
|
474 |
-
'title'
|
475 |
-
'img_src'
|
476 |
'product_link' => 'https://rtmedia.io/products/rtmedia-photo-watermark/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
477 |
-
'desc'
|
478 |
-
'price'
|
479 |
-
'demo_link'
|
480 |
-
'buy_now'
|
481 |
-
'category'
|
482 |
-
'purchased'
|
483 |
),
|
484 |
array(
|
485 |
-
'title'
|
486 |
-
'img_src'
|
487 |
'product_link' => 'https://rtmedia.io/products/rtmedia-photo-tagging/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
488 |
-
'desc'
|
489 |
-
'price'
|
490 |
-
'demo_link'
|
491 |
-
'buy_now'
|
492 |
-
'category'
|
493 |
-
'purchased'
|
494 |
),
|
495 |
array(
|
496 |
-
'title'
|
497 |
-
'img_src'
|
498 |
'product_link' => 'https://rtmedia.io/products/rtmedia-photo-filters/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
499 |
-
'desc'
|
500 |
-
'price'
|
501 |
-
'demo_link'
|
502 |
-
'buy_now'
|
503 |
-
'category'
|
504 |
-
'purchased'
|
505 |
),
|
506 |
array(
|
507 |
-
'title'
|
508 |
-
'img_src'
|
509 |
'product_link' => 'https://rtmedia.io/products/rtmedia-kaltura-add-on/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
510 |
-
'desc'
|
511 |
-
'price'
|
512 |
-
'demo_link'
|
513 |
-
'buy_now'
|
514 |
-
'category'
|
515 |
-
'purchased'
|
516 |
-
),
|
517 |
-
array(
|
518 |
-
'title'
|
519 |
-
'img_src'
|
520 |
-
'product_link' => 'https://rtmedia.io/products/
|
521 |
-
'desc'
|
522 |
-
'price'
|
523 |
-
'demo_link'
|
524 |
-
'buy_now'
|
525 |
-
'category'
|
526 |
-
'purchased'
|
527 |
-
),
|
528 |
-
array(
|
529 |
-
'title'
|
530 |
-
'img_src'
|
531 |
'product_link' => 'https://rtmedia.io/products/rtmedia-membership/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
532 |
-
'desc'
|
533 |
-
'price'
|
534 |
-
'buy_now'
|
535 |
-
'category'
|
536 |
-
'purchased'
|
537 |
),
|
538 |
);
|
539 |
-
$addons
|
540 |
|
541 |
foreach ( $addons as $key => $value ) {
|
542 |
$this->addon( $value );
|
543 |
}
|
544 |
?>
|
545 |
-
|
546 |
<?php
|
547 |
}
|
548 |
|
@@ -569,13 +572,13 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
569 |
* @return void
|
570 |
*/
|
571 |
public function themes_content( $args = '' ) {
|
572 |
-
echo '<h3>' .
|
573 |
}
|
574 |
|
575 |
/**
|
576 |
* Define addon.
|
577 |
*
|
578 |
-
* @global type
|
579 |
*
|
580 |
* @param array $args
|
581 |
*
|
@@ -585,26 +588,26 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
585 |
global $rtmedia;
|
586 |
|
587 |
$defaults = array(
|
588 |
-
'title'
|
589 |
-
'img_src'
|
590 |
'product_link' => '',
|
591 |
-
'desc'
|
592 |
-
'price'
|
593 |
-
'demo_link'
|
594 |
-
'buy_now'
|
595 |
-
'coming_soon'
|
596 |
-
'category'
|
597 |
-
'purchased'
|
598 |
);
|
599 |
-
$args
|
600 |
extract( $args );
|
601 |
|
602 |
$coming_soon ? ' coming-soon' : '';
|
603 |
|
604 |
if ( $purchased ) {
|
605 |
-
$purchase_link = '<span class="rtm-addon-purchased button-primary disabled alignright product_type_simple">' .
|
606 |
} else {
|
607 |
-
$purchase_link = '<a class="button-primary alignright product_type_simple" href="' . $buy_now . '" target="_blank">' .
|
608 |
}
|
609 |
|
610 |
$coming_soon_div = ( $coming_soon ) ? $this->coming_soon_div() : '';
|
@@ -612,35 +615,37 @@ if ( ! class_exists( 'RTMediaAddon' ) ) {
|
|
612 |
<div class="plugin-card clearfix rtm-plugin-card">
|
613 |
|
614 |
<div class="plugin-card-top">
|
615 |
-
<a class="rtm-logo" href="<?php echo $product_link
|
616 |
-
|
|
|
|
|
617 |
</a>
|
618 |
|
619 |
<div class="name column-name">
|
620 |
-
<h4><a href="<?php echo $product_link; ?>" title="<?php echo $title; ?>"
|
|
|
621 |
</div>
|
622 |
|
623 |
<div class="desc column-description">
|
624 |
-
<?php echo $desc; ?>
|
625 |
</div>
|
626 |
</div>
|
627 |
|
628 |
<div class="plugin-card-bottom">
|
629 |
<span class="price alignleft">
|
630 |
-
<span class="amount"><?php echo $price; ?></span>
|
631 |
</span>
|
632 |
<?php
|
633 |
-
echo $purchase_link;
|
634 |
|
635 |
-
if ( $demo_link
|
636 |
-
echo '<a class="alignright rtm-live-demo button" href="' . $demo_link . '" title="' . $title . '" target="_blank">' .
|
637 |
}
|
638 |
?>
|
639 |
</div>
|
640 |
</div>
|
641 |
<?php
|
642 |
}
|
643 |
-
|
644 |
}
|
645 |
|
646 |
}
|
23 |
*
|
24 |
* @param void
|
25 |
*
|
26 |
+
* @return string
|
27 |
*/
|
28 |
public function coming_soon_div() {
|
29 |
+
return '<div class="coming-soon coming-soon-l"></div> <a class="coming-soon coming-soon-r" href="' . esc_url( $this->enquiry_link ) . '" target="_blank"></a>';
|
30 |
}
|
31 |
|
32 |
/**
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
+
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
|
51 |
|
52 |
+
if ( $section['callback'] ) {
|
53 |
+
call_user_func( $section['callback'], $section );
|
54 |
}
|
55 |
|
56 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
|
57 |
continue;
|
58 |
}
|
59 |
|
60 |
echo '<table class="form-table">';
|
61 |
+
do_settings_fields( $page, $section['id'] );
|
62 |
echo '</table>';
|
63 |
}
|
64 |
}
|
75 |
public function get_addons() {
|
76 |
$tabs = array();
|
77 |
global $rtmedia_admin;
|
78 |
+
|
79 |
+
if ( ! is_rtmedia_vip_plugin() ) {
|
80 |
+
$tabs[] = array(
|
81 |
+
'title' => esc_html__( 'Plugins', 'buddypress-media' ),
|
82 |
+
'name' => esc_html__( 'Plugins', 'buddypress-media' ),
|
83 |
+
'href' => '#rtm-plugins',
|
84 |
+
'icon' => 'dashicons-admin-plugins',
|
85 |
+
'callback' => array( $this, 'plugins_content' ),
|
86 |
+
);
|
87 |
+
}
|
88 |
|
89 |
$tabs[] = array(
|
90 |
+
'title' => esc_html__( 'Audio/Video Encoding', 'buddypress-media' ),
|
91 |
+
'name' => esc_html__( 'Audio/Video Encoding', 'buddypress-media' ),
|
92 |
+
'href' => '#rtm-services',
|
93 |
+
'icon' => 'dashicons-playlist-video',
|
94 |
+
'callback' => array( $rtmedia_admin->rtmedia_encoding, 'encoding_service_intro' ),
|
95 |
);
|
96 |
|
97 |
RTMediaAdmin::render_admin_ui( self::$page, $tabs );
|
107 |
* @return void
|
108 |
*/
|
109 |
public function plugins_content( $args = '' ) {
|
|
|
110 |
$rtcamp_upload_url = 'https://cdn.rtmedia.io/wp-content/uploads/';
|
111 |
+
$rtmedia_demo_url = 'http://demo.rtmedia.io/';
|
112 |
+
$addons = array(
|
113 |
array(
|
114 |
+
'title' => esc_html__( 'SEO', 'buddypress-media' ),
|
115 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/seo-xml.png',
|
116 |
'product_link' => 'https://rtmedia.io/products/rtmedia-seo/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
117 |
+
'desc' => '<p>' . esc_html__( 'Generate an XML sitemap for all the public media files uploaded via rtMedia plugin. These sitemaps can be useful to index search engine to improve website SEO.', 'buddypress-media' ) . '</p>',
|
118 |
+
'price' => '$49',
|
119 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
120 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-seo/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
121 |
+
'category' => 'general',
|
122 |
+
'purchased' => ( defined( 'RTMEDIA_SEO_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-seo/index.php' ) ) ? true : false,
|
123 |
+
),
|
124 |
+
array(
|
125 |
+
'title' => esc_html__( 'Moderation', 'buddypress-media' ),
|
126 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-moderation.jpg',
|
127 |
'product_link' => 'https://rtmedia.io/products/rtmedia-moderation/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
128 |
+
'desc' => '<p>' . esc_html__( 'Report media if they find offensive. Set number of reports to automatically take down media from site.', 'buddypress-media' ) . '</p>',
|
129 |
+
'price' => '$99',
|
130 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
131 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-moderation/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
132 |
+
'category' => 'general',
|
133 |
+
'purchased' => ( defined( 'RTMEDIA_MODERATION_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-moderation/index.php' ) ) ? true : false,
|
134 |
),
|
135 |
array(
|
136 |
+
'title' => esc_html__( 'Custom Attributes', 'buddypress-media' ),
|
137 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-custom-attributes.jpg',
|
138 |
'product_link' => 'https://rtmedia.io/products/rtmedia-custom-attributes/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
139 |
+
'desc' => '<p>' . esc_html__( 'Categories media based on attributes. Site owner need to create attributes. When user upload a media, can select in which attribute that media can add.', 'buddypress-media' ) . '</p>',
|
140 |
+
'price' => '$99',
|
141 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
142 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-custom-attributes/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
143 |
+
'category' => 'general',
|
144 |
+
'purchased' => ( defined( 'RTMEDIA_ATTRIBUTES_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-custom-attributes/index.php' ) ) ? true : false,
|
145 |
),
|
146 |
array(
|
147 |
+
'title' => esc_html__( 'Docs and Other files', 'buddypress-media' ),
|
148 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-docs-files.jpg',
|
149 |
'product_link' => 'https://rtmedia.io/products/rtmedia-docs-files/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
150 |
+
'desc' => '<p>' . esc_html__( 'Allow users to upload documents and other file type using rtMedia upload box. This addon support all the file extensions which WordPress allows.', 'buddypress-media' ) . '</p>',
|
151 |
+
'price' => '$99',
|
152 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
153 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-docs-files/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
154 |
+
'category' => 'general',
|
155 |
+
'purchased' => ( defined( 'RTMEDIA_OTHER_FILES_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-docs-files/index.php' ) ) ? true : false,
|
156 |
),
|
157 |
array(
|
158 |
+
'title' => esc_html__( 'Default Albums', 'buddypress-media' ),
|
159 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-default-albums.jpg',
|
160 |
'product_link' => 'https://rtmedia.io/products/rtmedia-default-albums/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
161 |
+
'desc' => '<p>' . esc_html__( 'This plugin allows the creation of multiple default albums for rtMedia uploads. One of these albums can be set as the default global album.', 'buddypress-media' ) . '</p>',
|
162 |
+
'price' => '$49',
|
163 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
164 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-default-albums/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
165 |
+
'category' => 'general',
|
166 |
+
'purchased' => ( defined( 'RTMEDIA_DEFAULT_ALBUMS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-default-albums/index.php' ) ) ? true : false,
|
167 |
),
|
168 |
array(
|
169 |
+
'title' => esc_html__( 'Podcast (RSS and Atom feeds)', 'buddypress-media' ),
|
170 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-podcast-feed.jpg',
|
171 |
'product_link' => 'https://rtmedia.io/products/rtmedia-podcast-feed/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
172 |
+
'desc' => '<p>' . esc_html__( 'Read rtMedia uploads from iTunes as well as any RSS feed-reader/podcasting software.', 'buddypress-media' ) . '</p>',
|
173 |
+
'price' => '$49',
|
174 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
175 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-podcast-feed/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
176 |
+
'category' => 'general',
|
177 |
+
'purchased' => ( defined( 'RTMEDIA_RSS_ATOM_FEED_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-podcast-feed/index.php' ) ) ? true : false,
|
178 |
),
|
179 |
array(
|
180 |
+
'title' => esc_html__( 'Playlists', 'buddypress-media' ),
|
181 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-playlists.jpg',
|
182 |
'product_link' => 'https://rtmedia.io/products/rtmedia-playlists/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
183 |
+
'desc' => '<p>' . esc_html__( 'Audio can be grouped into playlists. Once the user upload any audio file, can create a playlist or use existing one to manage audio files.', 'buddypress-media' ) . '</p>',
|
184 |
+
'price' => '$49',
|
185 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
186 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-playlists/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
187 |
+
'category' => 'general',
|
188 |
+
'purchased' => ( defined( 'RTMEDIA_PLAYLIST_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-playlists/index.php' ) ) ? true : false,
|
189 |
),
|
190 |
array(
|
191 |
+
'title' => esc_html__( 'Favorites', 'buddypress-media' ),
|
192 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-favorites.jpg',
|
193 |
'product_link' => 'https://rtmedia.io/products/rtmedia-favorites/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
194 |
+
'desc' => '<p>' . esc_html__( 'Users can create their list of favorite media in which they can add media previously uploaded by any user.', 'buddypress-media' ) . '</p>',
|
195 |
+
'price' => '$49',
|
196 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
197 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-favorites/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
198 |
+
'category' => 'general',
|
199 |
+
'purchased' => ( defined( 'RTMEDIA_FAVORITES_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-favorites/index.php' ) ) ? true : false,
|
200 |
),
|
201 |
array(
|
202 |
+
'title' => esc_html__( 'Restrictions', 'buddypress-media' ),
|
203 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-restrictions.jpg',
|
204 |
'product_link' => 'https://rtmedia.io/products/rtmedia-restrictions/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
205 |
+
'desc' => '<p>' . esc_html__( 'Site admin can set an upload limit on the basis of time span, file size (MB) and number of files user can upload.', 'buddypress-media' ) . '</p>',
|
206 |
+
'price' => '$99',
|
207 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
208 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-restrictions/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
209 |
+
'category' => 'general',
|
210 |
+
'purchased' => ( defined( 'RTMEDIA_RSS_ATOM_FEED_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-podcast-feed/index.php' ) ) ? true : false,
|
211 |
),
|
212 |
array(
|
213 |
+
'title' => esc_html__( 'bbPress Attachments', 'buddypress-media' ),
|
214 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-bbpress-attachments.jpg',
|
215 |
'product_link' => 'https://rtmedia.io/products/rtmedia-bbpress-attachments/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
216 |
+
'desc' => '<p>' . esc_html__( 'Attach media files to bbPress forum topics and replies.', 'buddypress-media' ) . '</p>',
|
217 |
+
'price' => '$49',
|
218 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
219 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-bbpress-attachments/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
220 |
+
'category' => 'general',
|
221 |
+
'purchased' => ( defined( 'RTMEDIA_BBPRESS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-bbpress-attachments/index.php' ) ) ? true : false,
|
222 |
),
|
223 |
array(
|
224 |
+
'title' => esc_html__( 'WordPress Sitewide Gallery', 'buddypress-media' ),
|
225 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-wordpress-sitewide-gallery.jpg',
|
226 |
'product_link' => 'https://rtmedia.io/products/rtmedia-wordpress-sitewide-gallery/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
227 |
+
'desc' => '<p>' . esc_html__( 'Site admin can create and upload media into WordPress album. Create album without being dependent on BuddyPress.', 'buddypress-media' ) . '</p>',
|
228 |
+
'price' => '$99',
|
229 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
230 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-wordpress-sitewide-gallery/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
231 |
+
'category' => 'general',
|
232 |
+
'purchased' => ( defined( 'RTMEDIA_WORDPRESS_SITEWIDE_GALLERY_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-wordpress-sitewide-gallery/index.php' ) ) ? true : false,
|
233 |
),
|
234 |
array(
|
235 |
+
'title' => esc_html__( 'WordPress Comment Attachments', 'buddypress-media' ),
|
236 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-wordpress-comment-attachments.jpg',
|
237 |
'product_link' => 'https://rtmedia.io/products/rtmedia-wordpress-comment-attachments/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
238 |
+
'desc' => '<p>' . esc_html__( 'Allow users to upload a media file in WordPress comment attachment box. It will display a thumbnail of attached file.', 'buddypress-media' ) . '</p>',
|
239 |
+
'price' => '$49',
|
240 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
241 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-wordpress-comment-attachments/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
242 |
+
'category' => 'general',
|
243 |
+
'purchased' => ( defined( 'RTMEDIA_WORDPRESS_COMMENT_ATTACHMENT_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-wordpress-comment-attachments/index.php' ) ) ? true : false,
|
244 |
),
|
245 |
array(
|
246 |
+
'title' => esc_html__( 'Social Sharing', 'buddypress-media' ),
|
247 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-social-sharing.jpg',
|
248 |
'product_link' => 'https://rtmedia.io/products/rtmedia-social-sharing/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
249 |
+
'desc' => '<p>' . esc_html__( 'Share uploaded media on social network sites like Facebook, twitter, linkedin, Google +. This addon integrate with rtSocial plugin.', 'buddypress-media' ) . '</p>',
|
250 |
+
'price' => '$49',
|
251 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
252 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-social-sharing/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
253 |
+
'category' => 'general',
|
254 |
+
'purchased' => ( defined( 'RTMEDIA_SOCIAL_SHARING_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-social-sharing/index.php' ) ) ? true : false,
|
255 |
),
|
256 |
array(
|
257 |
+
'title' => esc_html__( 'Sidebar Widgets', 'buddypress-media' ),
|
258 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-sidebar-widgets.jpg',
|
259 |
'product_link' => 'https://rtmedia.io/products/rtmedia-sidebar-widgets/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
260 |
+
'desc' => '<p>' . esc_html__( 'This addon provide widgets to upload media and display gallery for rtMedia plugin.', 'buddypress-media' ) . '</p>',
|
261 |
+
'price' => '$49',
|
262 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
263 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-sidebar-widgets/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
264 |
+
'category' => 'general',
|
265 |
+
'purchased' => ( defined( 'RTMEDIA_WIDGETS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-sidebar-widgets/index.php' ) ) ? true : false,
|
266 |
),
|
267 |
array(
|
268 |
+
'title' => esc_html__( '5 Star Ratings', 'buddypress-media' ),
|
269 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-ratings.jpg',
|
270 |
'product_link' => 'https://rtmedia.io/products/rtmedia-star-ratings/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
271 |
+
'desc' => '<p>' . esc_html__( 'Display 5 star rating for all the uploaded media. User can rate the media files from 1 to 5 star.', 'buddypress-media' ) . '</p>',
|
272 |
+
'price' => '$49',
|
273 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
274 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-star-ratings/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
275 |
+
'category' => 'general',
|
276 |
+
'purchased' => ( defined( 'RTMEDIA_RATINGS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-ratings/index.php' ) ) ? true : false,
|
277 |
),
|
278 |
array(
|
279 |
+
'title' => esc_html__( 'Edit Mp3 Info (ID3 Tags)', 'buddypress-media' ),
|
280 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-edit-mp3-info.jpg',
|
281 |
'product_link' => 'https://rtmedia.io/products/rtmedia-edit-mp3-info/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
282 |
+
'desc' => '<p>' . esc_html__( 'Allow user to edit MP3 FIle Audio tags (ID 3 tags).', 'buddypress-media' ) . '</p>',
|
283 |
+
'price' => '$49',
|
284 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
285 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-edit-mp3-info/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
286 |
+
'category' => 'general',
|
287 |
+
'purchased' => ( defined( 'RTMEDIA_AUDIO_TAGS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-edit-mp3-info/index.php' ) ) ? true : false,
|
288 |
),
|
289 |
array(
|
290 |
+
'title' => esc_html__( 'Media Sorting', 'buddypress-media' ),
|
291 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-sorting.jpg',
|
292 |
'product_link' => 'https://rtmedia.io/products/rtmedia-sorting/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
293 |
+
'desc' => '<p>' . esc_html__( 'Sort uploaded media based on file size, ascending/descending title, upload date of media.', 'buddypress-media' ) . '</p>',
|
294 |
+
'price' => '$49',
|
295 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
296 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-sorting/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
297 |
+
'category' => 'general',
|
298 |
+
'purchased' => ( defined( 'RTMEDIA_SORTING_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-sorting/index.php' ) ) ? true : false,
|
299 |
),
|
300 |
array(
|
301 |
+
'title' => esc_html__( 'Bulk Edit', 'buddypress-media' ),
|
302 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-bulk-edit.jpg',
|
303 |
'product_link' => 'https://rtmedia.io/products/rtmedia-bulk-edit/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
304 |
+
'desc' => '<p>' . esc_html__( 'Bulk edit option will allow user to quickly select media files and do required actions like move files from one album to another, change attributes, change privacy, delete files.', 'buddypress-media' ) . '</p>',
|
305 |
+
'price' => '$99',
|
306 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
307 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-bulk-edit/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
308 |
+
'category' => 'general',
|
309 |
+
'purchased' => ( defined( 'RTMEDIA_BULK_EDIT_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-bulk-edit/index.php' ) ) ? true : false,
|
310 |
),
|
311 |
array(
|
312 |
+
'title' => esc_html__( 'BuddyPress Profile Picture', 'buddypress-media' ),
|
313 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-buddypress-profile-picture.jpg',
|
314 |
'product_link' => 'https://rtmedia.io/products/rtmedia-buddypress-profile-picture/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
315 |
+
'desc' => '<p>' . esc_html__( 'User can easily set his/her profile picture from media uploaded via rtMedia.', 'buddypress-media' ) . '</p>',
|
316 |
+
'price' => '$49',
|
317 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
318 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-buddypress-profile-picture/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
319 |
+
'category' => 'general',
|
320 |
+
'purchased' => ( defined( 'RTMEDIA_BUDDYPRESS_PROFILE_PICTURE_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-buddypress-profile-picture/index.php' ) ) ? true : false,
|
321 |
),
|
322 |
array(
|
323 |
+
'title' => esc_html__( 'Album Cover Art', 'buddypress-media' ),
|
324 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-album-cover-art.jpg',
|
325 |
'product_link' => 'https://rtmedia.io/products/rtmedia-album-cover-art/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
326 |
+
'desc' => '<p>' . esc_html__( 'User can easily set any of the image of the album as album cover photo', 'buddypress-media' ) . '</p>',
|
327 |
+
'price' => '$49',
|
328 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
329 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-album-cover-art/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
330 |
+
'category' => 'general',
|
331 |
+
'purchased' => ( defined( 'RTMEDIA_ALBUM_COVER_ART_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-album-cover-art/index.php' ) ) ? true : false,
|
332 |
),
|
333 |
array(
|
334 |
+
'title' => esc_html__( 'Direct Download Link', 'buddypress-media' ),
|
335 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-direct-download-link.jpg',
|
336 |
'product_link' => 'https://rtmedia.io/products/rtmedia-direct-download-link/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
337 |
+
'desc' => '<p>' . esc_html__( 'User can download media from website. Site owner can restrict which media type can be allowed to download.', 'buddypress-media' ) . '</p>',
|
338 |
+
'price' => '$49',
|
339 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
340 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-direct-download-link/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
341 |
+
'category' => 'general',
|
342 |
+
'purchased' => ( defined( 'RTMEDIA_DOWNLOADS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-direct-download-link/index.php' ) ) ? true : false,
|
343 |
),
|
344 |
array(
|
345 |
+
'title' => esc_html__( 'Upload by URL', 'buddypress-media' ),
|
346 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-upload-by-url.jpg',
|
347 |
'product_link' => 'https://rtmedia.io/products/rtmedia-upload-by-url/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
348 |
+
'desc' => '<p>' . esc_html__( 'Users do not need to download media files from a URL and then upload it with rtMedia. Just provide the absolute URL for the media and it will upload on site.', 'buddypress-media' ) . '</p>',
|
349 |
+
'price' => '$49',
|
350 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
351 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-upload-by-url/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
352 |
+
'category' => 'general',
|
353 |
+
'purchased' => ( defined( 'RTMEDIA_DOWNLOADS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-upload-by-url/index.php' ) ) ? true : false,
|
354 |
),
|
355 |
array(
|
356 |
+
'title' => esc_html__( 'Media Likes', 'buddypress-media' ),
|
357 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-likes.jpg',
|
358 |
'product_link' => 'https://rtmedia.io/products/rtmedia-likes/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
359 |
+
'desc' => '<p>' . esc_html__( 'This add-on let you know who liked the media. User can also see which media they liked under their profile.', 'buddypress-media' ) . '</p>',
|
360 |
+
'price' => '$49',
|
361 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
362 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-likes/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
363 |
+
'category' => 'general',
|
364 |
+
'purchased' => ( defined( 'RTMEDIA_LIKES_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-likes/index.php' ) ) ? true : false,
|
365 |
),
|
366 |
array(
|
367 |
+
'title' => esc_html__( 'Activity URL Preview', 'buddypress-media' ),
|
368 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-activity-url-preview.jpg',
|
369 |
'product_link' => 'https://rtmedia.io/products/rtmedia-activity-url-preview/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
370 |
+
'desc' => '<p>' . esc_html__( 'This addon provides a preview of the URL that is shared in BuddyPress activity. Just enter the URL you want to share on your site and see a preview of it before it is shared.', 'buddypress-media' ) . '</p>',
|
371 |
+
'price' => '$49',
|
372 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
373 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-activity-url-preview/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
374 |
+
'category' => 'general',
|
375 |
+
'purchased' => ( defined( 'RTMEDIA_ACTIVITY_URL_PREVIEW_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-activity-url-preview/index.php' ) ) ? true : false,
|
376 |
),
|
377 |
array(
|
378 |
+
'title' => esc_html__( 'View Counter', 'buddypress-media' ),
|
379 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-view-counter.jpg',
|
380 |
'product_link' => 'https://rtmedia.io/products/rtmedia-view-counter/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
381 |
+
'desc' => '<p>' . esc_html__( 'Enable view count for all the uploaded media. Whenever user open that media file in lightbox or in single media view, that view count will be calculated and display next to media file.', 'buddypress-media' ) . '</p>',
|
382 |
+
'price' => '$49',
|
383 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
384 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-view-counter/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
385 |
+
'category' => 'general',
|
386 |
+
'purchased' => ( defined( 'RTMEDIA_VIEW_COUNT_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-view-counter/index.php' ) ) ? true : false,
|
387 |
),
|
388 |
array(
|
389 |
+
'title' => esc_html__( 'Shortcode Generator', 'buddypress-media' ),
|
390 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-shortcode-generator.jpg',
|
391 |
'product_link' => 'https://rtmedia.io/products/rtmedia-shortcode-generator/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
392 |
+
'desc' => '<p>' . esc_html__( 'This add-on will add shortcode generator button in WordPress post and page editor for all the rtMedia shortcodes.', 'buddypress-media' ) . '</p>',
|
393 |
+
'price' => '$49',
|
394 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
395 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-shortcode-generator/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
396 |
+
'category' => 'general',
|
397 |
+
'purchased' => ( defined( 'RTMEDIA_SHORTCODE_GENERATOR_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-shortcode-generator/index.php' ) ) ? true : false,
|
398 |
),
|
399 |
array(
|
400 |
+
'title' => esc_html__( 'Album Privacy', 'buddypress-media' ),
|
401 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-album-privacy.jpg',
|
402 |
'product_link' => 'https://rtmedia.io/products/rtmedia-album-privacy/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
403 |
+
'desc' => '<p>' . esc_html__( 'Set album privacy when user create an album or change album privacy when editing existing albums. The privacy levels are Public, Logged in user, Friends and Private.', 'buddypress-media' ) . '</p>',
|
404 |
+
'price' => '$49',
|
405 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
406 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-album-privacy/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
407 |
+
'category' => 'general',
|
408 |
+
'purchased' => ( defined( 'RTMEDIA_ALBUM_PRIVACY_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-album-privacy/index.php' ) ) ? true : false,
|
409 |
),
|
410 |
array(
|
411 |
+
'title' => esc_html__( 'BuddyPress Group Media Control', 'buddypress-media' ),
|
412 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-buddypress-group-media-control.jpg',
|
413 |
'product_link' => 'https://rtmedia.io/products/rtmedia-buddypress-group-media-control/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
414 |
+
'desc' => '<p>' . esc_html__( 'This add-on allows group owner to manage media upload feature group wise.', 'buddypress-media' ) . '</p>',
|
415 |
+
'price' => '$49',
|
416 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
417 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-buddypress-group-media-control/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
418 |
+
'category' => 'general',
|
419 |
+
'purchased' => ( defined( 'RTMEDIA_GROUP_MEDIA_CONTROL_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-buddypress-group-media-control/index.php' ) ) ? true : false,
|
420 |
),
|
421 |
array(
|
422 |
+
'title' => esc_html__( 'Set Custom Thumbnail for Audio/Video', 'buddypress-media' ),
|
423 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-set-custom-thumbnail.jpg',
|
424 |
'product_link' => 'https://rtmedia.io/products/rtmedia-set-custom-thumbnail-for-audiovideo/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
425 |
+
'desc' => '<p>' . esc_html__( 'Allow media owner to change the thumbnail of uploaded audio/video files. The File Upload box will be provided to change media thumbnail.', 'buddypress-media' ) . '</p>',
|
426 |
+
'price' => '$49',
|
427 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
428 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-set-custom-thumbnail-for-audiovideo/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
429 |
+
'category' => 'general',
|
430 |
+
'purchased' => ( defined( 'RTMEDIA_MEDIA_CUSTOM_THUMBNAIL_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-set-custom-thumbnail/index.php' ) ) ? true : false,
|
431 |
),
|
432 |
array(
|
433 |
+
'title' => esc_html__( 'myCRED', 'buddypress-media' ),
|
434 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-mycred.jpg',
|
435 |
'product_link' => 'https://rtmedia.io/products/rtmedia-mycred/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
436 |
+
'desc' => '<p>' . esc_html__( 'This plugin integrates rtMedia and myCRED plugin, users can be can award virtual points for various rtMedia activities, like media upload, likes, deleted etc.', 'buddypress-media' ) . '</p>',
|
437 |
+
'price' => '$49',
|
438 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
439 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-mycred/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
440 |
+
'category' => 'general',
|
441 |
+
'purchased' => ( defined( 'RTMEDIA_MYCRED_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-mycred/index.php' ) ) ? true : false,
|
442 |
),
|
443 |
array(
|
444 |
+
'title' => esc_html__( 'Upload Terms', 'buddypress-media' ),
|
445 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-upload-terms.jpg',
|
446 |
'product_link' => 'https://rtmedia.io/products/rtmedia-upload-terms/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
447 |
+
'desc' => '<p>' . esc_html__( 'User must have to check the terms and conditions checkbox before uploading the media.', 'buddypress-media' ) . '</p>',
|
448 |
+
'price' => '$49',
|
449 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
450 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-upload-terms/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
451 |
+
'category' => 'general',
|
452 |
+
'purchased' => ( defined( 'RTMEDIA_UPLOAD_TERMS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-upload-terms/index.php' ) ) ? true : false,
|
453 |
),
|
454 |
array(
|
455 |
+
'title' => esc_html__( 'CubePoints', 'buddypress-media' ),
|
456 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/06/rtmedia-cubepoints.jpg',
|
457 |
'product_link' => 'https://rtmedia.io/products/rtmedia-cubepoints/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
458 |
+
'desc' => '<p>' . esc_html__( 'If you are using CubePoints plugin on your website than rtMedia CubePoint add-on can be integrate with that plugin to setup point management system for rtMedia related activities.', 'buddypress-media' ) . '</p>',
|
459 |
+
'price' => '$49',
|
460 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
461 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-cubepoints/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
462 |
+
'category' => 'general',
|
463 |
+
'purchased' => ( defined( 'RTMEDIA_CUBEPOINTS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-cubepoints/index.php' ) ) ? true : false,
|
464 |
),
|
465 |
array(
|
466 |
+
'title' => esc_html__( 'Social Sync', 'buddypress-media' ),
|
467 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-Social-Sync.png',
|
468 |
'product_link' => 'https://rtmedia.io/products/rtmedia-social-sync/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
469 |
+
'desc' => '<p>' . esc_html__( 'rtMedia Social Sync allows you to import media from your Facebook account.', 'buddypress-media' ) . '</p>',
|
470 |
+
'price' => '$99',
|
471 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
472 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-social-sync/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
473 |
+
'category' => 'general',
|
474 |
+
'purchased' => ( defined( 'RTMEDIA_SOCIAL_SYNC_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-social-sync/index.php' ) ) ? true : false,
|
475 |
),
|
476 |
array(
|
477 |
+
'title' => esc_html__( 'Photo Watermark', 'buddypress-media' ),
|
478 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-Photo-Watermark.png',
|
479 |
'product_link' => 'https://rtmedia.io/products/rtmedia-photo-watermark/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
480 |
+
'desc' => '<p>' . esc_html__( 'rtMedia Photo Watermark let you add watermark on your images uploaded using rtMedia.', 'buddypress-media' ) . '</p>',
|
481 |
+
'price' => '$99',
|
482 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
483 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-photo-watermark/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
484 |
+
'category' => 'photo',
|
485 |
+
'purchased' => ( defined( 'RTMEDIA_WATERMARK_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-photo-watermak/index.php' ) ) ? true : false,
|
486 |
),
|
487 |
array(
|
488 |
+
'title' => esc_html__( 'Photo Tagging', 'buddypress-media' ),
|
489 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-Photo-Tagging.png',
|
490 |
'product_link' => 'https://rtmedia.io/products/rtmedia-photo-tagging/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
491 |
+
'desc' => '<p>' . esc_html__( 'rtMedia Photo Tagging enable users to tag their friends on photos uploaded using rtMedia.', 'buddypress-media' ) . '</p>',
|
492 |
+
'price' => '$99',
|
493 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
494 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-photo-tagging/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
495 |
+
'category' => 'photo',
|
496 |
+
'purchased' => ( defined( 'RTMEDIA_PHOTO_TAGGING_URL' ) || file_exists( WP_PLUGIN_DIR . '/bpm-photo-tag/index.php' ) ) ? true : false,
|
497 |
),
|
498 |
array(
|
499 |
+
'title' => esc_html__( 'Photo Filters', 'buddypress-media' ),
|
500 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-Photo-Filters.png',
|
501 |
'product_link' => 'https://rtmedia.io/products/rtmedia-photo-filters/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
502 |
+
'desc' => '<p>' . esc_html__( 'rtMedia Photo Filters adds Instagram like filters to images uploaded with rtMedia.', 'buddypress-media' ) . '</p>',
|
503 |
+
'price' => '$99',
|
504 |
+
'demo_link' => $rtmedia_demo_url . '?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
505 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-photo-filters/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
506 |
+
'category' => 'photo',
|
507 |
+
'purchased' => ( defined( 'RTMEDIA_INSTAGRAM_URL' ) || file_exists( WP_PLUGIN_DIR . '/bpm-instagram/index.php' ) || defined( 'RTMEDIA_PHOTO_FILTERS_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-photo-filters/index.php' ) ) ? true : false,
|
508 |
),
|
509 |
array(
|
510 |
+
'title' => esc_html__( 'Kaltura Add-on', 'buddypress-media' ),
|
511 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-Kaltura-Add-on.png',
|
512 |
'product_link' => 'https://rtmedia.io/products/rtmedia-kaltura-add-on/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
513 |
+
'desc' => '<p>' . esc_html__( 'Add support for more video formats using Kaltura video solution. It works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.', 'buddypress-media' ) . '</p>',
|
514 |
+
'price' => '$499',
|
515 |
+
'demo_link' => $rtmedia_demo_url . 'bpm-kaltura/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
516 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-kaltura/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
517 |
+
'category' => 'video',
|
518 |
+
'purchased' => ( defined( 'RTMEDIA_KALTURA_PATH' ) || file_exists( WP_PLUGIN_DIR . '/bpm-kaltura/index.php' ) ) ? true : false,
|
519 |
+
),
|
520 |
+
array(
|
521 |
+
'title' => esc_html__( 'FFMPEG Add-on', 'buddypress-media' ),
|
522 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-FFMPEG-Addon.png',
|
523 |
+
'product_link' => 'https://rtmedia.io/products/buddypress-media-ffmpeg-converter/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
524 |
+
'desc' => '<p>' . esc_html__( 'Add supports for more audio & video formats using open-source media-node. Media node comes with automated setup script for Ubuntu/Debian.', 'buddypress-media' ) . '</p>',
|
525 |
+
'price' => '$499',
|
526 |
+
'demo_link' => $rtmedia_demo_url . 'bpm-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
527 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-ffmpeg/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
528 |
+
'category' => 'video',
|
529 |
+
'purchased' => ( defined( 'RTMEDIA_FFMPEG_URL' ) || file_exists( WP_PLUGIN_DIR . '/bpm-ffmpeg/index.php' ) ) ? true : false,
|
530 |
+
),
|
531 |
+
array(
|
532 |
+
'title' => esc_html__( 'Membership Add-on', 'buddypress-media' ),
|
533 |
+
'img_src' => $rtcamp_upload_url . 'edd/2015/08/rtMedia-Membership.png',
|
534 |
'product_link' => 'https://rtmedia.io/products/rtmedia-membership/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
535 |
+
'desc' => '<p>' . esc_html__( 'rtMedia Membership add-on provides membership functionality in your site in terms of media upload.', 'buddypress-media' ),
|
536 |
+
'price' => '$99',
|
537 |
+
'buy_now' => 'https://rtmedia.io/products/rtmedia-membership/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
538 |
+
'category' => 'membership',
|
539 |
+
'purchased' => ( defined( 'RTMEDIA_MEMBERSHIP_URL' ) || file_exists( WP_PLUGIN_DIR . '/rtmedia-membership/index.php' ) ) ? true : false,
|
540 |
),
|
541 |
);
|
542 |
+
$addons = apply_filters( 'rtmedia_addons', $addons );
|
543 |
|
544 |
foreach ( $addons as $key => $value ) {
|
545 |
$this->addon( $value );
|
546 |
}
|
547 |
?>
|
548 |
+
<div class="clear"></div>
|
549 |
<?php
|
550 |
}
|
551 |
|
572 |
* @return void
|
573 |
*/
|
574 |
public function themes_content( $args = '' ) {
|
575 |
+
echo '<h3>' . esc_html__( 'Coming Soon !!', 'buddypress-media' ) . '</h3>';
|
576 |
}
|
577 |
|
578 |
/**
|
579 |
* Define addon.
|
580 |
*
|
581 |
+
* @global type $rtmedia
|
582 |
*
|
583 |
* @param array $args
|
584 |
*
|
588 |
global $rtmedia;
|
589 |
|
590 |
$defaults = array(
|
591 |
+
'title' => '',
|
592 |
+
'img_src' => '',
|
593 |
'product_link' => '',
|
594 |
+
'desc' => '',
|
595 |
+
'price' => '',
|
596 |
+
'demo_link' => '',
|
597 |
+
'buy_now' => '',
|
598 |
+
'coming_soon' => false,
|
599 |
+
'category' => 'photo',
|
600 |
+
'purchased' => false,
|
601 |
);
|
602 |
+
$args = wp_parse_args( $args, $defaults );
|
603 |
extract( $args );
|
604 |
|
605 |
$coming_soon ? ' coming-soon' : '';
|
606 |
|
607 |
if ( $purchased ) {
|
608 |
+
$purchase_link = '<span class="rtm-addon-purchased button-primary disabled alignright product_type_simple">' . esc_html__( 'Purchased', 'buddypress-media' ) . '</span>';
|
609 |
} else {
|
610 |
+
$purchase_link = '<a class="button-primary alignright product_type_simple" href="' . esc_url( $buy_now ) . '" target="_blank">' . esc_html__( 'Buy Now', 'buddypress-media' ) . '</a>';
|
611 |
}
|
612 |
|
613 |
$coming_soon_div = ( $coming_soon ) ? $this->coming_soon_div() : '';
|
615 |
<div class="plugin-card clearfix rtm-plugin-card">
|
616 |
|
617 |
<div class="plugin-card-top">
|
618 |
+
<a class="rtm-logo" href="<?php echo esc_url( $product_link ); ?>"
|
619 |
+
title="<?php echo esc_attr( $title ); ?>" target="_blank">
|
620 |
+
<img width="240" height="184" title="<?php echo esc_attr( $title ); ?>"
|
621 |
+
alt="<?php echo esc_attr( $title ); ?>" src="<?php echo esc_url( $img_src ); ?>"/>
|
622 |
</a>
|
623 |
|
624 |
<div class="name column-name">
|
625 |
+
<h4><a href="<?php echo esc_url( $product_link ); ?>" title="<?php echo esc_attr( $title ); ?>"
|
626 |
+
target="_blank"><?php echo esc_html( $title ); ?></a></h4>
|
627 |
</div>
|
628 |
|
629 |
<div class="desc column-description">
|
630 |
+
<?php echo wp_kses_post( $desc ); ?>
|
631 |
</div>
|
632 |
</div>
|
633 |
|
634 |
<div class="plugin-card-bottom">
|
635 |
<span class="price alignleft">
|
636 |
+
<span class="amount"><?php echo esc_html( $price ); ?></span>
|
637 |
</span>
|
638 |
<?php
|
639 |
+
echo $purchase_link; // @codingStandardsIgnoreLine
|
640 |
|
641 |
+
if ( '' !== $demo_link ) {
|
642 |
+
echo '<a class="alignright rtm-live-demo button" href="' . esc_url( $demo_link ) . '" title="' . esc_attr( $title ) . '" target="_blank">' . esc_html__( 'Live Demo', 'buddypress-media' ) . '</a>';
|
643 |
}
|
644 |
?>
|
645 |
</div>
|
646 |
</div>
|
647 |
<?php
|
648 |
}
|
|
|
649 |
}
|
650 |
|
651 |
}
|
app/helper/RTMediaAdminWidget.php
CHANGED
@@ -5,34 +5,33 @@
|
|
5 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
6 |
* @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
|
7 |
*/
|
8 |
-
if ( ! class_exists( 'RTMediaAdminWidget' ) ){
|
9 |
|
10 |
class RTMediaAdminWidget {
|
11 |
|
12 |
/**
|
13 |
* Constructs the RTMediaAdminWidget.
|
14 |
*
|
15 |
-
* @global type
|
16 |
-
*
|
17 |
-
* @param type
|
18 |
-
* @param type
|
|
|
19 |
*/
|
20 |
public function __construct( $id = null, $title = null, $content = null ) {
|
21 |
-
|
22 |
-
if ( $id ){
|
23 |
?>
|
24 |
-
|
25 |
-
<?php if ( $title ){ ?>
|
26 |
-
|
27 |
<?php }
|
28 |
?>
|
29 |
-
|
30 |
</div><?php
|
31 |
} else {
|
32 |
-
trigger_error(
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
}
|
37 |
|
38 |
-
}
|
5 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
6 |
* @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
|
7 |
*/
|
8 |
+
if ( ! class_exists( 'RTMediaAdminWidget' ) ) {
|
9 |
|
10 |
class RTMediaAdminWidget {
|
11 |
|
12 |
/**
|
13 |
* Constructs the RTMediaAdminWidget.
|
14 |
*
|
15 |
+
* @global type $rtmedia
|
16 |
+
*
|
17 |
+
* @param type $id
|
18 |
+
* @param type $title
|
19 |
+
* @param type $content
|
20 |
*/
|
21 |
public function __construct( $id = null, $title = null, $content = null ) {
|
22 |
+
if ( $id ) {
|
|
|
23 |
?>
|
24 |
+
<div class="postbox" id="<?php echo esc_attr( $id ); ?>">
|
25 |
+
<?php if ( $title ) { ?>
|
26 |
+
<h3 class="hndle"><span><?php esc_html_e( $title, 'buddypress-media' ); ?></span></h3>
|
27 |
<?php }
|
28 |
?>
|
29 |
+
<div class="inside"><?php echo $content; // @codingStandardsIgnoreLine ?></div>
|
30 |
</div><?php
|
31 |
} else {
|
32 |
+
trigger_error( esc_html__( 'Argument missing. id is required.', 'buddypress-media' ) );
|
33 |
}
|
34 |
}
|
|
|
35 |
}
|
36 |
|
37 |
+
}
|
app/helper/RTMediaCommentModel.php
CHANGED
@@ -26,6 +26,7 @@ class RTMediaCommentModel {
|
|
26 |
* Insert attr
|
27 |
*
|
28 |
* @access public
|
|
|
29 |
* @param array $attr
|
30 |
*/
|
31 |
public function insert( $attr ) {
|
@@ -37,6 +38,7 @@ class RTMediaCommentModel {
|
|
37 |
* Update comment.
|
38 |
*
|
39 |
* @access public
|
|
|
40 |
* @param array $attr
|
41 |
*/
|
42 |
public function update( $attr ) {
|
@@ -48,6 +50,7 @@ class RTMediaCommentModel {
|
|
48 |
* Get comments.
|
49 |
*
|
50 |
* @access public
|
|
|
51 |
* @param string $where
|
52 |
*/
|
53 |
public function get( $where ) {
|
@@ -59,7 +62,8 @@ class RTMediaCommentModel {
|
|
59 |
* Get comments by id.
|
60 |
*
|
61 |
* @access public
|
62 |
-
*
|
|
|
63 |
*/
|
64 |
public function get_by_id( $id ) {
|
65 |
|
@@ -70,7 +74,8 @@ class RTMediaCommentModel {
|
|
70 |
* Delete comments by id.
|
71 |
*
|
72 |
* @access public
|
73 |
-
*
|
|
|
74 |
*/
|
75 |
public function delete( $id ) {
|
76 |
|
26 |
* Insert attr
|
27 |
*
|
28 |
* @access public
|
29 |
+
*
|
30 |
* @param array $attr
|
31 |
*/
|
32 |
public function insert( $attr ) {
|
38 |
* Update comment.
|
39 |
*
|
40 |
* @access public
|
41 |
+
*
|
42 |
* @param array $attr
|
43 |
*/
|
44 |
public function update( $attr ) {
|
50 |
* Get comments.
|
51 |
*
|
52 |
* @access public
|
53 |
+
*
|
54 |
* @param string $where
|
55 |
*/
|
56 |
public function get( $where ) {
|
62 |
* Get comments by id.
|
63 |
*
|
64 |
* @access public
|
65 |
+
*
|
66 |
+
* @param int $id
|
67 |
*/
|
68 |
public function get_by_id( $id ) {
|
69 |
|
74 |
* Delete comments by id.
|
75 |
*
|
76 |
* @access public
|
77 |
+
*
|
78 |
+
* @param int $id
|
79 |
*/
|
80 |
public function delete( $id ) {
|
81 |
|
app/helper/RTMediaCommentNotification.php
CHANGED
@@ -2,135 +2,144 @@
|
|
2 |
|
3 |
/**
|
4 |
* Description of RTMediaCommentNotification
|
5 |
-
*
|
6 |
* @author Jignesh Nakrani <jignesh.nakrani@rtcamp.com>
|
7 |
*/
|
8 |
class RTMediaCommentNotification extends RTMediaNotification {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
/**
|
30 |
* Hooked to bp_init.
|
31 |
*/
|
32 |
-
function init(){
|
33 |
-
if( bp_is_active( 'notifications' ) ){
|
34 |
-
add_filter('rtmedia_comment_notifications', array($this, 'format_comment_notifications'));
|
35 |
-
add_action('rtmedia_after_add_comment', array($this, 'add_comment_notify'));
|
36 |
-
add_action('rtmedia_after_media', array($this, 'mark_notification_unread'));
|
37 |
-
add_action('rtmedia_before_remove_comment', array($this, 'remove_comment_notification'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$comment_author = bp_core_get_username($initiator_id);
|
56 |
-
$media_url = get_rtmedia_permalink(rtmedia_id($post_id));
|
57 |
-
$media_type = rtmedia_type(rtmedia_id($post_id));
|
58 |
-
|
59 |
-
if ($total_items == 1) {
|
60 |
-
$text = $comment_author . ' ' . __('commented on your', 'buddypress-media') . ' ' . $media_type;
|
61 |
-
} else {
|
62 |
-
$text = $total_items . ' ' . __('new comments on your', 'buddypress-media') . ' ' . $media_type;
|
63 |
-
}
|
64 |
-
$link = $media_url;
|
65 |
-
if ($format == 'string') {
|
66 |
-
$return = apply_filters('rtmedia_before_comment_notification', '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
|
67 |
-
} else {
|
68 |
-
$return = apply_filters('rtmedia_before_comment_notification', array(
|
69 |
-
'link' => $link,
|
70 |
-
'text' => $text
|
71 |
-
), (int) $total_items);
|
72 |
-
}
|
73 |
-
return $return;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* add a notification for a author of media on new comment on media
|
79 |
-
* @global type $bp
|
80 |
-
* @param array $args contains comment descriptions
|
81 |
-
*/
|
82 |
-
function add_comment_notify($args) {
|
83 |
-
|
84 |
-
$post_author_id = get_post($args['comment_post_ID'])->post_author;
|
85 |
-
$post_id = $args['comment_post_ID'];
|
86 |
-
$comment_id = $args['comment_id'];
|
87 |
-
$user_id = $args['user_id'];
|
88 |
-
|
89 |
-
if ($post_author_id == $user_id) {
|
90 |
-
return;
|
91 |
-
}
|
92 |
-
|
93 |
-
$comment_notification_id = $this->add_notification($post_id, $post_author_id, $args['user_id']);
|
94 |
-
if( false != $comment_notification_id ) {
|
95 |
-
add_comment_meta($comment_id, 'comment_notification_id', $comment_notification_id);
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* delete notification of a comment perticular commnet
|
101 |
-
* @param int $comment_id
|
102 |
-
*/
|
103 |
-
function remove_comment_notification($comment_id) {
|
104 |
-
|
105 |
-
$comment_notification_id = (int) get_comment_meta( $comment_id, 'comment_notification_id', true );
|
106 |
-
|
107 |
-
if ( $comment_notification_id > 0 ) {
|
108 |
-
BP_Notifications_Notification::delete( array( 'id' => $comment_notification_id ) );
|
109 |
-
delete_comment_meta( $comment_id, 'comment_notification_id' );
|
110 |
-
}
|
111 |
-
|
112 |
-
}
|
113 |
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
* this is callback function for rt_like_notifier component dont call this callback method manually
|
118 |
-
*
|
119 |
-
* @param int
|
120 |
-
* @param int
|
121 |
-
* @param int
|
122 |
-
* @param int
|
123 |
-
* @param String
|
124 |
-
*
|
125 |
-
* @return String/Array formatted notification
|
126 |
*/
|
127 |
-
function rt_comment_notifications_callback($action, $post_id, $initiator_id, $total_items, $format = 'string') {
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
2 |
|
3 |
/**
|
4 |
* Description of RTMediaCommentNotification
|
5 |
+
*
|
6 |
* @author Jignesh Nakrani <jignesh.nakrani@rtcamp.com>
|
7 |
*/
|
8 |
class RTMediaCommentNotification extends RTMediaNotification {
|
9 |
|
10 |
+
public $component_id = 'rt_comment_notifier';
|
11 |
+
public $component_action = 'new_comment_to_media';
|
12 |
|
13 |
+
function __construct() {
|
14 |
|
15 |
+
if ( class_exists( 'BuddyPress' ) ) {
|
16 |
+
$args = array(
|
17 |
+
'component_id' => 'rt_comment_notifier',
|
18 |
+
'component_slug' => 'rt_comment',
|
19 |
+
'component_callback' => 'rt_comment_notifications_callback',
|
20 |
+
'component_action' => $this->component_action,
|
21 |
+
);
|
22 |
|
23 |
+
parent::__construct( $args );
|
24 |
|
25 |
+
add_action( 'bp_init', array( $this, 'init' ) );
|
26 |
+
}
|
27 |
+
}
|
28 |
|
29 |
/**
|
30 |
* Hooked to bp_init.
|
31 |
*/
|
32 |
+
function init() {
|
33 |
+
if ( bp_is_active( 'notifications' ) ) {
|
34 |
+
add_filter( 'rtmedia_comment_notifications', array( $this, 'format_comment_notifications' ) );
|
35 |
+
add_action( 'rtmedia_after_add_comment', array( $this, 'add_comment_notify' ) );
|
36 |
+
add_action( 'rtmedia_after_media', array( $this, 'mark_notification_unread' ) );
|
37 |
+
add_action( 'rtmedia_before_remove_comment', array( $this, 'remove_comment_notification' ) );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* format the new notification in String or array
|
43 |
+
*
|
44 |
+
* @param array $params
|
45 |
+
*
|
46 |
+
* @return array/string As per $format
|
47 |
+
*/
|
48 |
+
function format_comment_notifications( $params ) {
|
49 |
+
$action = $params['action'];
|
50 |
+
$post_id = intval( $params['post_id'] );
|
51 |
+
|
52 |
+
if ( $this->component_action . $post_id === $action ) {
|
53 |
+
$initiator_id = $params['initiator_id'];
|
54 |
+
$total_items = $params['total_items'];
|
55 |
+
$format = $params['format'];
|
56 |
+
|
57 |
+
$comment_author = bp_core_get_username( $initiator_id );
|
58 |
+
$media_url = get_rtmedia_permalink( rtmedia_id( $post_id ) );
|
59 |
+
$media_type = rtmedia_type( rtmedia_id( $post_id ) );
|
60 |
+
|
61 |
+
if ( 1 === $total_items ) {
|
62 |
+
$text = $comment_author . ' ' . __( 'commented on your', 'buddypress-media' ) . ' ' . $media_type;
|
63 |
+
} else {
|
64 |
+
$text = $total_items . ' ' . __( 'new comments on your', 'buddypress-media' ) . ' ' . $media_type;
|
65 |
+
}
|
66 |
+
$link = esc_url( $media_url );
|
67 |
+
|
68 |
+
$return = apply_filters( 'rtmedia_before_comment_notification',
|
69 |
+
array(
|
70 |
+
'link' => $link,
|
71 |
+
'text' => $text,
|
72 |
+
),
|
73 |
+
(int) $total_items
|
74 |
+
);
|
75 |
+
|
76 |
+
if ( 'string' === $format ) {
|
77 |
+
return '<a href="' . esc_url( $return['link'] ) . '">' . esc_html( $return['text'] ) . '</a>';
|
78 |
+
} else {
|
79 |
+
return $return;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* add a notification for a author of media on new comment on media
|
86 |
+
* @global type $bp
|
87 |
+
*
|
88 |
+
* @param array $args contains comment descriptions
|
89 |
+
*/
|
90 |
+
function add_comment_notify( $args ) {
|
91 |
+
|
92 |
+
$post_author_id = get_post( $args['comment_post_ID'] )->post_author;
|
93 |
+
$post_id = $args['comment_post_ID'];
|
94 |
+
$comment_id = $args['comment_id'];
|
95 |
+
$user_id = $args['user_id'];
|
96 |
+
|
97 |
+
if ( intval( $post_author_id ) === intval( $user_id ) ) {
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
|
101 |
+
$comment_notification_id = $this->add_notification( $post_id, $post_author_id, $args['user_id'] );
|
102 |
+
if ( false !== $comment_notification_id ) {
|
103 |
+
add_comment_meta( $comment_id, 'comment_notification_id', $comment_notification_id );
|
104 |
}
|
105 |
}
|
106 |
|
107 |
+
/**
|
108 |
+
* delete notification of a comment perticular commnet
|
109 |
+
* @param int $comment_id
|
110 |
+
*/
|
111 |
+
function remove_comment_notification($comment_id) {
|
112 |
+
|
113 |
+
$comment_notification_id = (int) get_comment_meta( $comment_id, 'comment_notification_id', true );
|
114 |
+
|
115 |
+
if ( $comment_notification_id > 0 ) {
|
116 |
+
BP_Notifications_Notification::delete( array( 'id' => $comment_notification_id ) );
|
117 |
+
delete_comment_meta( $comment_id, 'comment_notification_id' );
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
* this is callback function for rt_like_notifier component dont call this callback method manually
|
126 |
+
*
|
127 |
+
* @param int $action action of componamt for notification
|
128 |
+
* @param int $post_id ID of a post to notification
|
129 |
+
* @param int $initiator_id secondary_item_id used in 'bp_notifications_add_notification'
|
130 |
+
* @param int $total_items number of notification for same component
|
131 |
+
* @param String $format string or array
|
132 |
+
*
|
133 |
+
* @return String/Array formatted notification
|
134 |
*/
|
135 |
+
function rt_comment_notifications_callback( $action, $post_id, $initiator_id, $total_items, $format = 'string' ) {
|
136 |
+
$params = array(
|
137 |
+
'action' => $action,
|
138 |
+
'post_id' => $post_id,
|
139 |
+
'initiator_id' => $initiator_id,
|
140 |
+
'total_items' => $total_items,
|
141 |
+
'format' => $format,
|
142 |
+
);
|
143 |
+
|
144 |
+
return apply_filters( 'rtmedia_comment_notifications', $params );
|
145 |
+
}
|
app/helper/RTMediaFeed.php
CHANGED
@@ -8,18 +8,17 @@
|
|
8 |
*/
|
9 |
class RTMediaFeed {
|
10 |
|
11 |
-
//public $feed_url = 'http://rtcamp.com/tag/buddypress/feed/';
|
12 |
public $feed_url = '';
|
13 |
|
14 |
/**
|
15 |
* Constructor
|
16 |
*
|
17 |
* @access public
|
|
|
18 |
* @param string $feed_url
|
19 |
-
* @return void
|
20 |
*/
|
21 |
public function __construct( $feed_url = '' ) {
|
22 |
-
if ( $feed_url ){
|
23 |
$this->feed_url = $feed_url;
|
24 |
}
|
25 |
}
|
@@ -29,41 +28,38 @@ class RTMediaFeed {
|
|
29 |
*/
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
* @global type $rtmedia
|
34 |
*/
|
35 |
public function fetch_feed() {
|
36 |
-
global $rtmedia;
|
37 |
// Get RSS Feed(s)
|
38 |
require_once( ABSPATH . WPINC . '/feed.php' );
|
39 |
-
$maxitems
|
|
|
40 |
// Get a SimplePie feed object from the specified feed source.
|
41 |
$rss = fetch_feed( $this->feed_url );
|
42 |
-
if ( ! is_wp_error( $rss ) ){ // Checks that the object is created correctly
|
43 |
-
// Figure out how many total items there are, but limit it to
|
44 |
-
// $maxitems = $rss->get_item_quantity(5);
|
45 |
$maxitems = $rss->get_item_quantity( 3 );
|
46 |
// Build an array of all the items, starting with element 0 (first element).
|
47 |
$rss_items = $rss->get_items( 0, $maxitems );
|
48 |
}
|
49 |
?>
|
50 |
<ul><?php
|
51 |
-
if ( 0
|
52 |
-
echo '<li>' .
|
53 |
} else {
|
54 |
// Loop through each feed item and display each item as a hyperlink.
|
55 |
foreach ( $rss_items as $item ) {
|
56 |
?>
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
60 |
}
|
61 |
}
|
62 |
?>
|
63 |
</ul><?php
|
64 |
-
if ( DOING_AJAX ){
|
65 |
-
|
66 |
}
|
67 |
}
|
68 |
-
|
69 |
-
}
|
8 |
*/
|
9 |
class RTMediaFeed {
|
10 |
|
|
|
11 |
public $feed_url = '';
|
12 |
|
13 |
/**
|
14 |
* Constructor
|
15 |
*
|
16 |
* @access public
|
17 |
+
*
|
18 |
* @param string $feed_url
|
|
|
19 |
*/
|
20 |
public function __construct( $feed_url = '' ) {
|
21 |
+
if ( $feed_url ) {
|
22 |
$this->feed_url = $feed_url;
|
23 |
}
|
24 |
}
|
28 |
*/
|
29 |
|
30 |
/**
|
|
|
|
|
31 |
*/
|
32 |
public function fetch_feed() {
|
|
|
33 |
// Get RSS Feed(s)
|
34 |
require_once( ABSPATH . WPINC . '/feed.php' );
|
35 |
+
$maxitems = 0;
|
36 |
+
$rss_items = array();
|
37 |
// Get a SimplePie feed object from the specified feed source.
|
38 |
$rss = fetch_feed( $this->feed_url );
|
39 |
+
if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly
|
40 |
+
// Figure out how many total items there are, but limit it to 3.
|
|
|
41 |
$maxitems = $rss->get_item_quantity( 3 );
|
42 |
// Build an array of all the items, starting with element 0 (first element).
|
43 |
$rss_items = $rss->get_items( 0, $maxitems );
|
44 |
}
|
45 |
?>
|
46 |
<ul><?php
|
47 |
+
if ( 0 === $maxitems ) {
|
48 |
+
echo '<li>' . esc_html__( 'No items', 'buddypress-media' ) . '.</li>';
|
49 |
} else {
|
50 |
// Loop through each feed item and display each item as a hyperlink.
|
51 |
foreach ( $rss_items as $item ) {
|
52 |
?>
|
53 |
+
<li>
|
54 |
+
<a href='<?php echo esc_url( $item->get_permalink() ); ?>?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media'
|
55 |
+
title='<?php echo esc_attr__( 'Posted ', 'buddypress-media' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ); ?>'><?php echo esc_html( $item->get_title() ); ?></a>
|
56 |
+
</li><?php
|
57 |
}
|
58 |
}
|
59 |
?>
|
60 |
</ul><?php
|
61 |
+
if ( DOING_AJAX ) {
|
62 |
+
wp_die();
|
63 |
}
|
64 |
}
|
65 |
+
}
|
|
app/helper/RTMediaInteractionModel.php
CHANGED
@@ -18,7 +18,7 @@ class RTMediaInteractionModel extends RTDBModel {
|
|
18 |
* @access public
|
19 |
* @return void
|
20 |
*/
|
21 |
-
public function __construct(){
|
22 |
parent::__construct( 'rtm_media_interaction', false, 10, true );
|
23 |
}
|
24 |
|
@@ -27,26 +27,26 @@ class RTMediaInteractionModel extends RTDBModel {
|
|
27 |
*
|
28 |
* @access public
|
29 |
*
|
30 |
-
* @param int
|
31 |
-
* @param int
|
32 |
* @param type $action
|
33 |
*
|
34 |
* @return bool
|
35 |
*/
|
36 |
-
public function check( $user_id = '', $media_id = '', $action = '' ){
|
37 |
-
if ( $user_id
|
38 |
return false;
|
39 |
}
|
40 |
|
41 |
$columns = array(
|
42 |
-
'user_id'
|
43 |
'media_id' => $media_id,
|
44 |
-
'action'
|
45 |
);
|
46 |
|
47 |
$results = $this->get( $columns );
|
48 |
|
49 |
-
if ( $results ){
|
50 |
return true;
|
51 |
} else {
|
52 |
return false;
|
@@ -58,28 +58,28 @@ class RTMediaInteractionModel extends RTDBModel {
|
|
58 |
*
|
59 |
* @access public
|
60 |
*
|
61 |
-
* @param int
|
62 |
-
* @param int
|
63 |
* @param type $action
|
64 |
*
|
65 |
* @return type $results
|
66 |
*/
|
67 |
-
function get_row( $user_id = '', $media_id = '', $action = '' ){
|
68 |
-
if ( $user_id
|
69 |
return false;
|
70 |
}
|
71 |
|
72 |
$columns = array();
|
73 |
-
if ( ''
|
74 |
$columns['user_id'] = $user_id;
|
75 |
}
|
76 |
-
if ( ''
|
77 |
$columns['media_id'] = $media_id;
|
78 |
}
|
79 |
-
if ( ''
|
80 |
$columns['action'] = $action;
|
81 |
}
|
82 |
-
|
83 |
$results = $this->get( $columns );
|
84 |
|
85 |
return $results;
|
18 |
* @access public
|
19 |
* @return void
|
20 |
*/
|
21 |
+
public function __construct() {
|
22 |
parent::__construct( 'rtm_media_interaction', false, 10, true );
|
23 |
}
|
24 |
|
27 |
*
|
28 |
* @access public
|
29 |
*
|
30 |
+
* @param int $user_id
|
31 |
+
* @param int $media_id
|
32 |
* @param type $action
|
33 |
*
|
34 |
* @return bool
|
35 |
*/
|
36 |
+
public function check( $user_id = '', $media_id = '', $action = '' ) {
|
37 |
+
if ( '' === $user_id || '' === $media_id || '' === $action ) {
|
38 |
return false;
|
39 |
}
|
40 |
|
41 |
$columns = array(
|
42 |
+
'user_id' => $user_id,
|
43 |
'media_id' => $media_id,
|
44 |
+
'action' => $action,
|
45 |
);
|
46 |
|
47 |
$results = $this->get( $columns );
|
48 |
|
49 |
+
if ( $results ) {
|
50 |
return true;
|
51 |
} else {
|
52 |
return false;
|
58 |
*
|
59 |
* @access public
|
60 |
*
|
61 |
+
* @param int $user_id
|
62 |
+
* @param int $media_id
|
63 |
* @param type $action
|
64 |
*
|
65 |
* @return type $results
|
66 |
*/
|
67 |
+
function get_row( $user_id = '', $media_id = '', $action = '' ) {
|
68 |
+
if ( '' === $user_id || '' === $media_id || '' === $action ) {
|
69 |
return false;
|
70 |
}
|
71 |
|
72 |
$columns = array();
|
73 |
+
if ( '' !== $user_id ) {
|
74 |
$columns['user_id'] = $user_id;
|
75 |
}
|
76 |
+
if ( '' !== $media_id ) {
|
77 |
$columns['media_id'] = $media_id;
|
78 |
}
|
79 |
+
if ( '' !== $action ) {
|
80 |
$columns['action'] = $action;
|
81 |
}
|
82 |
+
|
83 |
$results = $this->get( $columns );
|
84 |
|
85 |
return $results;
|
app/helper/RTMediaLicense.php
CHANGED
@@ -14,14 +14,12 @@ class RTMediaLicense {
|
|
14 |
|
15 |
self::$page = $page;
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
$tabs = apply_filters( 'rtmedia_license_tabs', array() );
|
20 |
$addon_installed = false;
|
21 |
if ( ! empty( $tabs ) && is_array( $tabs ) ) {
|
22 |
$addon_installed = true;
|
23 |
foreach ( $tabs as $key => $tab ) {
|
24 |
-
$tabs[ $key ][
|
25 |
}
|
26 |
?>
|
27 |
<div id="rtm-licenses">
|
@@ -41,69 +39,74 @@ class RTMediaLicense {
|
|
41 |
}
|
42 |
if ( ! $addon_installed ) {
|
43 |
?>
|
44 |
-
<div class="rtm-license-404">You may be interested in <a
|
|
|
|
|
45 |
<?php
|
46 |
}
|
47 |
}
|
48 |
|
49 |
static function render_license_section( $page = '', $args = '' ) {
|
50 |
|
51 |
-
$license = ( isset( $args[
|
52 |
-
$status
|
53 |
|
54 |
-
if (
|
55 |
$status_class = 'activated rtm-success';
|
56 |
-
$status_value =
|
57 |
} else {
|
58 |
$status_class = 'deactivated rtm-warning';
|
59 |
-
$status_value =
|
60 |
}
|
61 |
|
62 |
-
$el_id
|
63 |
-
$license_key_id
|
64 |
-
$license_status_id = $args[
|
65 |
?>
|
66 |
<div class="rtm-addon-license">
|
67 |
-
<div class="rtm-license-status-wrap <?php echo $status_class ?>">
|
68 |
-
<span
|
69 |
-
|
|
|
70 |
</div>
|
71 |
|
72 |
<form method="post">
|
73 |
<table class="form-table">
|
74 |
<tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
<tr>
|
76 |
<th scope="row">
|
77 |
-
<?php
|
78 |
</th>
|
79 |
<td>
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
</td>
|
83 |
</tr>
|
84 |
-
|
85 |
-
<?php if ( false !== $license ) { ?>
|
86 |
-
<tr>
|
87 |
-
<th scope="row">
|
88 |
-
<?php _e( 'Activate / Deactivate License', 'buddypress-media' ); ?>
|
89 |
-
</th>
|
90 |
-
<td>
|
91 |
-
<?php
|
92 |
-
$nonce_action = 'edd_' . $el_id . '_nonce';
|
93 |
-
$nonce_name = 'edd_' . $el_id . '_nonce';
|
94 |
-
if ( $status !== false && $status == 'valid' ) {
|
95 |
-
$btn_name = 'edd_' . $el_id . '_license_deactivate';
|
96 |
-
$btn_val = __( 'Deactivate License', 'buddypress-media' );
|
97 |
-
} else {
|
98 |
-
$btn_name = 'edd_' . $el_id . '_license_activate';
|
99 |
-
$btn_val = __( 'Activate License', 'buddypress-media' );
|
100 |
-
}
|
101 |
-
?>
|
102 |
-
<?php wp_nonce_field( $nonce_action, $nonce_name ); ?>
|
103 |
-
<input type="submit" class="button-secondary" name="<?php echo $btn_name; ?>" value="<?php echo $btn_val; ?>"/>
|
104 |
-
</td>
|
105 |
-
</tr>
|
106 |
-
<?php } ?>
|
107 |
</tbody>
|
108 |
</table>
|
109 |
<?php submit_button( 'Save Key' ); ?>
|
@@ -111,5 +114,4 @@ class RTMediaLicense {
|
|
111 |
</div>
|
112 |
<?php
|
113 |
}
|
114 |
-
|
115 |
}
|
14 |
|
15 |
self::$page = $page;
|
16 |
|
17 |
+
$tabs = apply_filters( 'rtmedia_license_tabs', array() );
|
|
|
|
|
18 |
$addon_installed = false;
|
19 |
if ( ! empty( $tabs ) && is_array( $tabs ) ) {
|
20 |
$addon_installed = true;
|
21 |
foreach ( $tabs as $key => $tab ) {
|
22 |
+
$tabs[ $key ]['callback'] = array( 'RTMediaLicense', 'render_license_section' );
|
23 |
}
|
24 |
?>
|
25 |
<div id="rtm-licenses">
|
39 |
}
|
40 |
if ( ! $addon_installed ) {
|
41 |
?>
|
42 |
+
<div class="rtm-license-404">You may be interested in <a
|
43 |
+
href="<?php echo esc_url( admin_url( 'admin.php?page=rtmedia-addons' ) ); ?>">rtMedia Addons</a>.
|
44 |
+
</div>
|
45 |
<?php
|
46 |
}
|
47 |
}
|
48 |
|
49 |
static function render_license_section( $page = '', $args = '' ) {
|
50 |
|
51 |
+
$license = ( isset( $args['license_key'] ) ) ? $args['license_key'] : false;
|
52 |
+
$status = ( isset( $args['status'] ) ) ? $args['status'] : false;
|
53 |
|
54 |
+
if ( false !== $status && 'valid' === $status ) {
|
55 |
$status_class = 'activated rtm-success';
|
56 |
+
$status_value = esc_attr__( 'Activated', 'buddypress-media' );
|
57 |
} else {
|
58 |
$status_class = 'deactivated rtm-warning';
|
59 |
+
$status_value = esc_attr__( 'Deactivated', 'buddypress-media' );
|
60 |
}
|
61 |
|
62 |
+
$el_id = $args['addon_id'];
|
63 |
+
$license_key_id = $args['key_id'];
|
64 |
+
$license_status_id = $args['status_id'];
|
65 |
?>
|
66 |
<div class="rtm-addon-license">
|
67 |
+
<div class="rtm-license-status-wrap <?php echo esc_attr( $status_class ) ?>">
|
68 |
+
<span
|
69 |
+
class="rtm-addon-license-status-label"><?php esc_html_e( 'Status: ', 'buddypress-media' ); ?></span>
|
70 |
+
<span class="rtm-addon-license-status"><?php echo esc_attr( $status_value ); ?></span>
|
71 |
</div>
|
72 |
|
73 |
<form method="post">
|
74 |
<table class="form-table">
|
75 |
<tbody>
|
76 |
+
<tr>
|
77 |
+
<th scope="row">
|
78 |
+
<?php esc_html_e( 'License Key', 'buddypress-media' ); ?>
|
79 |
+
</th>
|
80 |
+
<td>
|
81 |
+
<input id="<?php echo esc_attr( $license_key_id ) ?>"
|
82 |
+
name="<?php echo esc_attr( $license_key_id ) ?>" type="text"
|
83 |
+
class="regular-text" value="<?php echo esc_attr( $license ); ?>"/>
|
84 |
+
</td>
|
85 |
+
</tr>
|
86 |
+
|
87 |
+
<?php if ( false !== $license ) { ?>
|
88 |
<tr>
|
89 |
<th scope="row">
|
90 |
+
<?php esc_html_e( 'Activate / Deactivate License', 'buddypress-media' ); ?>
|
91 |
</th>
|
92 |
<td>
|
93 |
+
<?php
|
94 |
+
$nonce_action = 'edd_' . $el_id . '_nonce';
|
95 |
+
$nonce_name = 'edd_' . $el_id . '_nonce';
|
96 |
+
if ( false !== $status && 'valid' === $status ) {
|
97 |
+
$btn_name = 'edd_' . $el_id . '_license_deactivate';
|
98 |
+
$btn_val = esc_attr__( 'Deactivate License', 'buddypress-media' );
|
99 |
+
} else {
|
100 |
+
$btn_name = 'edd_' . $el_id . '_license_activate';
|
101 |
+
$btn_val = esc_attr__( 'Activate License', 'buddypress-media' );
|
102 |
+
}
|
103 |
+
?>
|
104 |
+
<?php wp_nonce_field( $nonce_action, $nonce_name ); ?>
|
105 |
+
<input type="submit" class="button-secondary"
|
106 |
+
name="<?php echo esc_attr( $btn_name ); ?>" value="<?php echo esc_attr( $btn_val ); ?>"/>
|
107 |
</td>
|
108 |
</tr>
|
109 |
+
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
</tbody>
|
111 |
</table>
|
112 |
<?php submit_button( 'Save Key' ); ?>
|
114 |
</div>
|
115 |
<?php
|
116 |
}
|
|
|
117 |
}
|
app/helper/RTMediaLikeNotification.php
CHANGED
@@ -7,149 +7,158 @@
|
|
7 |
*/
|
8 |
class RTMediaLikeNotification extends RTMediaNotification {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
/**
|
30 |
* Hooked to bp_init.
|
31 |
*/
|
32 |
-
function init(){
|
33 |
-
if( bp_is_active( 'notifications' ) ){
|
34 |
-
add_filter('rtmedia_like_notifications', array($this, 'format_like_notifications'));
|
35 |
-
add_action('rtmedia_after_like_media', array($this, 'add_like_notify'));
|
36 |
-
add_action('rtmedia_after_media', array($this, 'mark_notification_unread'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
} elseif ($like_count == 0) {
|
62 |
-
$this->delete_notification_by_item_id($post_author_id, $post_id);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Format string and media url for notification
|
68 |
-
*
|
69 |
-
* @param array $params array ('action', 'post_id', 'initiator_id', 'total_items', 'format' )
|
70 |
-
* @return string/array format notification as $params['format'] request
|
71 |
-
*/
|
72 |
-
function format_like_notifications($params) {
|
73 |
-
$action = $params['action'];
|
74 |
-
$post_id = $params['post_id'];
|
75 |
-
|
76 |
-
if ($this->component_action . $post_id == $action) {
|
77 |
-
|
78 |
-
$initiator_id = $params['initiator_id'];
|
79 |
-
$total_items = $params['total_items'];
|
80 |
-
$format = $params['format'];
|
81 |
-
|
82 |
-
$liked_list = $this->fetch_media_like_stats(rtmedia_id($post_id));
|
83 |
-
$liked_by = bp_core_get_username($liked_list[0]->user_id);
|
84 |
-
$like_count = get_rtmedia_like($post_id);
|
85 |
-
$link = get_rtmedia_permalink(rtmedia_id($post_id));
|
86 |
-
$media_type = rtmedia_type(rtmedia_id($post_id));
|
87 |
-
|
88 |
-
if ($like_count == 0) {
|
89 |
-
$this->delete_notification_by_item_id($initiator_id, $post_id);
|
90 |
-
} elseif ($like_count == 1) {
|
91 |
-
$text = $liked_by . ' ' . __('liked your', 'buddypress-media') . ' ' . $media_type;
|
92 |
-
} elseif ($like_count == 2) {
|
93 |
-
$text = $liked_by . ' ' . __('and one more friend liked your', 'buddypress-media') .' ' . $media_type;
|
94 |
-
} else {
|
95 |
-
$count = $like_count - 1;
|
96 |
-
$text = $liked_by . ' ' . __( 'and' ,'buddypress-media' ) . ' ' . $count . ' ' . __('other friends liked your', 'buddypress-media' ) . ' ' . $media_type;
|
97 |
-
}
|
98 |
-
|
99 |
-
if ($format == 'string') {
|
100 |
-
$return = apply_filters('rtmedia_before_like_notification', '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
|
101 |
-
} else {
|
102 |
-
$return = apply_filters('rtmedia_before_like_notification', array(
|
103 |
-
'link' => $link,
|
104 |
-
'text' => $text
|
105 |
-
), (int) $total_items);
|
106 |
-
}
|
107 |
-
return $return;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Get like count of a media
|
113 |
-
* @param int $media_id MediaID to count likes
|
114 |
-
*
|
115 |
-
* @return int Total like count on success or false
|
116 |
-
*/
|
117 |
-
function fetch_media_like_stats($media_id) {
|
118 |
-
if (empty($media_id)) {
|
119 |
-
return false;
|
120 |
-
}
|
121 |
-
$rtmediainteractionmodel = new RTMediaInteractionModel();
|
122 |
-
$media_like_cols = array(
|
123 |
-
'media_id' => $media_id,
|
124 |
-
'action' => 'like',
|
125 |
-
'value' => 1);
|
126 |
-
$media_likes = $rtmediainteractionmodel->get($media_like_cols, false, false, 'action_date');
|
127 |
-
if (count($media_likes) == 0) {
|
128 |
-
return false;
|
129 |
-
}
|
130 |
-
return $media_likes;
|
131 |
-
}
|
132 |
|
|
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
* this is callback function for rt_like_notifier component dont call this callback method manually
|
137 |
-
*
|
138 |
-
* @param int
|
139 |
-
* @param int
|
140 |
-
* @param int
|
141 |
-
* @param int
|
142 |
-
* @param String
|
143 |
-
*
|
144 |
-
* @return String/Array formatted notification
|
145 |
*/
|
146 |
-
function like_notifications_callback($action, $post_id, $initiator_id, $total_items, $format = 'string') {
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
155 |
}
|
7 |
*/
|
8 |
class RTMediaLikeNotification extends RTMediaNotification {
|
9 |
|
10 |
+
public $component_id = 'rt_like_notifier';
|
11 |
+
public $component_action = 'new_like_to_media';
|
12 |
|
13 |
+
function __construct() {
|
14 |
|
15 |
+
if ( class_exists( 'BuddyPress' ) ) {
|
16 |
+
$args = array(
|
17 |
+
'component_id' => 'rt_like_notifier',
|
18 |
+
'component_slug' => 'rt_like',
|
19 |
+
'component_callback' => 'like_notifications_callback',
|
20 |
+
'component_action' => $this->component_action,
|
21 |
+
);
|
22 |
|
23 |
+
parent::__construct( $args );
|
24 |
|
25 |
+
add_action( 'bp_init', array( $this, 'init' ) );
|
26 |
+
}
|
27 |
+
}
|
28 |
|
29 |
/**
|
30 |
* Hooked to bp_init.
|
31 |
*/
|
32 |
+
function init() {
|
33 |
+
if ( bp_is_active( 'notifications' ) ) {
|
34 |
+
add_filter( 'rtmedia_like_notifications', array( $this, 'format_like_notifications' ) );
|
35 |
+
add_action( 'rtmedia_after_like_media', array( $this, 'add_like_notify' ) );
|
36 |
+
add_action( 'rtmedia_after_media', array( $this, 'mark_notification_unread' ) );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* add notification using bp_notifications_add_notification function
|
42 |
+
* delete and merge likes if already same notification exist on a media
|
43 |
+
*
|
44 |
+
* @param RTMediaLike $likeargs RTMediaLike class object
|
45 |
+
*
|
46 |
+
*/
|
47 |
+
function add_like_notify( $likeargs ) {
|
48 |
+
$action = $likeargs->increase;
|
49 |
+
$user_id = $likeargs->interactor;
|
50 |
+
$post_author_id = $likeargs->owner;
|
51 |
+
$post_id = $likeargs->media->media_id;
|
52 |
+
$like_count = intval( get_rtmedia_like( $post_id ) );
|
53 |
+
|
54 |
+
if ( intval( $post_author_id ) === intval( $user_id ) ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
if ( true === $action ) {
|
58 |
+
$this->delete_notification_by_item_id( $post_author_id, $post_id );
|
59 |
+
$this->add_notification( $post_id, $post_author_id, $user_id );
|
60 |
+
} elseif ( 0 === intval( $like_count ) ) {
|
61 |
+
$this->delete_notification_by_item_id( $post_author_id, $post_id );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Format string and media url for notification
|
67 |
+
*
|
68 |
+
* @param array $params array ('action', 'post_id', 'initiator_id', 'total_items', 'format' )
|
69 |
+
*
|
70 |
+
* @return string/array format notification as $params['format'] request
|
71 |
+
*/
|
72 |
+
function format_like_notifications( $params ) {
|
73 |
+
$action = $params['action'];
|
74 |
+
$post_id = intval( $params['post_id'] );
|
75 |
+
|
76 |
+
if ( $this->component_action . $post_id === $action ) {
|
77 |
+
|
78 |
+
$initiator_id = $params['initiator_id'];
|
79 |
+
$total_items = $params['total_items'];
|
80 |
+
$format = $params['format'];
|
81 |
+
|
82 |
+
$rtmedia_id = rtmedia_id( $post_id );
|
83 |
+
$liked_list = $this->fetch_media_like_stats( $rtmedia_id );
|
84 |
+
$liked_by = bp_core_get_username( $liked_list[0]->user_id );
|
85 |
+
$like_count = get_rtmedia_like( $post_id );
|
86 |
+
$link = esc_url( get_rtmedia_permalink( $rtmedia_id ) );
|
87 |
+
$media_type = rtmedia_type( $rtmedia_id );
|
88 |
+
$text = null;
|
89 |
+
|
90 |
+
if ( 0 === intval( $like_count ) ) {
|
91 |
+
$this->delete_notification_by_item_id( $initiator_id, $post_id );
|
92 |
+
} elseif ( 1 === intval( $like_count ) ) {
|
93 |
+
$text = $liked_by . ' ' . __( 'liked your', 'buddypress-media' ) . ' ' . $media_type;
|
94 |
+
} elseif ( 2 === intval( $like_count ) ) {
|
95 |
+
$text = $liked_by . ' ' . __( 'and one more friend liked your', 'buddypress-media' ) . ' ' . $media_type;
|
96 |
+
} else {
|
97 |
+
$count = $like_count - 1;
|
98 |
+
$text = $liked_by . ' ' . __( 'and', 'buddypress-media' ) . ' ' . $count . ' ' . __( 'other friends liked your', 'buddypress-media' ) . ' ' . $media_type;
|
99 |
+
}
|
100 |
+
|
101 |
+
$return = apply_filters( 'rtmedia_before_like_notification',
|
102 |
+
array(
|
103 |
+
'link' => $link,
|
104 |
+
'text' => $text,
|
105 |
+
),
|
106 |
+
(int) $total_items
|
107 |
+
);
|
108 |
+
|
109 |
+
if ( 'string' === $format ) {
|
110 |
+
return '<a href="' . esc_url( $return['link'] ) . '">' . esc_html( $return['text'] ) . '</a>';
|
111 |
+
} else {
|
112 |
+
return $return;
|
113 |
+
}
|
114 |
}
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* Get like count of a media
|
119 |
+
*
|
120 |
+
* @param int $media_id MediaID to count likes
|
121 |
+
*
|
122 |
+
* @return int Total like count on success or false
|
123 |
+
*/
|
124 |
+
function fetch_media_like_stats( $media_id ) {
|
125 |
+
if ( empty( $media_id ) ) {
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
$rtmediainteractionmodel = new RTMediaInteractionModel();
|
129 |
+
$media_like_cols = array(
|
130 |
+
'media_id' => $media_id,
|
131 |
+
'action' => 'like',
|
132 |
+
'value' => 1,
|
133 |
+
);
|
134 |
+
$media_likes = $rtmediainteractionmodel->get( $media_like_cols, false, false, 'action_date' );
|
135 |
+
if ( 0 === count( $media_likes ) ) {
|
136 |
+
return false;
|
137 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
+
return $media_likes;
|
140 |
+
}
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
* this is callback function for rt_like_notifier component dont call this callback method manually
|
145 |
+
*
|
146 |
+
* @param int $action action of componamt for notification
|
147 |
+
* @param int $post_id ID of a post to notification
|
148 |
+
* @param int $initiator_id secondary_item_id used in 'bp_notifications_add_notification'
|
149 |
+
* @param int $total_items number of notification for same component
|
150 |
+
* @param String $format string or array
|
151 |
+
*
|
152 |
+
* @return String/Array formatted notification
|
153 |
*/
|
154 |
+
function like_notifications_callback( $action, $post_id, $initiator_id, $total_items, $format = 'string' ) {
|
155 |
+
$params = array(
|
156 |
+
'action' => $action,
|
157 |
+
'post_id' => $post_id,
|
158 |
+
'initiator_id' => $initiator_id,
|
159 |
+
'total_items' => $total_items,
|
160 |
+
'format' => $format,
|
161 |
+
);
|
162 |
+
|
163 |
+
return apply_filters( 'rtmedia_like_notifications', $params );
|
164 |
}
|
app/helper/RTMediaModel.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
class RTMediaModel extends RTDBModel {
|
9 |
|
10 |
-
function __construct(){
|
11 |
parent::__construct( 'rtm_media', false, 10, true );
|
12 |
$this->meta_table_name = 'rt_rtm_media_meta';
|
13 |
}
|
@@ -19,9 +19,9 @@ class RTMediaModel extends RTDBModel {
|
|
19 |
*
|
20 |
* @return array
|
21 |
*/
|
22 |
-
function __call( $name, $arguments ){
|
23 |
$result = parent::__call( $name, $arguments );
|
24 |
-
if ( ! $result['result'] ){
|
25 |
$result['result'] = $this->populate_results_fallback( $name, $arguments );
|
26 |
}
|
27 |
|
@@ -32,17 +32,17 @@ class RTMediaModel extends RTDBModel {
|
|
32 |
*
|
33 |
* @global object $wpdb
|
34 |
*
|
35 |
-
* @param array
|
36 |
-
* @param mixed
|
37 |
-
* @param mixed
|
38 |
-
* @param string
|
39 |
*
|
40 |
* @return array
|
41 |
*/
|
42 |
-
function get( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc', $count_flag = false ){
|
43 |
global $wpdb;
|
44 |
$select = 'SELECT ';
|
45 |
-
if ( $count_flag ){
|
46 |
$select .= 'count(*) ';
|
47 |
} else {
|
48 |
$select .= "{$this->table_name}.* ";
|
@@ -51,52 +51,56 @@ class RTMediaModel extends RTDBModel {
|
|
51 |
$from = " FROM {$this->table_name} ";
|
52 |
$join = '';
|
53 |
$where = ' where 2=2 ';
|
54 |
-
if ( is_multisite() ){
|
55 |
-
$where .= " AND {$this->table_name}.blog_id
|
56 |
}
|
57 |
$temp = 65;
|
58 |
|
59 |
$columns = apply_filters( 'rtmedia-model-query-columns', $columns, $count_flag );
|
60 |
|
61 |
foreach ( (array) $columns as $colname => $colvalue ) {
|
62 |
-
|
|
|
63 |
foreach ( $colvalue as $meta_query ) {
|
64 |
-
if ( ! isset( $meta_query['compare'] ) ){
|
65 |
$meta_query['compare'] = '=';
|
66 |
}
|
67 |
-
$tbl_alias = chr( $temp ++ );
|
68 |
-
if ( is_multisite() ){
|
69 |
$join .= " LEFT JOIN {$wpdb->base_prefix}{$this->meta_table_name} as {$tbl_alias} ON {$this->table_name}.id = {$tbl_alias}.media_id ";
|
70 |
} else {
|
71 |
$join .= " LEFT JOIN {$wpdb->prefix}{$this->meta_table_name} as {$tbl_alias} ON {$this->table_name}.id = {$tbl_alias}.media_id ";
|
72 |
}
|
73 |
-
|
74 |
-
|
|
|
75 |
} else {
|
76 |
-
$where .= " AND {$tbl_alias}.meta_key =
|
77 |
}
|
78 |
}
|
79 |
} else {
|
80 |
-
if ( is_array( $colvalue ) ){
|
81 |
-
if ( ! isset( $colvalue['compare'] ) ){
|
82 |
$compare = 'IN';
|
83 |
} else {
|
84 |
$compare = $colvalue['compare'];
|
85 |
}
|
86 |
|
87 |
$tmpVal = isset( $colvalue['value'] ) ? $colvalue['value'] : $colvalue;
|
88 |
-
$col_val_comapare = ( is_array( $tmpVal ) ) ?
|
89 |
-
if ( 'IS NOT'
|
90 |
$col_val_comapare = ! empty( $colvalue['value'] ) ? $colvalue['value'] : $col_val_comapare;
|
91 |
}
|
92 |
-
$
|
|
|
93 |
} else {
|
94 |
-
$where .= " AND {$this->table_name}.{$colname} =
|
95 |
}
|
96 |
}
|
97 |
}
|
98 |
$qgroup_by = ' ';
|
99 |
-
if ( $order_by ){
|
|
|
100 |
$qorder_by = " ORDER BY {$this->table_name}.{$order_by}";
|
101 |
} else {
|
102 |
$qorder_by = '';
|
@@ -109,20 +113,20 @@ class RTMediaModel extends RTDBModel {
|
|
109 |
$qorder_by = apply_filters( 'rtmedia-model-order-by-query', $qorder_by, $this->table_name );
|
110 |
|
111 |
$sql = $select . $from . $join . $where . $qgroup_by . $qorder_by;
|
112 |
-
if ( false !== $offset ){
|
113 |
-
if ( ! is_integer( $offset ) ){
|
114 |
$offset = 0;
|
115 |
}
|
116 |
|
117 |
-
if ( intval( $offset ) < 0 ){
|
118 |
$offset = 0;
|
119 |
}
|
120 |
|
121 |
-
if ( ! is_integer( $per_page ) ){
|
122 |
$per_page = 1;
|
123 |
}
|
124 |
|
125 |
-
if ( intval( $per_page ) < 1 ){
|
126 |
$per_page = 1;
|
127 |
}
|
128 |
|
@@ -131,10 +135,10 @@ class RTMediaModel extends RTDBModel {
|
|
131 |
|
132 |
$sql .= $limit;
|
133 |
}
|
134 |
-
if ( ! $count_flag ){
|
135 |
-
return $wpdb->get_results( $sql );
|
136 |
} else {
|
137 |
-
return $wpdb->get_var( $sql );
|
138 |
}
|
139 |
}
|
140 |
|
@@ -145,24 +149,24 @@ class RTMediaModel extends RTDBModel {
|
|
145 |
*
|
146 |
* @return array
|
147 |
*/
|
148 |
-
function populate_results_fallback( $name, $arguments ){
|
149 |
$result['result'] = false;
|
150 |
-
if ( 'get_by_media_id'
|
151 |
|
152 |
$result['result'][0]->media_id = $arguments[0];
|
153 |
|
154 |
$post_type = get_post_field( 'post_type', $arguments[0] );
|
155 |
-
if ( 'attachment'
|
156 |
-
$post_mime_type
|
157 |
$result['result'][0]->media_type = $post_mime_type[0];
|
158 |
-
} elseif ( 'bp_media_album'
|
159 |
$result['result'][0]->media_type = 'bp_media_album';
|
160 |
} else {
|
161 |
$result['result'][0]->media_type = false;
|
162 |
}
|
163 |
|
164 |
$result['result'][0]->context_id = intval( get_post_meta( $arguments[0], 'bp-media-key', true ) );
|
165 |
-
if ( $result['result'][0]->context_id > 0 ){
|
166 |
$result['result'][0]->context = 'profile';
|
167 |
} else {
|
168 |
$result['result'][0]->context = 'group';
|
@@ -185,8 +189,8 @@ class RTMediaModel extends RTDBModel {
|
|
185 |
*
|
186 |
* @return array
|
187 |
*/
|
188 |
-
function get_media( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc', $count_flag = false ){
|
189 |
-
if ( is_multisite() ){
|
190 |
$order_by = 'blog_id' . ( ( $order_by ) ? ',' . $order_by : '' );
|
191 |
}
|
192 |
|
@@ -204,49 +208,51 @@ class RTMediaModel extends RTDBModel {
|
|
204 |
*
|
205 |
* @return array $results
|
206 |
*/
|
207 |
-
function get_user_albums( $author_id, $offset, $per_page, $order_by = 'media_id desc' ){
|
208 |
global $wpdb;
|
209 |
-
if ( is_multisite() ){
|
210 |
$order_by = 'blog_id' . ( ( $order_by ) ? ',' . $order_by : '' );
|
211 |
}
|
212 |
|
213 |
$sql = "SELECT * FROM {$this->table_name} ";
|
214 |
|
215 |
-
if( is_multisite() ){
|
216 |
-
$sub_sql = "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE media_author =
|
217 |
} else {
|
218 |
-
$sub_sql = "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE media_author =
|
219 |
}
|
220 |
-
|
221 |
-
$where = " WHERE (id IN( $sub_sql ) OR (media_author =
|
222 |
AND media_type = 'album'
|
223 |
-
AND (context = 'profile' or context is NULL) ";
|
224 |
-
if ( is_multisite() ){
|
225 |
-
$where .= " AND {$this->table_name}.blog_id =
|
226 |
}
|
227 |
$where = apply_filters( 'rtmedia-get-album-where-query', $where, $this->table_name );
|
|
|
|
|
228 |
$qorder_by = " ORDER BY {$this->table_name}.$order_by ";
|
229 |
$sql .= $where . $qorder_by;
|
230 |
-
if ( false !== $offset ){
|
231 |
-
if ( ! is_integer( $offset ) ){
|
232 |
$offset = 0;
|
233 |
}
|
234 |
-
if ( intval( $offset ) < 0 ){
|
235 |
$offset = 0;
|
236 |
}
|
237 |
|
238 |
-
if ( ! is_integer( $per_page ) ){
|
239 |
$per_page = 1;
|
240 |
}
|
241 |
-
if ( intval( $per_page ) < 1 ){
|
242 |
$per_page = 1;
|
243 |
}
|
244 |
|
245 |
$sql .= ' LIMIT ' . $offset . ',' . $per_page;
|
246 |
}
|
247 |
-
|
248 |
-
$results = $wpdb->get_results( $sql );
|
249 |
-
|
250 |
return $results;
|
251 |
}
|
252 |
|
@@ -259,35 +265,37 @@ class RTMediaModel extends RTDBModel {
|
|
259 |
*
|
260 |
* @return array $results
|
261 |
*/
|
262 |
-
function get_group_albums( $group_id, $offset, $per_page, $order_by = 'media_id desc' ){
|
263 |
global $wpdb;
|
264 |
-
if ( is_multisite
|
265 |
-
|
|
|
266 |
|
267 |
-
if( is_multisite() ){
|
268 |
-
$sub_sql = "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id =
|
269 |
} else {
|
270 |
-
$sub_sql = "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id =
|
271 |
}
|
272 |
-
$sql = "SELECT * FROM {$this->table_name} WHERE id IN( $sub_sql ) OR (media_type = 'album' AND context_id =
|
273 |
|
274 |
-
if ( is_multisite() ){
|
275 |
-
$sql .= " AND {$this->table_name}.blog_id =
|
276 |
}
|
|
|
277 |
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
278 |
|
279 |
-
if ( false !== $offset ){
|
280 |
-
if ( ! is_integer( $offset ) ){
|
281 |
$offset = 0;
|
282 |
}
|
283 |
-
if ( intval( $offset ) < 0 ){
|
284 |
$offset = 0;
|
285 |
}
|
286 |
|
287 |
-
if ( ! is_integer( $per_page ) ){
|
288 |
$per_page = 1;
|
289 |
}
|
290 |
-
if ( intval( $per_page ) < 1 ){
|
291 |
$per_page = 1;
|
292 |
}
|
293 |
|
@@ -305,56 +313,50 @@ class RTMediaModel extends RTDBModel {
|
|
305 |
*
|
306 |
* @return string $result
|
307 |
*/
|
308 |
-
function get_counts( $user_id = false, $where_query = false ){
|
309 |
-
|
310 |
-
if ( ! $user_id && ! $where_query ){
|
311 |
return false;
|
312 |
}
|
313 |
global $wpdb, $rtmedia;
|
314 |
|
315 |
$query = "SELECT {$this->table_name}.privacy, ";
|
316 |
foreach ( $rtmedia->allowed_types as $type ) {
|
317 |
-
$
|
|
|
318 |
}
|
319 |
$query .= "SUM(CASE WHEN {$this->table_name}.media_type LIKE 'album' THEN 1 ELSE 0 END) as album
|
320 |
FROM
|
321 |
{$this->table_name} WHERE 2=2 ";
|
322 |
|
323 |
-
if ( is_multisite() ){
|
324 |
-
$query .= " AND {$this->table_name}.blog_id =
|
325 |
}
|
326 |
-
|
327 |
-
if ( $where_query ){
|
328 |
foreach ( $where_query as $colname => $colvalue ) {
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
332 |
$compare = 'IN';
|
333 |
} else {
|
334 |
$compare = $colvalue['compare'];
|
335 |
}
|
336 |
-
if ( ! isset( $colvalue['value'] ) ){
|
337 |
$colvalue['value'] = $colvalue;
|
338 |
}
|
339 |
-
|
340 |
-
|
341 |
} else {
|
342 |
-
|
343 |
-
// if ( $colname == "context" && $colvalue == "profile" ) {
|
344 |
-
// $query .= " AND {$this->table_name}.{$colname} <> 'group'";
|
345 |
-
// } else {
|
346 |
-
// $query .= " AND {$this->table_name}.{$colname} = '{$colvalue}'";
|
347 |
-
// }
|
348 |
-
//profile now shows only profile media so conditional check removed and counts will be fetched according to the available context
|
349 |
-
$where_query_sql .= " AND {$this->table_name}.{$colname} = '{$colvalue}'";
|
350 |
}
|
351 |
}
|
352 |
}
|
353 |
}
|
354 |
-
|
355 |
-
|
356 |
-
$result
|
357 |
-
if ( ! is_array( $result ) ){
|
358 |
return false;
|
359 |
}
|
360 |
|
@@ -368,35 +370,35 @@ class RTMediaModel extends RTDBModel {
|
|
368 |
*
|
369 |
* @return int
|
370 |
*/
|
371 |
-
function get_other_album_count( $profile_id, $context = 'profile' ){
|
|
|
372 |
$global = RTMediaAlbum::get_globals();
|
373 |
-
$sql = "select distinct album_id from {$this->table_name} where 2=2 AND context =
|
374 |
-
if ( is_multisite() ){
|
375 |
-
$sql .= " AND {$this->table_name}.blog_id =
|
376 |
}
|
377 |
-
if ( is_array( $global ) && count( $global ) > 0 ){
|
378 |
$sql .= ' and album_id in (';
|
379 |
$sep = '';
|
380 |
foreach ( $global as $id ) {
|
381 |
-
$sql .= $sep . $id;
|
382 |
$sep = ',';
|
383 |
}
|
384 |
$sql .= ')';
|
385 |
}
|
386 |
-
if ( 'profile'
|
387 |
-
$sql .=
|
388 |
} else {
|
389 |
-
if ( 'group'
|
390 |
-
$sql .=
|
391 |
}
|
392 |
}
|
393 |
-
|
394 |
$result = $wpdb->get_results( $sql );
|
395 |
-
if ( isset( $result ) ){
|
396 |
return count( $result );
|
397 |
} else {
|
398 |
return 0;
|
399 |
}
|
400 |
}
|
401 |
-
|
402 |
-
}
|
7 |
*/
|
8 |
class RTMediaModel extends RTDBModel {
|
9 |
|
10 |
+
function __construct() {
|
11 |
parent::__construct( 'rtm_media', false, 10, true );
|
12 |
$this->meta_table_name = 'rt_rtm_media_meta';
|
13 |
}
|
19 |
*
|
20 |
* @return array
|
21 |
*/
|
22 |
+
function __call( $name, $arguments ) {
|
23 |
$result = parent::__call( $name, $arguments );
|
24 |
+
if ( ! $result['result'] ) {
|
25 |
$result['result'] = $this->populate_results_fallback( $name, $arguments );
|
26 |
}
|
27 |
|
32 |
*
|
33 |
* @global object $wpdb
|
34 |
*
|
35 |
+
* @param array $columns
|
36 |
+
* @param mixed $offset
|
37 |
+
* @param mixed $per_page
|
38 |
+
* @param string $order_by
|
39 |
*
|
40 |
* @return array
|
41 |
*/
|
42 |
+
function get( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc', $count_flag = false ) {
|
43 |
global $wpdb;
|
44 |
$select = 'SELECT ';
|
45 |
+
if ( $count_flag ) {
|
46 |
$select .= 'count(*) ';
|
47 |
} else {
|
48 |
$select .= "{$this->table_name}.* ";
|
51 |
$from = " FROM {$this->table_name} ";
|
52 |
$join = '';
|
53 |
$where = ' where 2=2 ';
|
54 |
+
if ( is_multisite() ) {
|
55 |
+
$where .= $wpdb->prepare( " AND {$this->table_name}.blog_id =%d ", get_current_blog_id() ); // @codingStandardsIgnoreLine
|
56 |
}
|
57 |
$temp = 65;
|
58 |
|
59 |
$columns = apply_filters( 'rtmedia-model-query-columns', $columns, $count_flag );
|
60 |
|
61 |
foreach ( (array) $columns as $colname => $colvalue ) {
|
62 |
+
$colname = esc_sql( $colname );
|
63 |
+
if ( 'meta_query' === strtolower( $colname ) ) {
|
64 |
foreach ( $colvalue as $meta_query ) {
|
65 |
+
if ( ! isset( $meta_query['compare'] ) ) {
|
66 |
$meta_query['compare'] = '=';
|
67 |
}
|
68 |
+
$tbl_alias = esc_sql( chr( $temp ++ ) );
|
69 |
+
if ( is_multisite() ) {
|
70 |
$join .= " LEFT JOIN {$wpdb->base_prefix}{$this->meta_table_name} as {$tbl_alias} ON {$this->table_name}.id = {$tbl_alias}.media_id ";
|
71 |
} else {
|
72 |
$join .= " LEFT JOIN {$wpdb->prefix}{$this->meta_table_name} as {$tbl_alias} ON {$this->table_name}.id = {$tbl_alias}.media_id ";
|
73 |
}
|
74 |
+
$meta_query['compare'] = esc_sql( $meta_query['compare'] );
|
75 |
+
if ( isset( $meta_query['value'] ) ) {
|
76 |
+
$where .= $wpdb->prepare( " AND ({$tbl_alias}.meta_key = %s and {$tbl_alias}.meta_value {$meta_query["compare"]} %s ) ", $meta_query['key'], $meta_query['value'] ); // @codingStandardsIgnoreLine
|
77 |
} else {
|
78 |
+
$where .= $wpdb->prepare( " AND {$tbl_alias}.meta_key = %s ", $meta_query['key'] );// @codingStandardsIgnoreLine
|
79 |
}
|
80 |
}
|
81 |
} else {
|
82 |
+
if ( is_array( $colvalue ) ) {
|
83 |
+
if ( ! isset( $colvalue['compare'] ) ) {
|
84 |
$compare = 'IN';
|
85 |
} else {
|
86 |
$compare = $colvalue['compare'];
|
87 |
}
|
88 |
|
89 |
$tmpVal = isset( $colvalue['value'] ) ? $colvalue['value'] : $colvalue;
|
90 |
+
$col_val_comapare = ( is_array( $tmpVal ) ) ? implode( "','", esc_sql( $tmpVal ) ) : esc_sql( $tmpVal );
|
91 |
+
if ( 'IS NOT' === $compare ) {
|
92 |
$col_val_comapare = ! empty( $colvalue['value'] ) ? $colvalue['value'] : $col_val_comapare;
|
93 |
}
|
94 |
+
$compare = esc_sql( $compare );
|
95 |
+
$where .= " AND {$this->table_name}.{$colname} {$compare} ('{$col_val_comapare}')";
|
96 |
} else {
|
97 |
+
$where .= $wpdb->prepare( " AND {$this->table_name}.{$colname} = %s", $colvalue ); // @codingStandardsIgnoreLine
|
98 |
}
|
99 |
}
|
100 |
}
|
101 |
$qgroup_by = ' ';
|
102 |
+
if ( $order_by ) {
|
103 |
+
$order_by = esc_sql( $order_by );
|
104 |
$qorder_by = " ORDER BY {$this->table_name}.{$order_by}";
|
105 |
} else {
|
106 |
$qorder_by = '';
|
113 |
$qorder_by = apply_filters( 'rtmedia-model-order-by-query', $qorder_by, $this->table_name );
|
114 |
|
115 |
$sql = $select . $from . $join . $where . $qgroup_by . $qorder_by;
|
116 |
+
if ( false !== $offset ) {
|
117 |
+
if ( ! is_integer( $offset ) ) {
|
118 |
$offset = 0;
|
119 |
}
|
120 |
|
121 |
+
if ( intval( $offset ) < 0 ) {
|
122 |
$offset = 0;
|
123 |
}
|
124 |
|
125 |
+
if ( ! is_integer( $per_page ) ) {
|
126 |
$per_page = 1;
|
127 |
}
|
128 |
|
129 |
+
if ( intval( $per_page ) < 1 ) {
|
130 |
$per_page = 1;
|
131 |
}
|
132 |
|
135 |
|
136 |
$sql .= $limit;
|
137 |
}
|
138 |
+
if ( ! $count_flag ) {
|
139 |
+
return $wpdb->get_results( $sql ); // @codingStandardsIgnoreLine
|
140 |
} else {
|
141 |
+
return $wpdb->get_var( $sql ); // @codingStandardsIgnoreLine
|
142 |
}
|
143 |
}
|
144 |
|
149 |
*
|
150 |
* @return array
|
151 |
*/
|
152 |
+
function populate_results_fallback( $name, $arguments ) {
|
153 |
$result['result'] = false;
|
154 |
+
if ( 'get_by_media_id' === $name && isset( $arguments[0] ) && $arguments[0] ) {
|
155 |
|
156 |
$result['result'][0]->media_id = $arguments[0];
|
157 |
|
158 |
$post_type = get_post_field( 'post_type', $arguments[0] );
|
159 |
+
if ( 'attachment' === $post_type ) {
|
160 |
+
$post_mime_type = explode( '/', get_post_field( 'post_mime_type', $arguments[0] ) );
|
161 |
$result['result'][0]->media_type = $post_mime_type[0];
|
162 |
+
} elseif ( 'bp_media_album' === $post_type ) {
|
163 |
$result['result'][0]->media_type = 'bp_media_album';
|
164 |
} else {
|
165 |
$result['result'][0]->media_type = false;
|
166 |
}
|
167 |
|
168 |
$result['result'][0]->context_id = intval( get_post_meta( $arguments[0], 'bp-media-key', true ) );
|
169 |
+
if ( intval( $result['result'][0]->context_id ) > 0 ) {
|
170 |
$result['result'][0]->context = 'profile';
|
171 |
} else {
|
172 |
$result['result'][0]->context = 'group';
|
189 |
*
|
190 |
* @return array
|
191 |
*/
|
192 |
+
function get_media( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc', $count_flag = false ) {
|
193 |
+
if ( is_multisite() ) {
|
194 |
$order_by = 'blog_id' . ( ( $order_by ) ? ',' . $order_by : '' );
|
195 |
}
|
196 |
|
208 |
*
|
209 |
* @return array $results
|
210 |
*/
|
211 |
+
function get_user_albums( $author_id, $offset, $per_page, $order_by = 'media_id desc' ) {
|
212 |
global $wpdb;
|
213 |
+
if ( is_multisite() ) {
|
214 |
$order_by = 'blog_id' . ( ( $order_by ) ? ',' . $order_by : '' );
|
215 |
}
|
216 |
|
217 |
$sql = "SELECT * FROM {$this->table_name} ";
|
218 |
|
219 |
+
if ( is_multisite() ) {
|
220 |
+
$sub_sql = $wpdb->prepare( "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE media_author = %d AND album_id IS NOT NULL AND media_type <> 'album' AND context <> 'group' AND blog_id = %d", $author_id, get_current_blog_id() ); // @codingStandardsIgnoreLine
|
221 |
} else {
|
222 |
+
$sub_sql = $wpdb->prepare( "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE media_author = %d AND album_id IS NOT NULL AND media_type <> 'album' AND context <> 'group'", $author_id ); // @codingStandardsIgnoreLine
|
223 |
}
|
224 |
+
// @codingStandardsIgnoreStart
|
225 |
+
$where = $wpdb->prepare( " WHERE (id IN( $sub_sql ) OR (media_author = %d ))
|
226 |
AND media_type = 'album'
|
227 |
+
AND (context = 'profile' or context is NULL) ", $author_id ); // @codingStandardsIgnoreEnd
|
228 |
+
if ( is_multisite() ) {
|
229 |
+
$where .= $wpdb->prepare( " AND {$this->table_name}.blog_id = %d ", get_current_blog_id() ); // @codingStandardsIgnoreStart
|
230 |
}
|
231 |
$where = apply_filters( 'rtmedia-get-album-where-query', $where, $this->table_name );
|
232 |
+
|
233 |
+
$order_by = esc_sql( $order_by );
|
234 |
$qorder_by = " ORDER BY {$this->table_name}.$order_by ";
|
235 |
$sql .= $where . $qorder_by;
|
236 |
+
if ( false !== $offset ) {
|
237 |
+
if ( ! is_integer( $offset ) ) {
|
238 |
$offset = 0;
|
239 |
}
|
240 |
+
if ( intval( $offset ) < 0 ) {
|
241 |
$offset = 0;
|
242 |
}
|
243 |
|
244 |
+
if ( ! is_integer( $per_page ) ) {
|
245 |
$per_page = 1;
|
246 |
}
|
247 |
+
if ( intval( $per_page ) < 1 ) {
|
248 |
$per_page = 1;
|
249 |
}
|
250 |
|
251 |
$sql .= ' LIMIT ' . $offset . ',' . $per_page;
|
252 |
}
|
253 |
+
|
254 |
+
$results = $wpdb->get_results( $sql ); // @codingStandardsIgnoreStart
|
255 |
+
|
256 |
return $results;
|
257 |
}
|
258 |
|
265 |
*
|
266 |
* @return array $results
|
267 |
*/
|
268 |
+
function get_group_albums( $group_id, $offset, $per_page, $order_by = 'media_id desc' ) {
|
269 |
global $wpdb;
|
270 |
+
if ( is_multisite() ) {
|
271 |
+
$order_by = 'blog_id' . ( ( $order_by ) ? ',' . $order_by : '' );
|
272 |
+
}
|
273 |
|
274 |
+
if ( is_multisite() ) {
|
275 |
+
$sub_sql = $wpdb->prepare( "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id = %d AND album_id IS NOT NULL AND media_type != 'album' AND context = 'group' AND blog_id = %d", $group_id, get_current_blog_id() );
|
276 |
} else {
|
277 |
+
$sub_sql = $wpdb->prepare( "SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id = %d AND album_id IS NOT NULL AND media_type != 'album' AND context = 'group'", $group_id );
|
278 |
}
|
279 |
+
$sql = $wpdb->prepare( "SELECT * FROM {$this->table_name} WHERE id IN( $sub_sql ) OR (media_type = 'album' AND context_id = %d AND context = 'group')", $group_id );
|
280 |
|
281 |
+
if ( is_multisite() ) {
|
282 |
+
$sql .= $wpdb->prepare( " AND {$this->table_name}.blog_id = %d ", get_current_blog_id() );
|
283 |
}
|
284 |
+
$order_by = esc_sql( $order_by );
|
285 |
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
286 |
|
287 |
+
if ( false !== $offset ) {
|
288 |
+
if ( ! is_integer( $offset ) ) {
|
289 |
$offset = 0;
|
290 |
}
|
291 |
+
if ( intval( $offset ) < 0 ) {
|
292 |
$offset = 0;
|
293 |
}
|
294 |
|
295 |
+
if ( ! is_integer( $per_page ) ) {
|
296 |
$per_page = 1;
|
297 |
}
|
298 |
+
if ( intval( $per_page ) < 1 ) {
|
299 |
$per_page = 1;
|
300 |
}
|
301 |
|
313 |
*
|
314 |
* @return string $result
|
315 |
*/
|
316 |
+
function get_counts( $user_id = false, $where_query = false ) {
|
317 |
+
if ( ! $user_id && ! $where_query ) {
|
|
|
318 |
return false;
|
319 |
}
|
320 |
global $wpdb, $rtmedia;
|
321 |
|
322 |
$query = "SELECT {$this->table_name}.privacy, ";
|
323 |
foreach ( $rtmedia->allowed_types as $type ) {
|
324 |
+
$type['name'] = esc_sql( $type['name'] );
|
325 |
+
$query .= $wpdb->prepare( "SUM(CASE WHEN {$this->table_name}.media_type LIKE %s THEN 1 ELSE 0 END) as {$type['name']}, ", $type['name'] );
|
326 |
}
|
327 |
$query .= "SUM(CASE WHEN {$this->table_name}.media_type LIKE 'album' THEN 1 ELSE 0 END) as album
|
328 |
FROM
|
329 |
{$this->table_name} WHERE 2=2 ";
|
330 |
|
331 |
+
if ( is_multisite() ) {
|
332 |
+
$query .= $wpdb->prepare( " AND {$this->table_name}.blog_id = %d ", get_current_blog_id() );
|
333 |
}
|
334 |
+
$where_query_sql = '';
|
335 |
+
if ( $where_query ) {
|
336 |
foreach ( $where_query as $colname => $colvalue ) {
|
337 |
+
$colname = esc_sql( $colname );
|
338 |
+
if ( 'meta_query' !== strtolower( $colname ) ) {
|
339 |
+
if ( is_array( $colvalue ) ) {
|
340 |
+
if ( ! isset( $colvalue['compare'] ) ) {
|
341 |
$compare = 'IN';
|
342 |
} else {
|
343 |
$compare = $colvalue['compare'];
|
344 |
}
|
345 |
+
if ( ! isset( $colvalue['value'] ) ) {
|
346 |
$colvalue['value'] = $colvalue;
|
347 |
}
|
348 |
+
$compare = esc_sql( $compare );
|
349 |
+
$where_query_sql .= " AND {$this->table_name}.{$colname} {$compare} ('" . implode( "','", esc_sql( $colvalue['value'] ) ) . "')";
|
350 |
} else {
|
351 |
+
$where_query_sql .= $wpdb->prepare( " AND {$this->table_name}.{$colname} = %s", $colvalue );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
}
|
354 |
}
|
355 |
}
|
356 |
+
$where_query_sql = apply_filters( 'rtmedia-get-counts-where-query', $where_query_sql );
|
357 |
+
$query = $query . $where_query_sql . ' GROUP BY privacy limit 100';
|
358 |
+
$result = $wpdb->get_results( $query );
|
359 |
+
if ( ! is_array( $result ) ) {
|
360 |
return false;
|
361 |
}
|
362 |
|
370 |
*
|
371 |
* @return int
|
372 |
*/
|
373 |
+
function get_other_album_count( $profile_id, $context = 'profile' ) {
|
374 |
+
global $wpdb;
|
375 |
$global = RTMediaAlbum::get_globals();
|
376 |
+
$sql = $wpdb->prepare( "select distinct album_id from {$this->table_name} where 2=2 AND context = %s ", $context );
|
377 |
+
if ( is_multisite() ) {
|
378 |
+
$sql .= $wpdb->prepare( " AND {$this->table_name}.blog_id = %d ", get_current_blog_id() );
|
379 |
}
|
380 |
+
if ( is_array( $global ) && count( $global ) > 0 ) {
|
381 |
$sql .= ' and album_id in (';
|
382 |
$sep = '';
|
383 |
foreach ( $global as $id ) {
|
384 |
+
$sql .= $sep . esc_sql( $id );
|
385 |
$sep = ',';
|
386 |
}
|
387 |
$sql .= ')';
|
388 |
}
|
389 |
+
if ( 'profile' === $context ) {
|
390 |
+
$sql .= $wpdb->prepare( ' AND media_author=%d ', $profile_id );
|
391 |
} else {
|
392 |
+
if ( 'group' === $context ) {
|
393 |
+
$sql .= $wpdb->prepare( ' AND context_id=%d ', $profile_id );
|
394 |
}
|
395 |
}
|
396 |
+
$sql .= 'limit 100';
|
397 |
$result = $wpdb->get_results( $sql );
|
398 |
+
if ( isset( $result ) ) {
|
399 |
return count( $result );
|
400 |
} else {
|
401 |
return 0;
|
402 |
}
|
403 |
}
|
404 |
+
}
|
|
app/helper/RTMediaNotification.php
CHANGED
@@ -7,81 +7,84 @@
|
|
7 |
*/
|
8 |
|
9 |
/**
|
10 |
-
*
|
11 |
* @author Jignesh Nakrani <jignesh.nakrani@rtcamp.com>
|
12 |
*/
|
13 |
class RTMediaNotification {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'item_id' => $post_id,
|
54 |
-
'user_id' => $post_author_id,
|
55 |
-
'component_name' => $this->component_id,
|
56 |
-
'component_action' => $this->component_action . $post_id,
|
57 |
-
'secondary_item_id' => $user_id,
|
58 |
-
'date_notified' => bp_core_current_time(),
|
59 |
-
);
|
60 |
-
global $rtmedia;
|
61 |
-
if ( isset( $rtmedia->options[ "buddypress_enableNotification" ] ) && $rtmedia->options[ "buddypress_enableNotification" ] != "0" ) {
|
62 |
-
return bp_notifications_add_notification( $args_add_noification );
|
63 |
-
}
|
64 |
-
return false;
|
65 |
-
}
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
bp_notifications_mark_notifications_by_type($user_id, $this->component_id, $this->component_action . $post_id, $is_new = false);
|
76 |
-
}
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
* @param int $post_id ID of a post to delete related notification
|
82 |
-
*/
|
83 |
-
function delete_notification_by_item_id($post_author_id, $post_id) {
|
84 |
-
bp_notifications_delete_notifications_by_item_id($post_author_id, $post_id, $this->component_id, $this->component_action . $post_id);
|
85 |
-
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
7 |
*/
|
8 |
|
9 |
/**
|
10 |
+
*
|
11 |
* @author Jignesh Nakrani <jignesh.nakrani@rtcamp.com>
|
12 |
*/
|
13 |
class RTMediaNotification {
|
14 |
|
15 |
+
public $component_id;
|
16 |
+
public $component_slug;
|
17 |
+
public $component_callback;
|
18 |
+
public $component_action;
|
19 |
|
20 |
+
function __construct( $args ) {
|
21 |
|
22 |
+
foreach ( $args as $key => $val ) {
|
23 |
+
$this->{$key} = $val;
|
24 |
+
}
|
25 |
|
26 |
+
add_action( 'bp_setup_globals', array( $this, 'notifier_setup_globals' ) );
|
27 |
+
}
|
28 |
|
29 |
+
/**
|
30 |
+
* register a new component for notifications
|
31 |
+
* @global type $bp
|
32 |
+
*/
|
33 |
+
function notifier_setup_globals() {
|
34 |
+
global $bp;
|
35 |
+
$component = $this->component_id;
|
36 |
+
$bp->{$component} = new stdClass();
|
37 |
+
$bp->{$component}->id = $component;
|
38 |
+
$bp->{$component}->slug = $this->component_slug;
|
39 |
+
$bp->{$component}->notification_callback = $this->component_callback;
|
40 |
+
$bp->active_components[ $bp->{$component}->id ] = $bp->{$component}->id;
|
41 |
+
}
|
42 |
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @param int $post_id
|
46 |
+
* @param int $post_author_id
|
47 |
+
* @param int $user_id
|
48 |
+
*
|
49 |
+
* @return int|bool notification id on success or false
|
50 |
+
*/
|
51 |
+
function add_notification( $post_id, $post_author_id, $user_id ) {
|
52 |
+
global $rtmedia;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
$args_add_noification = array(
|
55 |
+
'item_id' => $post_id,
|
56 |
+
'user_id' => $post_author_id,
|
57 |
+
'component_name' => $this->component_id,
|
58 |
+
'component_action' => $this->component_action . $post_id,
|
59 |
+
'secondary_item_id' => $user_id,
|
60 |
+
'date_notified' => bp_core_current_time(),
|
61 |
+
);
|
|
|
|
|
62 |
|
63 |
+
if ( isset( $rtmedia->options['buddypress_enableNotification'] ) && 0 !== intval( $rtmedia->options['buddypress_enableNotification'] ) ) {
|
64 |
+
return bp_notifications_add_notification( $args_add_noification );
|
65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* mark related notification as read once media is visit by user
|
72 |
+
*
|
73 |
+
* @param int $media_id ID of media to mark notification as read
|
74 |
+
*/
|
75 |
+
function mark_notification_unread( $media_id ) {
|
76 |
+
$post_id = rtmedia_media_id( $media_id );
|
77 |
+
$user_id = get_current_user_id();
|
78 |
+
bp_notifications_mark_notifications_by_type( $user_id, $this->component_id, $this->component_action . $post_id, $is_new = false );
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* deletes existing media notification of a perticular user
|
83 |
+
*
|
84 |
+
* @param int $post_author_id Author of post
|
85 |
+
* @param int $post_id ID of a post to delete related notification
|
86 |
+
*/
|
87 |
+
function delete_notification_by_item_id( $post_author_id, $post_id ) {
|
88 |
+
bp_notifications_delete_notifications_by_item_id( $post_author_id, $post_id, $this->component_id, $this->component_action . $post_id );
|
89 |
+
}
|
90 |
}
|
app/helper/RTMediaSettings.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
7 |
* @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
|
8 |
*/
|
9 |
-
if ( ! class_exists( 'RTMediaSettings' ) ){
|
10 |
|
11 |
class RTMediaSettings {
|
12 |
|
@@ -16,10 +16,13 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
16 |
* @access public
|
17 |
* @return void
|
18 |
*/
|
19 |
-
public function __construct(){
|
20 |
-
|
|
|
21 |
add_action( 'admin_init', array( $this, 'settings' ) );
|
22 |
-
|
|
|
|
|
23 |
add_action( 'init', array( $this, 'settings' ) );
|
24 |
}
|
25 |
}
|
@@ -35,29 +38,29 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
35 |
*
|
36 |
* @return array $defaults
|
37 |
*/
|
38 |
-
public function get_default_options(){
|
39 |
global $rtmedia;
|
40 |
$options = $rtmedia->options;
|
41 |
|
42 |
$defaults = array(
|
43 |
-
'general_enableAlbums'
|
44 |
-
'general_enableComments'
|
45 |
-
'general_downloadButton'
|
46 |
-
'general_enableLightbox'
|
47 |
-
'general_perPageMedia'
|
48 |
-
'general_display_media'
|
49 |
'general_enableMediaEndPoint' => 0,
|
50 |
-
'general_showAdminMenu'
|
51 |
-
'general_videothumbs'
|
52 |
-
|
53 |
-
'general_uniqueviewcount'
|
54 |
-
'general_viewcount'
|
55 |
-
'general_AllowUserData'
|
56 |
-
'rtmedia_add_linkback'
|
57 |
-
'rtmedia_affiliate_id'
|
58 |
-
'rtmedia_enable_api'
|
59 |
-
'general_masonry_layout'
|
60 |
-
|
61 |
);
|
62 |
|
63 |
foreach ( $rtmedia->allowed_types as $type ) {
|
@@ -67,9 +70,9 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
67 |
}
|
68 |
|
69 |
/* Previous Sizes values from buddypress is migrated */
|
70 |
-
foreach ( $rtmedia->default_sizes as $type => $
|
71 |
-
foreach ( $
|
72 |
-
foreach ( $
|
73 |
$defaults[ 'defaultSizes_' . $type . '_' . $size . '_' . $dimension ] = 0;
|
74 |
}
|
75 |
}
|
@@ -80,31 +83,31 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
80 |
$defaults['privacy_default'] = 0;
|
81 |
$defaults['privacy_userOverride'] = 0;
|
82 |
|
83 |
-
$defaults['buddypress_enableOnGroup']
|
84 |
-
$defaults['buddypress_enableOnActivity']
|
85 |
-
$defaults['buddypress_enableOnProfile']
|
86 |
-
$defaults['buddypress_limitOnActivity']
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
$defaults['styles_custom']
|
91 |
-
$defaults['styles_enabled']
|
92 |
-
|
93 |
-
if ( isset( $options['general_videothumbs'] ) && is_numeric( $options['general_videothumbs'] ) && intval( $options['general_videothumbs'] ) > 10 ){
|
94 |
$defaults['general_videothumbs'] = 10;
|
95 |
}
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
$defaults = apply_filters( 'rtmedia_general_content_default_values', $defaults );
|
110 |
|
@@ -120,7 +123,7 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
120 |
*
|
121 |
* @return type $options
|
122 |
*/
|
123 |
-
public function sanitize_options( $options ){
|
124 |
$defaults = $this->get_default_options();
|
125 |
$options = wp_parse_args( $options, $defaults );
|
126 |
|
@@ -136,33 +139,33 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
136 |
*
|
137 |
* @return type $options
|
138 |
*/
|
139 |
-
public function sanitize_before_save_options( $options ){
|
140 |
$defaults = $this->get_default_options();
|
141 |
|
142 |
foreach ( $defaults as $key => $value ) {
|
143 |
-
if ( ! isset( $options[ $key ] ) ){
|
144 |
$options[ $key ] = '0';
|
145 |
}
|
146 |
}
|
147 |
|
148 |
-
if ( isset( $options['general_videothumbs'] ) && intval( $options['general_videothumbs'] ) > 10 ){
|
149 |
$options['general_videothumbs'] = 10;
|
150 |
}
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
$options['general_videothumbs'] = 2;
|
155 |
}
|
156 |
|
157 |
// Checking if number of media perpage is integer or not
|
158 |
-
if( isset( $options[
|
159 |
-
if( $options[
|
160 |
-
$options[
|
161 |
-
} else if( !is_int( $options[
|
162 |
-
$options[
|
163 |
}
|
164 |
}
|
165 |
-
|
166 |
return $options;
|
167 |
}
|
168 |
|
@@ -176,51 +179,56 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
176 |
*
|
177 |
* @return void
|
178 |
*/
|
179 |
-
public function settings(){
|
|
|
180 |
global $rtmedia, $rtmedia_addon, $rtmedia_save_setting_single;
|
181 |
$options = rtmedia_get_site_option( 'rtmedia-options' );
|
182 |
$options = $this->sanitize_options( $options );
|
183 |
$rtmedia->options = $options;
|
184 |
// Save Settings first then proceed.
|
185 |
-
|
186 |
-
|
|
|
187 |
$options = $this->sanitize_before_save_options( $options );
|
188 |
$options = apply_filters( 'rtmedia_pro_options_save_settings', $options );
|
189 |
$is_rewrite_rule_flush = apply_filters( 'rtmedia_flush_rewrite_rule', false );
|
190 |
rtmedia_update_site_option( 'rtmedia-options', $options );
|
191 |
do_action( 'rtmedia_save_admin_settings', $options );
|
192 |
-
if ( $is_rewrite_rule_flush ){
|
193 |
flush_rewrite_rules( false );
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
201 |
}
|
202 |
global $rtmedia;
|
203 |
$rtmedia->options = $options;
|
204 |
}
|
205 |
|
206 |
-
if ( function_exists( 'add_settings_section' ) ){
|
207 |
$rtmedia_addon = new RTMediaAddon();
|
208 |
-
add_settings_section( 'rtm-addons',
|
|
|
|
|
|
|
209 |
$rtmedia_support = new RTMediaSupport( false );
|
210 |
-
add_settings_section( 'rtm-support',
|
|
|
|
|
|
|
211 |
$rtmedia_themes = new RTMediaThemes();
|
212 |
-
add_settings_section( 'rtm-themes',
|
|
|
|
|
|
|
213 |
}
|
214 |
|
215 |
-
|
216 |
-
// $rtmedia_privacy = new BPMediaPrivacySettings();
|
217 |
-
// add_filter('rtmedia_add_sub_tabs', array($rtmedia_privacy, 'ui'), 99, 2);
|
218 |
-
// add_settings_section('rtm-privacy', __('Update Database', 'buddypress-media'), array($rtmedia_privacy, 'init'), 'rtmedia-privacy');
|
219 |
-
// }
|
220 |
-
//$rtmedia_album_importer = new BPMediaAlbumimporter();
|
221 |
-
//add_settings_section('rtm-rt-album-importer', __('BP-Album Importer', 'buddypress-media'), array($rtmedia_album_importer, 'ui'), 'rtmedia-importer');
|
222 |
-
//register_setting('buddypress-media', 'rtmedia_options', array($this, 'sanitize'));
|
223 |
-
if ( ! isset( $rtmedia_save_setting_single ) ){
|
224 |
$rtmedia_save_setting_single = true;
|
225 |
}
|
226 |
}
|
@@ -234,36 +242,36 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
234 |
*
|
235 |
* @return void
|
236 |
*/
|
237 |
-
public function network_notices(){
|
238 |
$flag = 1;
|
239 |
-
if ( rtmedia_get_site_option( 'rtm-media-enable', false ) ){
|
240 |
-
echo '<div id="setting-error-bpm-media-enable" class="error"><p><strong>' . rtmedia_get_site_option( 'rtm-media-enable' ) . '</strong></p></div>';
|
241 |
delete_site_option( 'rtm-media-enable' );
|
242 |
$flag = 0;
|
243 |
}
|
244 |
-
if ( rtmedia_get_site_option( 'rtm-media-type', false ) ){
|
245 |
-
echo '<div id="setting-error-bpm-media-type" class="error"><p><strong>' . rtmedia_get_site_option( 'rtm-media-type' ) . '</strong></p></div>';
|
246 |
delete_site_option( 'rtm-media-type' );
|
247 |
$flag = 0;
|
248 |
}
|
249 |
-
if ( rtmedia_get_site_option( 'rtm-media-default-count', false ) ){
|
250 |
-
echo '<div id="setting-error-bpm-media-default-count" class="error"><p><strong>' . rtmedia_get_site_option( 'rtm-media-default-count' ) . '</strong></p></div>';
|
251 |
delete_site_option( 'rtm-media-default-count' );
|
252 |
$flag = 0;
|
253 |
}
|
254 |
|
255 |
-
if ( rtmedia_get_site_option( 'rtm-recount-success', false ) ){
|
256 |
-
echo '<div id="setting-error-bpm-recount-success" class="updated"><p><strong>' . rtmedia_get_site_option( 'rtm-recount-success' ) . '</strong></p></div>';
|
257 |
delete_site_option( 'rtm-recount-success' );
|
258 |
$flag = 0;
|
259 |
} elseif ( rtmedia_get_site_option( 'rtm-recount-fail', false ) ) {
|
260 |
-
echo '<div id="setting-error-bpm-recount-fail" class="error"><p><strong>' . rtmedia_get_site_option( 'rtm-recount-fail' ) . '</strong></p></div>';
|
261 |
delete_site_option( 'rtm-recount-fail' );
|
262 |
$flag = 0;
|
263 |
}
|
264 |
|
265 |
-
if ( get_site_option( 'rtm-settings-saved' ) && $flag ){
|
266 |
-
echo '<div id="setting-error-bpm-settings-saved" class="updated"><p><strong>' . get_site_option( 'rtm-settings-saved' ) . '</strong></p></div>';
|
267 |
}
|
268 |
|
269 |
delete_site_option( 'rtm-settings-saved' );
|
@@ -278,11 +286,16 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
278 |
*
|
279 |
* @return void
|
280 |
*/
|
281 |
-
public function allowed_types(){
|
282 |
$allowed_types = rtmedia_get_site_option( 'upload_filetypes', 'jpg jpeg png gif' );
|
283 |
$allowed_types = explode( ' ', $allowed_types );
|
284 |
$allowed_types = implode( ', ', $allowed_types );
|
285 |
-
echo '<span class="description">' .
|
|
|
|
|
|
|
|
|
|
|
286 |
}
|
287 |
|
288 |
/**
|
@@ -295,53 +308,32 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
295 |
*
|
296 |
* @return type $input
|
297 |
*/
|
298 |
-
public function sanitize( $input ){
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
} else {
|
305 |
-
add_settings_error( __( 'Recount Success', 'buddypress-media' ), 'rtm-recount-success', __( 'Recounting of media files done successfully', 'buddypress-media' ), 'updated' );
|
306 |
-
}
|
307 |
-
} else {
|
308 |
-
if ( is_multisite() ){
|
309 |
-
rtmedia_update_site_option( 'rtm-recount-fail', __( 'Recounting Failed', 'buddypress-media' ) );
|
310 |
-
} else {
|
311 |
-
add_settings_error( __( 'Recount Fail', 'buddypress-media' ), 'rtm-recount-fail', __( 'Recounting Failed', 'buddypress-media' ) );
|
312 |
-
}
|
313 |
-
}
|
314 |
-
}
|
315 |
-
// if (!isset($_POST['rtmedia_options']['enable_on_profile']) && !isset($_POST['rtmedia_options']['enable_on_group'])) {
|
316 |
-
// if (is_multisite())
|
317 |
-
// update_site_option('rtm-media-enable', __('Enable BuddyPress Media on either User Profiles or Groups or both. Atleast one should be selected.', 'buddypress-media'));
|
318 |
-
// else
|
319 |
-
// add_settings_error(__('Enable BuddyPress Media', 'buddypress-media'), 'rtm-media-enable', __('Enable BuddyPress Media on either User Profiles or Groups or both. Atleast one should be selected.', 'buddypress-media'));
|
320 |
-
// $input['enable_on_profile'] = 1;
|
321 |
-
// }
|
322 |
-
if ( ! isset( $_POST['rtmedia_options']['videos_enabled'] ) && ! isset( $_POST['rtmedia_options']['audio_enabled'] ) && ! isset( $_POST['rtmedia_options']['images_enabled'] ) ){
|
323 |
-
if ( is_multisite() ){
|
324 |
-
rtmedia_update_site_option( 'rtm-media-type', __( 'Atleast one Media Type Must be selected', 'buddypress-media' ) );
|
325 |
} else {
|
326 |
-
add_settings_error(
|
327 |
}
|
328 |
$input['images_enabled'] = 1;
|
329 |
}
|
330 |
|
331 |
-
$input['default_count'] = intval( $
|
332 |
|
333 |
-
if ( ! is_int( $input['default_count'] ) || ( $input['default_count'] < 0 ) || empty( $input['default_count'] ) ){
|
334 |
-
if ( is_multisite() ){
|
335 |
-
rtmedia_update_site_option( 'rtm-media-default-count',
|
336 |
} else {
|
337 |
-
add_settings_error(
|
338 |
}
|
339 |
$input['default_count'] = 10;
|
340 |
}
|
341 |
-
if ( is_multisite() ){
|
342 |
-
rtmedia_update_site_option( 'rtm-settings-saved',
|
343 |
}
|
344 |
-
do_action( 'rtmedia_sanitize_settings', $_POST, $input );
|
345 |
|
346 |
return $input;
|
347 |
}
|
@@ -355,15 +347,18 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
355 |
*
|
356 |
* @return void
|
357 |
*/
|
358 |
-
public function image_settings_intro(){
|
359 |
-
if ( is_plugin_active( 'regenerate-thumbnails/regenerate-thumbnails.php' ) ){
|
360 |
$regenerate_link = admin_url( '/tools.php?page=regenerate-thumbnails' );
|
361 |
-
}
|
362 |
$regenerate_link = admin_url( '/plugins.php#regenerate-thumbnails' );
|
363 |
} else {
|
364 |
$regenerate_link = wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=regenerate-thumbnails' ), 'install-plugin_regenerate-thumbnails' );
|
365 |
}
|
366 |
-
echo '<span class="description">' .
|
|
|
|
|
|
|
367 |
echo '<div class="clearfix"> </div>';
|
368 |
}
|
369 |
|
@@ -376,18 +371,17 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
376 |
*
|
377 |
* @return string $notice
|
378 |
*/
|
379 |
-
public function privacy_notice(){
|
380 |
-
if ( current_user_can( 'create_users' ) ){
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
echo $notice;
|
391 |
}
|
392 |
}
|
393 |
|
@@ -400,11 +394,14 @@ if ( ! class_exists( 'RTMediaSettings' ) ){
|
|
400 |
*
|
401 |
* @return void
|
402 |
*/
|
403 |
-
public function rtmedia_support_intro(){
|
404 |
-
echo '<p>' .
|
405 |
-
|
|
|
|
|
|
|
|
|
406 |
}
|
407 |
-
|
408 |
}
|
409 |
|
410 |
}
|
6 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
7 |
* @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
|
8 |
*/
|
9 |
+
if ( ! class_exists( 'RTMediaSettings' ) ) {
|
10 |
|
11 |
class RTMediaSettings {
|
12 |
|
16 |
* @access public
|
17 |
* @return void
|
18 |
*/
|
19 |
+
public function __construct() {
|
20 |
+
//todo: nonce required
|
21 |
+
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
22 |
add_action( 'admin_init', array( $this, 'settings' ) );
|
23 |
+
|
24 |
+
$rtmedia_option_save = filter_input( INPUT_POST, 'rtmedia-options-save', FILTER_SANITIZE_STRING );
|
25 |
+
if ( isset( $rtmedia_option_save ) ) {
|
26 |
add_action( 'init', array( $this, 'settings' ) );
|
27 |
}
|
28 |
}
|
38 |
*
|
39 |
* @return array $defaults
|
40 |
*/
|
41 |
+
public function get_default_options() {
|
42 |
global $rtmedia;
|
43 |
$options = $rtmedia->options;
|
44 |
|
45 |
$defaults = array(
|
46 |
+
'general_enableAlbums' => 1,
|
47 |
+
'general_enableComments' => 0,
|
48 |
+
'general_downloadButton' => 0,
|
49 |
+
'general_enableLightbox' => 1,
|
50 |
+
'general_perPageMedia' => 10,
|
51 |
+
'general_display_media' => 'load_more',
|
52 |
'general_enableMediaEndPoint' => 0,
|
53 |
+
'general_showAdminMenu' => 0,
|
54 |
+
'general_videothumbs' => 2,
|
55 |
+
'general_jpeg_image_quality' => 90,
|
56 |
+
'general_uniqueviewcount' => 0,
|
57 |
+
'general_viewcount' => 0,
|
58 |
+
'general_AllowUserData' => 1,
|
59 |
+
'rtmedia_add_linkback' => 0,
|
60 |
+
'rtmedia_affiliate_id' => '',
|
61 |
+
'rtmedia_enable_api' => 0,
|
62 |
+
'general_masonry_layout' => 0,
|
63 |
+
'general_direct_upload' => 0,
|
64 |
);
|
65 |
|
66 |
foreach ( $rtmedia->allowed_types as $type ) {
|
70 |
}
|
71 |
|
72 |
/* Previous Sizes values from buddypress is migrated */
|
73 |
+
foreach ( $rtmedia->default_sizes as $type => $type_value ) {
|
74 |
+
foreach ( $type_value as $size => $size_value ) {
|
75 |
+
foreach ( $size_value as $dimension => $value ) {
|
76 |
$defaults[ 'defaultSizes_' . $type . '_' . $size . '_' . $dimension ] = 0;
|
77 |
}
|
78 |
}
|
83 |
$defaults['privacy_default'] = 0;
|
84 |
$defaults['privacy_userOverride'] = 0;
|
85 |
|
86 |
+
$defaults['buddypress_enableOnGroup'] = 1;
|
87 |
+
$defaults['buddypress_enableOnActivity'] = 1;
|
88 |
+
$defaults['buddypress_enableOnProfile'] = 1;
|
89 |
+
$defaults['buddypress_limitOnActivity'] = 0;
|
90 |
+
$defaults['buddypress_enableNotification'] = 0;
|
91 |
+
$defaults['buddypress_mediaLikeActivity'] = 0;
|
92 |
+
$defaults['buddypress_mediaCommentActivity'] = 0;
|
93 |
+
$defaults['styles_custom'] = '';
|
94 |
+
$defaults['styles_enabled'] = 1;
|
95 |
+
|
96 |
+
if ( isset( $options['general_videothumbs'] ) && is_numeric( $options['general_videothumbs'] ) && intval( $options['general_videothumbs'] ) > 10 ) {
|
97 |
$defaults['general_videothumbs'] = 10;
|
98 |
}
|
99 |
+
|
100 |
+
if ( isset( $options['general_jpeg_image_quality'] ) ) {
|
101 |
+
if ( is_numeric( $options['general_jpeg_image_quality'] ) ) {
|
102 |
+
if ( $options['general_jpeg_image_quality'] > 100 ) {
|
103 |
+
$defaults['general_jpeg_image_quality'] = 100;
|
104 |
+
} else if ( $options['general_jpeg_image_quality'] < 1 ) {
|
105 |
+
$defaults['general_jpeg_image_quality'] = 90;
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
$defaults['general_jpeg_image_quality'] = 90;
|
109 |
+
}
|
110 |
+
}
|
111 |
|
112 |
$defaults = apply_filters( 'rtmedia_general_content_default_values', $defaults );
|
113 |
|
123 |
*
|
124 |
* @return type $options
|
125 |
*/
|
126 |
+
public function sanitize_options( $options ) {
|
127 |
$defaults = $this->get_default_options();
|
128 |
$options = wp_parse_args( $options, $defaults );
|
129 |
|
139 |
*
|
140 |
* @return type $options
|
141 |
*/
|
142 |
+
public function sanitize_before_save_options( $options ) {
|
143 |
$defaults = $this->get_default_options();
|
144 |
|
145 |
foreach ( $defaults as $key => $value ) {
|
146 |
+
if ( ! isset( $options[ $key ] ) ) {
|
147 |
$options[ $key ] = '0';
|
148 |
}
|
149 |
}
|
150 |
|
151 |
+
if ( isset( $options['general_videothumbs'] ) && intval( $options['general_videothumbs'] ) > 10 ) {
|
152 |
$options['general_videothumbs'] = 10;
|
153 |
}
|
154 |
+
|
155 |
+
// Checking if video_thumbnails value is less then 0
|
156 |
+
if ( isset( $options['general_videothumbs'] ) && intval( $options['general_videothumbs'] ) <= 0 ) {
|
157 |
$options['general_videothumbs'] = 2;
|
158 |
}
|
159 |
|
160 |
// Checking if number of media perpage is integer or not
|
161 |
+
if ( isset( $options['general_perPageMedia'] ) ) {
|
162 |
+
if ( intval( $options['general_perPageMedia'] ) < 1 ) {
|
163 |
+
$options['general_perPageMedia'] = 10;
|
164 |
+
} else if ( ! is_int( $options['general_perPageMedia'] ) ) {
|
165 |
+
$options['general_perPageMedia'] = round( $options['general_perPageMedia'] );
|
166 |
}
|
167 |
}
|
168 |
+
|
169 |
return $options;
|
170 |
}
|
171 |
|
179 |
*
|
180 |
* @return void
|
181 |
*/
|
182 |
+
public function settings() {
|
183 |
+
//todo: nonce required
|
184 |
global $rtmedia, $rtmedia_addon, $rtmedia_save_setting_single;
|
185 |
$options = rtmedia_get_site_option( 'rtmedia-options' );
|
186 |
$options = $this->sanitize_options( $options );
|
187 |
$rtmedia->options = $options;
|
188 |
// Save Settings first then proceed.
|
189 |
+
$rtmedia_option_save = filter_input( INPUT_POST, 'rtmedia-options-save', FILTER_SANITIZE_STRING );
|
190 |
+
if ( isset( $rtmedia_option_save ) ) {
|
191 |
+
$options = filter_input( INPUT_POST, 'rtmedia-options', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
192 |
$options = $this->sanitize_before_save_options( $options );
|
193 |
$options = apply_filters( 'rtmedia_pro_options_save_settings', $options );
|
194 |
$is_rewrite_rule_flush = apply_filters( 'rtmedia_flush_rewrite_rule', false );
|
195 |
rtmedia_update_site_option( 'rtmedia-options', $options );
|
196 |
do_action( 'rtmedia_save_admin_settings', $options );
|
197 |
+
if ( $is_rewrite_rule_flush ) {
|
198 |
flush_rewrite_rules( false );
|
199 |
}
|
200 |
+
$settings_saved = '';
|
201 |
+
$setting_save = filter_input( INPUT_GET, 'settings-saved', FILTER_SANITIZE_STRING );
|
202 |
+
if ( ! isset( $setting_save ) ) {
|
203 |
+
$settings_saved = '&settings-saved=true';
|
204 |
+
}
|
205 |
+
$http_referer = filter_input( INPUT_SERVER, 'HTTP_REFERER', FILTER_SANITIZE_URL );
|
206 |
+
if ( isset( $http_referer ) ) {
|
207 |
+
wp_redirect( $http_referer . $settings_saved );
|
208 |
}
|
209 |
global $rtmedia;
|
210 |
$rtmedia->options = $options;
|
211 |
}
|
212 |
|
213 |
+
if ( function_exists( 'add_settings_section' ) ) {
|
214 |
$rtmedia_addon = new RTMediaAddon();
|
215 |
+
add_settings_section( 'rtm-addons', esc_html__( 'BuddyPress Media Addons for Photos', 'buddypress-media' ), array(
|
216 |
+
$rtmedia_addon,
|
217 |
+
'get_addons',
|
218 |
+
), 'rtmedia-addons' );
|
219 |
$rtmedia_support = new RTMediaSupport( false );
|
220 |
+
add_settings_section( 'rtm-support', esc_html__( 'Support', 'buddypress-media' ), array(
|
221 |
+
$rtmedia_support,
|
222 |
+
'get_support_content',
|
223 |
+
), 'rtmedia-support' );
|
224 |
$rtmedia_themes = new RTMediaThemes();
|
225 |
+
add_settings_section( 'rtm-themes', esc_html__( 'rtMedia Themes', 'buddypress-media' ), array(
|
226 |
+
$rtmedia_themes,
|
227 |
+
'get_themes',
|
228 |
+
), 'rtmedia-themes' );
|
229 |
}
|
230 |
|
231 |
+
if ( ! isset( $rtmedia_save_setting_single ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
$rtmedia_save_setting_single = true;
|
233 |
}
|
234 |
}
|
242 |
*
|
243 |
* @return void
|
244 |
*/
|
245 |
+
public function network_notices() {
|
246 |
$flag = 1;
|
247 |
+
if ( rtmedia_get_site_option( 'rtm-media-enable', false ) ) {
|
248 |
+
echo '<div id="setting-error-bpm-media-enable" class="error"><p><strong>' . esc_html( rtmedia_get_site_option( 'rtm-media-enable' ) ) . '</strong></p></div>';
|
249 |
delete_site_option( 'rtm-media-enable' );
|
250 |
$flag = 0;
|
251 |
}
|
252 |
+
if ( rtmedia_get_site_option( 'rtm-media-type', false ) ) {
|
253 |
+
echo '<div id="setting-error-bpm-media-type" class="error"><p><strong>' . esc_html( rtmedia_get_site_option( 'rtm-media-type' ) ) . '</strong></p></div>';
|
254 |
delete_site_option( 'rtm-media-type' );
|
255 |
$flag = 0;
|
256 |
}
|
257 |
+
if ( rtmedia_get_site_option( 'rtm-media-default-count', false ) ) {
|
258 |
+
echo '<div id="setting-error-bpm-media-default-count" class="error"><p><strong>' . esc_html( rtmedia_get_site_option( 'rtm-media-default-count' ) ) . '</strong></p></div>';
|
259 |
delete_site_option( 'rtm-media-default-count' );
|
260 |
$flag = 0;
|
261 |
}
|
262 |
|
263 |
+
if ( rtmedia_get_site_option( 'rtm-recount-success', false ) ) {
|
264 |
+
echo '<div id="setting-error-bpm-recount-success" class="updated"><p><strong>' . esc_html( rtmedia_get_site_option( 'rtm-recount-success' ) ) . '</strong></p></div>';
|
265 |
delete_site_option( 'rtm-recount-success' );
|
266 |
$flag = 0;
|
267 |
} elseif ( rtmedia_get_site_option( 'rtm-recount-fail', false ) ) {
|
268 |
+
echo '<div id="setting-error-bpm-recount-fail" class="error"><p><strong>' . esc_html( rtmedia_get_site_option( 'rtm-recount-fail' ) ) . '</strong></p></div>';
|
269 |
delete_site_option( 'rtm-recount-fail' );
|
270 |
$flag = 0;
|
271 |
}
|
272 |
|
273 |
+
if ( get_site_option( 'rtm-settings-saved' ) && $flag ) {
|
274 |
+
echo '<div id="setting-error-bpm-settings-saved" class="updated"><p><strong>' . esc_html( get_site_option( 'rtm-settings-saved' ) ) . '</strong></p></div>';
|
275 |
}
|
276 |
|
277 |
delete_site_option( 'rtm-settings-saved' );
|
286 |
*
|
287 |
* @return void
|
288 |
*/
|
289 |
+
public function allowed_types() {
|
290 |
$allowed_types = rtmedia_get_site_option( 'upload_filetypes', 'jpg jpeg png gif' );
|
291 |
$allowed_types = explode( ' ', $allowed_types );
|
292 |
$allowed_types = implode( ', ', $allowed_types );
|
293 |
+
echo '<span class="description">' .
|
294 |
+
sprintf(
|
295 |
+
esc_html__( 'Currently your network allows uploading of the following file types. You can change the settings %s', 'buddypress-media' ),
|
296 |
+
'<a href="' . esc_url( network_admin_url( 'settings.php#upload_filetypes' ) ) . '">' . esc_html__( 'here', 'buddypress-media' ) . '</a><br /><code>' . esc_html( $allowed_types ) . '</code>'
|
297 |
+
) .
|
298 |
+
'</span>';
|
299 |
}
|
300 |
|
301 |
/**
|
308 |
*
|
309 |
* @return type $input
|
310 |
*/
|
311 |
+
public function sanitize( $input ) {
|
312 |
+
$rtmedia_options = filter_input( INPUT_POST, 'rtmedia-options', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
313 |
+
|
314 |
+
if ( ! isset( $rtmedia_options['videos_enabled'] ) && ! isset( $rtmedia_options['audio_enabled'] ) && ! isset( $rtmedia_options['images_enabled'] ) ) {
|
315 |
+
if ( is_multisite() ) {
|
316 |
+
rtmedia_update_site_option( 'rtm-media-type', esc_html__( 'Atleast one Media Type Must be selected', 'buddypress-media' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
} else {
|
318 |
+
add_settings_error( esc_html__( 'Media Type', 'buddypress-media' ), 'rtm-media-type', esc_html__( 'Atleast one Media Type Must be selected', 'buddypress-media' ) );
|
319 |
}
|
320 |
$input['images_enabled'] = 1;
|
321 |
}
|
322 |
|
323 |
+
$input['default_count'] = intval( $rtmedia_options['default_count'] );
|
324 |
|
325 |
+
if ( ! is_int( $input['default_count'] ) || ( $input['default_count'] < 0 ) || empty( $input['default_count'] ) ) {
|
326 |
+
if ( is_multisite() ) {
|
327 |
+
rtmedia_update_site_option( 'rtm-media-default-count', esc_html__( '"Number of media" count value should be numeric and greater than 0.', 'buddypress-media' ) );
|
328 |
} else {
|
329 |
+
add_settings_error( esc_html__( 'Default Count', 'buddypress-media' ), 'rtm-media-default-count', esc_html__( '"Number of media" count value should be numeric and greater than 0.', 'buddypress-media' ) );
|
330 |
}
|
331 |
$input['default_count'] = 10;
|
332 |
}
|
333 |
+
if ( is_multisite() ) {
|
334 |
+
rtmedia_update_site_option( 'rtm-settings-saved', esc_html__( 'Settings saved.', 'buddypress-media' ) );
|
335 |
}
|
336 |
+
do_action( 'rtmedia_sanitize_settings', $_POST, $input ); // @codingStandardsIgnoreLine
|
337 |
|
338 |
return $input;
|
339 |
}
|
347 |
*
|
348 |
* @return void
|
349 |
*/
|
350 |
+
public function image_settings_intro() {
|
351 |
+
if ( is_plugin_active( 'regenerate-thumbnails/regenerate-thumbnails.php' ) ) {
|
352 |
$regenerate_link = admin_url( '/tools.php?page=regenerate-thumbnails' );
|
353 |
+
} else if ( array_key_exists( 'regenerate-thumbnails/regenerate-thumbnails.php', get_plugins() ) ) {
|
354 |
$regenerate_link = admin_url( '/plugins.php#regenerate-thumbnails' );
|
355 |
} else {
|
356 |
$regenerate_link = wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=regenerate-thumbnails' ), 'install-plugin_regenerate-thumbnails' );
|
357 |
}
|
358 |
+
echo '<span class="description">' . esc_html__( 'If you make changes to width, height or crop settings, you must use ', 'buddypress-media' ).
|
359 |
+
'<a href="' . esc_url( $regenerate_link ) . '">' . esc_html__( 'Regenerate Thumbnail Plugin', 'buddypress-media' ) . '</a>' .
|
360 |
+
esc_html__( ' to regenerate old images.', 'buddypress-media' ) .
|
361 |
+
'</span>';
|
362 |
echo '<div class="clearfix"> </div>';
|
363 |
}
|
364 |
|
371 |
*
|
372 |
* @return string $notice
|
373 |
*/
|
374 |
+
public function privacy_notice() {
|
375 |
+
if ( current_user_can( 'create_users' ) ) {
|
376 |
+
$url = add_query_arg(
|
377 |
+
array(
|
378 |
+
'page' => 'rtmedia-privacy',
|
379 |
+
),
|
380 |
+
( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) )
|
381 |
+
);
|
382 |
+
|
383 |
+
echo '<div class="error"><p>' . esc_html__( 'BuddyPress Media 2.6 requires a database upgrade. ', 'buddypress-media' ) .
|
384 |
+
'<a href="' . esc_url( $url ) . '">' . esc_html__( 'Update Database', 'buddypress-media' ) . '.</a></p></div>';
|
|
|
385 |
}
|
386 |
}
|
387 |
|
394 |
*
|
395 |
* @return void
|
396 |
*/
|
397 |
+
public function rtmedia_support_intro() {
|
398 |
+
echo '<p>' . esc_html__( 'If your site has some issues due to rtMedia and you want one on one support then you can create a support topic on the ', 'buddypress-media' ) .
|
399 |
+
'<a target="_blank" href="http://community.rtcamp.com/c/rtmedia?utm_source=dashboard&utm_medium=plugin&utm_campaign=rtmedia">' . esc_html__( 'rtMedia Support Forum', 'buddypress-media' ) . '</a>.' .
|
400 |
+
'</p>';
|
401 |
+
echo '<p>' . esc_html__( 'If you have any suggestions, enhancements or bug reports, then you can open a new issue on ', 'buddypress-media' ) .
|
402 |
+
'<a target="_blank" href="https://github.com/rtCamp/rtmedia/issues/new">' . esc_html__( 'GitHub', 'buddypress-media' ) . '</a>.' .
|
403 |
+
'</p>';
|
404 |
}
|
|
|
405 |
}
|
406 |
|
407 |
}
|
app/helper/RTMediaSupport.php
CHANGED
@@ -30,8 +30,9 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
30 |
}
|
31 |
|
32 |
$this->curr_sub_tab = 'support';
|
33 |
-
|
34 |
-
|
|
|
35 |
}
|
36 |
}
|
37 |
|
@@ -48,24 +49,26 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
48 |
$tabs = array();
|
49 |
global $rtmedia_admin;
|
50 |
$tabs[] = array(
|
51 |
-
'title'
|
52 |
-
'name'
|
53 |
-
'href'
|
54 |
-
'icon'
|
55 |
'callback' => array( $this, 'call_get_form' ),
|
56 |
);
|
57 |
$tabs[] = array(
|
58 |
-
'title'
|
59 |
-
'name'
|
60 |
-
'href'
|
61 |
-
'icon'
|
62 |
'callback' => array( $this, 'debug_info_html' ),
|
63 |
);
|
64 |
-
|
|
|
|
|
65 |
$tabs[] = array(
|
66 |
-
'title'
|
67 |
-
'name'
|
68 |
-
'href'
|
69 |
'callback' => array( $this, 'migration_html' ),
|
70 |
);
|
71 |
}
|
@@ -95,18 +98,18 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
95 |
return;
|
96 |
}
|
97 |
|
98 |
-
foreach ( (
|
99 |
|
100 |
-
if ( $section[
|
101 |
-
call_user_func( $section[
|
102 |
}
|
103 |
|
104 |
-
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section[
|
105 |
continue;
|
106 |
}
|
107 |
|
108 |
echo '<table class="form-table">';
|
109 |
-
do_settings_fields( $page, $section[
|
110 |
echo '</table>';
|
111 |
}
|
112 |
}
|
@@ -121,32 +124,35 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
121 |
* @return void
|
122 |
*/
|
123 |
public function service_selector() {
|
124 |
-
|
|
|
125 |
<div>
|
126 |
<form name="rtmedia_service_select_form" method="post">
|
127 |
<p>
|
128 |
-
<label class="bp-media-label"
|
|
|
129 |
<select name="rtmedia_service_select">
|
130 |
<option
|
131 |
value="premium_support" <?php
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
<option
|
137 |
value="bug_report" <?php
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
<option
|
143 |
value="new_feature" <?php
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
</select>
|
149 |
-
<input name="support_submit" value="<?php esc_attr_e( 'Submit', 'buddypress-media' ); ?>"
|
|
|
150 |
</p>
|
151 |
</form>
|
152 |
</div>
|
@@ -163,9 +169,9 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
163 |
* @return void
|
164 |
*/
|
165 |
public function call_get_form( $page = '' ) {
|
166 |
-
|
167 |
-
|
168 |
-
if ( 'support'
|
169 |
echo "<div id='rtmedia_service_contact_container' class='rtm-support-container'><form name='rtmedia_service_contact_detail' method='post'>";
|
170 |
$this->get_form( 'premium_support' );
|
171 |
echo '</form></div>';
|
@@ -183,19 +189,19 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
183 |
* @return array $rtmedia_plugins
|
184 |
*/
|
185 |
public function get_plugin_info() {
|
186 |
-
$active_plugins = (
|
187 |
if ( is_multisite() ) {
|
188 |
$active_plugins = array_merge( $active_plugins, rtmedia_get_site_option( 'active_sitewide_plugins', array() ) );
|
189 |
}
|
190 |
$rtmedia_plugins = array();
|
191 |
foreach ( $active_plugins as $plugin ) {
|
192 |
-
$plugin_data
|
193 |
$version_string = '';
|
194 |
-
if ( ! empty( $plugin_data[
|
195 |
-
$rtmedia_plugins[] = $plugin_data[
|
196 |
}
|
197 |
}
|
198 |
-
if ( 0
|
199 |
return false;
|
200 |
} else {
|
201 |
return implode( ', <br/>', $rtmedia_plugins );
|
@@ -212,18 +218,18 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
212 |
* @return array $result
|
213 |
*/
|
214 |
public function rtmedia_scan_template_files( $template_path ) {
|
215 |
-
$files
|
216 |
$result = array();
|
217 |
if ( $files ) {
|
218 |
foreach ( $files as $key => $value ) {
|
219 |
-
if ( ! in_array( $value, array( '.', '..' ) ) ) {
|
220 |
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
221 |
$sub_files = $this->rtmedia_scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
222 |
foreach ( $sub_files as $sub_file ) {
|
223 |
-
$result[] = str_replace( ABSPATH . 'wp-content/', '', RTMediaTemplate::locate_template( substr( $sub_file, 0, (
|
224 |
}
|
225 |
} else {
|
226 |
-
if ( 'main.php'
|
227 |
$result[] = $value;
|
228 |
}
|
229 |
}
|
@@ -245,42 +251,41 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
245 |
*/
|
246 |
public function debug_info() {
|
247 |
global $wpdb, $wp_version, $bp;
|
248 |
-
$debug_info
|
249 |
-
$debug_info[
|
250 |
-
$debug_info[
|
251 |
-
$debug_info[
|
252 |
-
$debug_info[
|
253 |
-
$debug_info[
|
254 |
-
$debug_info[
|
255 |
-
$debug_info[
|
256 |
-
$debug_info[
|
257 |
if ( extension_loaded( 'imagick' ) ) {
|
258 |
$imagickobj = new Imagick();
|
259 |
-
|
260 |
} else {
|
261 |
-
$imagick[
|
262 |
}
|
263 |
-
$debug_info[
|
264 |
if ( extension_loaded( 'gd' ) ) {
|
265 |
$gd = gd_info();
|
266 |
} else {
|
267 |
-
$gd[
|
268 |
}
|
269 |
-
$debug_info[
|
270 |
-
$debug_info[
|
271 |
-
$debug_info[
|
272 |
-
$debug_info[
|
273 |
-
$debug_info[
|
274 |
-
$active_theme
|
275 |
-
$debug_info[
|
276 |
-
$debug_info[
|
277 |
-
$debug_info[
|
278 |
-
$debug_info[
|
279 |
|
280 |
-
$rtMedia_model = new RTMediaModel();
|
281 |
-
$sql = "select media_type, count(id) as count from {$rtMedia_model->table_name} where blog_id = '" . get_current_blog_id() . "' group by media_type";
|
282 |
global $wpdb;
|
283 |
-
$
|
|
|
284 |
if ( $results ) {
|
285 |
foreach ( $results as $media ) {
|
286 |
$debug_info[ 'Total ' . ucfirst( $media->media_type ) . 's' ] = $media->count;
|
@@ -302,22 +307,22 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
302 |
$this->debug_info();
|
303 |
?>
|
304 |
<div id="debug-info" class="rtm-option-wrapper">
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
?>
|
312 |
-
<tr>
|
313 |
-
<th scope="row"><?php echo $configuration; ?></th>
|
314 |
-
<td><?php echo $value; ?></td>
|
315 |
-
</tr><?php
|
316 |
-
}
|
317 |
-
}
|
318 |
?>
|
319 |
-
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
</div><?php
|
322 |
}
|
323 |
|
@@ -332,7 +337,7 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
332 |
*/
|
333 |
public function is_migration_required() {
|
334 |
$pending_rtmedia_migrate = rtmedia_get_site_option( 'rtMigration-pending-count' );
|
335 |
-
if ( ( false === $pending_rtmedia_migrate || 0
|
336 |
return false;
|
337 |
}
|
338 |
|
@@ -352,20 +357,20 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
352 |
$pending_rtmedia_migrate = rtmedia_get_site_option( 'rtMigration-pending-count' );
|
353 |
|
354 |
$content = ' ';
|
355 |
-
$flag
|
356 |
-
if ( ( false === $pending_rtmedia_migrate || 0
|
357 |
-
$content .=
|
358 |
$flag = false;
|
359 |
}
|
360 |
$content = apply_filters( 'rtmedia_migration_content_filter', $content );
|
361 |
if ( $flag ) {
|
362 |
$content .= ' <div class="rtmedia-migration-support">';
|
363 |
-
$content .= ' <p>' .
|
364 |
$content .= '</div>';
|
365 |
}
|
366 |
?>
|
367 |
<div id="rtmedia-migration-html">
|
368 |
-
<?php echo $content; ?>
|
369 |
</div>
|
370 |
<?php
|
371 |
}
|
@@ -373,90 +378,119 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
373 |
/**
|
374 |
* Generate rtmedia admin form.
|
375 |
*
|
376 |
-
* @global type
|
377 |
*
|
378 |
* @param string $form
|
379 |
*
|
380 |
* @return void
|
381 |
*/
|
382 |
public function get_form( $form = '' ) {
|
|
|
383 |
if ( empty( $form ) ) {
|
384 |
-
$form = (
|
385 |
-
|
386 |
-
if ( $form == '' ) {
|
387 |
-
$form = 'premium_support';
|
388 |
}
|
389 |
-
|
390 |
switch ( $form ) {
|
391 |
case 'bug_report':
|
392 |
-
$meta_title =
|
393 |
break;
|
394 |
case 'new_feature':
|
395 |
-
$meta_title =
|
396 |
break;
|
397 |
case 'premium_support':
|
398 |
-
$meta_title =
|
399 |
break;
|
400 |
}
|
401 |
|
402 |
-
if ( 'premium_support'
|
403 |
if ( ! has_filter( 'rtmedia_license_tabs' ) && ! has_action( 'rtmedia_addon_license_details' ) ) {
|
404 |
-
$content = '<h3 class="rtm-option-title">' . $meta_title . '</h3>';
|
405 |
-
$content .= '<p>' .
|
406 |
-
|
407 |
-
|
408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
?>
|
411 |
-
<h3 class="rtm-option-title"><?php echo $meta_title; ?></h3>
|
412 |
<div id="support-form" class="bp-media-form rtm-support-form rtm-option-wrapper">
|
413 |
|
414 |
<div class="rtm-form-filed clearfix">
|
415 |
-
<label class="bp-media-label"
|
416 |
-
|
|
|
417 |
<span class="rtm-tooltip">
|
418 |
<i class="dashicons dashicons-info rtmicon"></i>
|
419 |
<span class="rtm-tip">
|
420 |
-
<?php
|
421 |
</span>
|
422 |
</span>
|
423 |
</div>
|
424 |
|
425 |
<div class="rtm-form-filed clearfix">
|
426 |
-
<label class="bp-media-label"
|
427 |
-
|
|
|
428 |
<span class="rtm-tooltip">
|
429 |
<i class="dashicons dashicons-info rtmicon"></i>
|
430 |
<span class="rtm-tip">
|
431 |
-
<?php
|
432 |
</span>
|
433 |
</span>
|
434 |
</div>
|
435 |
|
436 |
<div class="rtm-form-filed clearfix">
|
437 |
-
<label class="bp-media-label"
|
438 |
-
|
|
|
|
|
|
|
439 |
</div>
|
440 |
|
441 |
<div class="rtm-form-filed clearfix">
|
442 |
-
<label class="bp-media-label"
|
443 |
-
|
|
|
|
|
|
|
444 |
</div>
|
445 |
|
446 |
<div class="rtm-form-filed clearfix">
|
447 |
-
<label class="bp-media-label"
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
<input type="hidden" name="
|
453 |
-
<input type="hidden" name="
|
454 |
-
|
455 |
-
<input type="hidden" name="
|
|
|
|
|
|
|
456 |
</div>
|
457 |
</div><!-- .submit-bug-box -->
|
458 |
|
459 |
<div class="rtm-form-filed rtm-button-wrapper clearfix">
|
|
|
460 |
<?php submit_button( 'Submit', 'primary', 'rtmedia-submit-request', false ); ?>
|
461 |
<?php submit_button( 'Cancel', 'secondary', 'cancel-request', false ); ?>
|
462 |
</div>
|
@@ -476,120 +510,136 @@ if ( ! class_exists( 'RTMediaSupport' ) ) {
|
|
476 |
* @return void
|
477 |
*/
|
478 |
public function submit_request() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
$this->debug_info();
|
480 |
-
|
481 |
-
$form_data = wp_parse_args( $
|
482 |
foreach ( $form_data as $key => $formdata ) {
|
483 |
-
if ( ''
|
484 |
echo 'false';
|
485 |
die();
|
486 |
}
|
487 |
}
|
488 |
-
if ( 'premium_support'
|
489 |
$mail_type = 'Premium Support';
|
490 |
-
$title
|
491 |
-
}
|
492 |
$mail_type = 'New Feature Request';
|
493 |
-
$title
|
494 |
-
}
|
495 |
$mail_type = 'Bug Report';
|
496 |
-
$title
|
497 |
} else {
|
498 |
$mail_type = 'Bug Report';
|
499 |
-
$title
|
500 |
}
|
501 |
$message = '<html>
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
if ( 'bug_report'
|
541 |
$message .= '<tr>
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
}
|
558 |
$message .= '</table>';
|
559 |
if ( $this->debug_info ) {
|
560 |
-
$message .= '<h3>' .
|
561 |
$message .= '<table>';
|
562 |
foreach ( $this->debug_info as $configuration => $value ) {
|
563 |
$message .= '<tr>
|
564 |
-
|
565 |
-
|
566 |
}
|
567 |
$message .= '</table>';
|
568 |
}
|
569 |
$message .= '</body>
|
570 |
-
|
571 |
-
add_filter( 'wp_mail_content_type',
|
572 |
-
|
|
|
573 |
$support_email = 'support@rtcamp.com';
|
574 |
-
if ( wp_mail( $support_email, '[rtmedia] ' . $mail_type . ' from ' . str_replace( array(
|
|
|
|
|
|
|
575 |
echo '<div class="rtmedia-success" style="margin:10px 0;">';
|
576 |
-
if ( 'new_feature'
|
577 |
-
echo '<p>' .
|
578 |
} else {
|
579 |
-
echo '<p>' .
|
580 |
-
echo '<p>' .
|
581 |
}
|
582 |
echo '</div>';
|
583 |
} else {
|
584 |
echo '<div class="rtmedia-error">';
|
585 |
-
echo '<p>' .
|
586 |
-
echo '<p>' .
|
587 |
-
echo '<p>' .
|
|
|
|
|
|
|
|
|
|
|
588 |
echo '</div>';
|
589 |
}
|
590 |
die();
|
591 |
}
|
592 |
-
|
593 |
}
|
594 |
|
595 |
-
}
|
30 |
}
|
31 |
|
32 |
$this->curr_sub_tab = 'support';
|
33 |
+
$tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
|
34 |
+
if ( isset( $tab ) ) {
|
35 |
+
$this->curr_sub_tab = $tab;
|
36 |
}
|
37 |
}
|
38 |
|
49 |
$tabs = array();
|
50 |
global $rtmedia_admin;
|
51 |
$tabs[] = array(
|
52 |
+
'title' => esc_html__( 'Support', 'buddypress-media' ),
|
53 |
+
'name' => esc_html__( 'Support', 'buddypress-media' ),
|
54 |
+
'href' => '#support',
|
55 |
+
'icon' => 'dashicons-businessman',
|
56 |
'callback' => array( $this, 'call_get_form' ),
|
57 |
);
|
58 |
$tabs[] = array(
|
59 |
+
'title' => esc_html__( 'Debug Info', 'buddypress-media' ),
|
60 |
+
'name' => esc_html__( 'Debug Info', 'buddypress-media' ),
|
61 |
+
'href' => '#debug',
|
62 |
+
'icon' => 'dashicons-admin-tools',
|
63 |
'callback' => array( $this, 'debug_info_html' ),
|
64 |
);
|
65 |
+
|
66 |
+
//if any un-migrated media is there
|
67 |
+
if ( $this->is_migration_required() ) {
|
68 |
$tabs[] = array(
|
69 |
+
'title' => esc_html__( 'Migration', 'buddypress-media' ),
|
70 |
+
'name' => esc_html__( 'Migration', 'buddypress-media' ),
|
71 |
+
'href' => '#migration',
|
72 |
'callback' => array( $this, 'migration_html' ),
|
73 |
);
|
74 |
}
|
98 |
return;
|
99 |
}
|
100 |
|
101 |
+
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
|
102 |
|
103 |
+
if ( $section['callback'] ) {
|
104 |
+
call_user_func( $section['callback'], $section );
|
105 |
}
|
106 |
|
107 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
|
108 |
continue;
|
109 |
}
|
110 |
|
111 |
echo '<table class="form-table">';
|
112 |
+
do_settings_fields( $page, $section['id'] );
|
113 |
echo '</table>';
|
114 |
}
|
115 |
}
|
124 |
* @return void
|
125 |
*/
|
126 |
public function service_selector() {
|
127 |
+
//todo: nonce required
|
128 |
+
$form = filter_input( INPUT_POST, 'form', FILTER_SANITIZE_STRING ); ?>
|
129 |
<div>
|
130 |
<form name="rtmedia_service_select_form" method="post">
|
131 |
<p>
|
132 |
+
<label class="bp-media-label"
|
133 |
+
for="select_support"><?php esc_html_e( 'Service', 'buddypress-media' ); ?>:</label>
|
134 |
<select name="rtmedia_service_select">
|
135 |
<option
|
136 |
value="premium_support" <?php
|
137 |
+
if ( 'premium_support' === $form ) {
|
138 |
+
echo 'selected';
|
139 |
+
}
|
140 |
+
?>><?php esc_html_e( 'Premium Support', 'buddypress-media' ); ?></option>
|
141 |
<option
|
142 |
value="bug_report" <?php
|
143 |
+
if ( 'bug_report' === $form ) {
|
144 |
+
echo 'selected';
|
145 |
+
}
|
146 |
+
?>><?php esc_html_e( 'Bug Report', 'buddypress-media' ); ?></option>
|
147 |
<option
|
148 |
value="new_feature" <?php
|
149 |
+
if ( 'new_feature' === $form ) {
|
150 |
+
echo 'selected';
|
151 |
+
}
|
152 |
+
?>><?php esc_html_e( 'New Feature', 'buddypress-media' ); ?></option>
|
153 |
</select>
|
154 |
+
<input name="support_submit" value="<?php esc_attr_e( 'Submit', 'buddypress-media' ); ?>"
|
155 |
+
type="submit" class="button"/>
|
156 |
</p>
|
157 |
</form>
|
158 |
</div>
|
169 |
* @return void
|
170 |
*/
|
171 |
public function call_get_form( $page = '' ) {
|
172 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
173 |
+
if ( isset( $page ) && 'rtmedia-support' === $page ) {
|
174 |
+
if ( 'support' === $this->curr_sub_tab ) {
|
175 |
echo "<div id='rtmedia_service_contact_container' class='rtm-support-container'><form name='rtmedia_service_contact_detail' method='post'>";
|
176 |
$this->get_form( 'premium_support' );
|
177 |
echo '</form></div>';
|
189 |
* @return array $rtmedia_plugins
|
190 |
*/
|
191 |
public function get_plugin_info() {
|
192 |
+
$active_plugins = (array) get_option( 'active_plugins', array() );
|
193 |
if ( is_multisite() ) {
|
194 |
$active_plugins = array_merge( $active_plugins, rtmedia_get_site_option( 'active_sitewide_plugins', array() ) );
|
195 |
}
|
196 |
$rtmedia_plugins = array();
|
197 |
foreach ( $active_plugins as $plugin ) {
|
198 |
+
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
199 |
$version_string = '';
|
200 |
+
if ( ! empty( $plugin_data['Name'] ) ) {
|
201 |
+
$rtmedia_plugins[] = esc_html( $plugin_data['Name'] ) . ' ' . esc_html__( 'by', 'buddypress-media' ) . ' ' . $plugin_data['Author'] . ' ' . esc_html__( 'version', 'buddypress-media' ) . ' ' . $plugin_data['Version'] . $version_string;
|
202 |
}
|
203 |
}
|
204 |
+
if ( 0 === count( $rtmedia_plugins ) ) {
|
205 |
return false;
|
206 |
} else {
|
207 |
return implode( ', <br/>', $rtmedia_plugins );
|
218 |
* @return array $result
|
219 |
*/
|
220 |
public function rtmedia_scan_template_files( $template_path ) {
|
221 |
+
$files = scandir( $template_path );
|
222 |
$result = array();
|
223 |
if ( $files ) {
|
224 |
foreach ( $files as $key => $value ) {
|
225 |
+
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
|
226 |
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
227 |
$sub_files = $this->rtmedia_scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
228 |
foreach ( $sub_files as $sub_file ) {
|
229 |
+
$result[] = str_replace( ABSPATH . 'wp-content/', '', RTMediaTemplate::locate_template( substr( $sub_file, 0, ( count( $sub_file ) - 5 ) ) ) );
|
230 |
}
|
231 |
} else {
|
232 |
+
if ( 'main.php' !== $value ) {
|
233 |
$result[] = $value;
|
234 |
}
|
235 |
}
|
251 |
*/
|
252 |
public function debug_info() {
|
253 |
global $wpdb, $wp_version, $bp;
|
254 |
+
$debug_info = array();
|
255 |
+
$debug_info['Home URL'] = esc_url( home_url() );
|
256 |
+
$debug_info['Site URL'] = esc_url( site_url() );
|
257 |
+
$debug_info['PHP'] = esc_html( PHP_VERSION );
|
258 |
+
$debug_info['MYSQL'] = esc_html( $wpdb->db_version() );
|
259 |
+
$debug_info['WordPress'] = esc_html( $wp_version );
|
260 |
+
$debug_info['BuddyPress'] = esc_html( ( isset( $bp->version ) ) ? $bp->version : '-NA-' );
|
261 |
+
$debug_info['rtMedia'] = esc_html( RTMEDIA_VERSION );
|
262 |
+
$debug_info['OS'] = esc_html( PHP_OS );
|
263 |
if ( extension_loaded( 'imagick' ) ) {
|
264 |
$imagickobj = new Imagick();
|
265 |
+
$imagick = $message = preg_replace( " #((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#i", "'<a href=\"$1\" target=\"_blank\">$3</a>$4'", $imagickobj->getversion() );
|
266 |
} else {
|
267 |
+
$imagick['versionString'] = 'Not Installed';
|
268 |
}
|
269 |
+
$debug_info['Imagick'] = $imagick['versionString'];
|
270 |
if ( extension_loaded( 'gd' ) ) {
|
271 |
$gd = gd_info();
|
272 |
} else {
|
273 |
+
$gd['GD Version'] = 'Not Installed';
|
274 |
}
|
275 |
+
$debug_info['GD'] = esc_html( $gd['GD Version'] );
|
276 |
+
$debug_info['[php.ini] post_max_size'] = esc_html( ini_get( 'post_max_size' ) );
|
277 |
+
$debug_info['[php.ini] upload_max_filesize'] = esc_html( ini_get( 'upload_max_filesize' ) );
|
278 |
+
$debug_info['[php.ini] memory_limit'] = esc_html( ini_get( 'memory_limit' ) );
|
279 |
+
$debug_info['Installed Plugins'] = $this->get_plugin_info();
|
280 |
+
$active_theme = wp_get_theme();
|
281 |
+
$debug_info['Theme Name'] = esc_html( $active_theme->Name );
|
282 |
+
$debug_info['Theme Version'] = esc_html( $active_theme->Version );
|
283 |
+
$debug_info['Author URL'] = esc_url( $active_theme->{'Author URI'} );
|
284 |
+
$debug_info['Template Overrides'] = implode( ', <br/>', $this->rtmedia_scan_template_files( RTMEDIA_PATH . '/templates/' ) );
|
285 |
|
|
|
|
|
286 |
global $wpdb;
|
287 |
+
$rtMedia_model = new RTMediaModel();
|
288 |
+
$results = $wpdb->get_results( $wpdb->prepare( "select media_type, count(id) as count from {$rtMedia_model->table_name} where blog_id = %d group by media_type limit 100", get_current_blog_id() ) ); // @codingStandardsIgnoreLine
|
289 |
if ( $results ) {
|
290 |
foreach ( $results as $media ) {
|
291 |
$debug_info[ 'Total ' . ucfirst( $media->media_type ) . 's' ] = $media->count;
|
307 |
$this->debug_info();
|
308 |
?>
|
309 |
<div id="debug-info" class="rtm-option-wrapper">
|
310 |
+
<h3 class="rtm-option-title"><?php esc_html_e( 'Debug Info', 'buddypress-media' ); ?></h3>
|
311 |
+
<table class="form-table rtm-debug-info">
|
312 |
+
<tbody>
|
313 |
+
<?php
|
314 |
+
if ( $this->debug_info ) {
|
315 |
+
foreach ( $this->debug_info as $configuration => $value ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
?>
|
317 |
+
<tr>
|
318 |
+
<th scope="row"><?php echo esc_html( $configuration ); ?></th>
|
319 |
+
<td><?php echo esc_html( $value ); ?></td>
|
320 |
+
</tr><?php
|
321 |
+
}
|
322 |
+
}
|
323 |
+
?>
|
324 |
+
</tbody>
|
325 |
+
</table>
|
326 |
</div><?php
|
327 |
}
|
328 |
|
337 |
*/
|
338 |
public function is_migration_required() {
|
339 |
$pending_rtmedia_migrate = rtmedia_get_site_option( 'rtMigration-pending-count' );
|
340 |
+
if ( ( false === $pending_rtmedia_migrate || 0 === intval( $pending_rtmedia_migrate ) ) ) {
|
341 |
return false;
|
342 |
}
|
343 |
|
357 |
$pending_rtmedia_migrate = rtmedia_get_site_option( 'rtMigration-pending-count' );
|
358 |
|
359 |
$content = ' ';
|
360 |
+
$flag = true;
|
361 |
+
if ( ( false === $pending_rtmedia_migrate || 0 === intval( $pending_rtmedia_migrate ) ) ) {
|
362 |
+
$content .= esc_html__( 'There is no media found to migrate.', 'buddypress-media' );
|
363 |
$flag = false;
|
364 |
}
|
365 |
$content = apply_filters( 'rtmedia_migration_content_filter', $content );
|
366 |
if ( $flag ) {
|
367 |
$content .= ' <div class="rtmedia-migration-support">';
|
368 |
+
$content .= ' <p>' . esc_html__( 'Click', 'buddypress-media' ) . ' <a href="' . esc_url( get_admin_url() ) . 'admin.php?page=rtmedia-migration">' . esc_html__( 'here', 'buddypress-media' ) . '</a>' . esc_html__( 'here to migrate media from rtMedia 2.x to rtMedia 3.0+.', 'buddypress-media' ) . '</p>';
|
369 |
$content .= '</div>';
|
370 |
}
|
371 |
?>
|
372 |
<div id="rtmedia-migration-html">
|
373 |
+
<?php echo $content; // @codingStandardsIgnoreLine ?>
|
374 |
</div>
|
375 |
<?php
|
376 |
}
|
378 |
/**
|
379 |
* Generate rtmedia admin form.
|
380 |
*
|
381 |
+
* @global type $current_user
|
382 |
*
|
383 |
* @param string $form
|
384 |
*
|
385 |
* @return void
|
386 |
*/
|
387 |
public function get_form( $form = '' ) {
|
388 |
+
//todo: nonce required
|
389 |
if ( empty( $form ) ) {
|
390 |
+
$form = filter_input( INPUT_POST, 'form'. FILTER_SANITIZE_STRING );
|
391 |
+
$form = isset( $form ) ? $form : 'premium_support';
|
|
|
|
|
392 |
}
|
393 |
+
$meta_title = '';
|
394 |
switch ( $form ) {
|
395 |
case 'bug_report':
|
396 |
+
$meta_title = esc_html__( 'Submit a Bug Report', 'buddypress-media' );
|
397 |
break;
|
398 |
case 'new_feature':
|
399 |
+
$meta_title = esc_html__( 'Submit a New Feature Request', 'buddypress-media' );
|
400 |
break;
|
401 |
case 'premium_support':
|
402 |
+
$meta_title = esc_html__( 'Submit Support Request', 'buddypress-media' );
|
403 |
break;
|
404 |
}
|
405 |
|
406 |
+
if ( 'premium_support' === $form ) {
|
407 |
if ( ! has_filter( 'rtmedia_license_tabs' ) && ! has_action( 'rtmedia_addon_license_details' ) ) {
|
408 |
+
$content = '<h3 class="rtm-option-title">' . esc_html( $meta_title ) . '</h3>';
|
409 |
+
$content .= '<p>' .
|
410 |
+
sprintf(
|
411 |
+
esc_html__( 'If your site has some issues due to rtMedia and you want support, feel free to create a support topic on %s', 'buddypress-media' ),
|
412 |
+
'<a target="_blank" href="http://community.rtcamp.com/c/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">' . esc_html__( 'Community Forum', 'buddypress-media' ) . '</a>.'
|
413 |
+
) .
|
414 |
+
'</p>';
|
415 |
+
|
416 |
+
$content .= '<p>' .
|
417 |
+
sprintf(
|
418 |
+
esc_html__( 'If you have any suggestions, enhancements or bug reports, then you can open a new issue on %s', 'buddypress-media' ),
|
419 |
+
'<a target="_blank" href="https://github.com/rtCamp/rtmedia/issues/new">' . esc_html__( 'GitHub', 'buddypress-media' ) . '</a>.'
|
420 |
+
) .
|
421 |
+
'</p>';
|
422 |
+
|
423 |
+
echo $content; // @codingStandardsIgnoreLine
|
424 |
} else {
|
425 |
+
$website = filter_input( INPUT_POST, 'website', FILTER_SANITIZE_URL );
|
426 |
+
$subject = filter_input( INPUT_POST, 'subject', FILTER_SANITIZE_STRING );
|
427 |
+
$details = filter_input( INPUT_POST, 'details', FILTER_SANITIZE_STRING );
|
428 |
+
$server_addr = filter_input( INPUT_SERVER, 'SERVER_ADDR', FILTER_VALIDATE_IP );
|
429 |
+
$remote_addr = filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );
|
430 |
+
$server_software = filter_input( INPUT_SERVER, 'SERVER_SOFTWARE', FILTER_SANITIZE_STRING );
|
431 |
+
$http_user_agent = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT', FILTER_SANITIZE_STRING );
|
432 |
?>
|
433 |
+
<h3 class="rtm-option-title"><?php echo esc_html( $meta_title ); ?></h3>
|
434 |
<div id="support-form" class="bp-media-form rtm-support-form rtm-option-wrapper">
|
435 |
|
436 |
<div class="rtm-form-filed clearfix">
|
437 |
+
<label class="bp-media-label"
|
438 |
+
for="name"><?php esc_html_e( 'Name', 'buddypress-media' ); ?></label>
|
439 |
+
<input class="bp-media-input" id="name" type="text" name="name" value="" required/>
|
440 |
<span class="rtm-tooltip">
|
441 |
<i class="dashicons dashicons-info rtmicon"></i>
|
442 |
<span class="rtm-tip">
|
443 |
+
<?php esc_html_e( 'Use actual user name which used during purchased.', 'buddypress-media' ); ?>
|
444 |
</span>
|
445 |
</span>
|
446 |
</div>
|
447 |
|
448 |
<div class="rtm-form-filed clearfix">
|
449 |
+
<label class="bp-media-label"
|
450 |
+
for="email"><?php esc_html_e( 'Email', 'buddypress-media' ); ?></label>
|
451 |
+
<input id="email" class="bp-media-input" type="text" name="email" value="" required/>
|
452 |
<span class="rtm-tooltip">
|
453 |
<i class="dashicons dashicons-info rtmicon"></i>
|
454 |
<span class="rtm-tip">
|
455 |
+
<?php esc_html_e( 'Use email id which used during purchased', 'buddypress-media' ); ?>
|
456 |
</span>
|
457 |
</span>
|
458 |
</div>
|
459 |
|
460 |
<div class="rtm-form-filed clearfix">
|
461 |
+
<label class="bp-media-label"
|
462 |
+
for="website"><?php esc_html_e( 'Website', 'buddypress-media' ); ?></label>
|
463 |
+
<input id="website" class="bp-media-input" type="text" name="website"
|
464 |
+
value="<?php echo esc_url( isset( $website ) ? $website : get_bloginfo( 'url' ) ); ?>"
|
465 |
+
required/>
|
466 |
</div>
|
467 |
|
468 |
<div class="rtm-form-filed clearfix">
|
469 |
+
<label class="bp-media-label"
|
470 |
+
for="subject"><?php esc_html_e( 'Subject', 'buddypress-media' ); ?></label>
|
471 |
+
<input id="subject" class="bp-media-input" type="text" name="subject"
|
472 |
+
value="<?php echo esc_attr( isset( $subject ) ? esc_attr( $subject ) : '' ); ?>"
|
473 |
+
required/>
|
474 |
</div>
|
475 |
|
476 |
<div class="rtm-form-filed clearfix">
|
477 |
+
<label class="bp-media-label"
|
478 |
+
for="details"><?php esc_html_e( 'Details', 'buddypress-media' ); ?></label>
|
479 |
+
<textarea id="details" class="bp-media-textarea" name="details"
|
480 |
+
required><?php echo esc_html( isset( $details ) ? esc_textarea( $details ) : '' ); ?></textarea>
|
481 |
+
|
482 |
+
<input type="hidden" name="request_type" value="<?php echo esc_attr( $form ); ?>"/>
|
483 |
+
<input type="hidden" name="request_id"
|
484 |
+
value="<?php echo esc_attr( wp_create_nonce( date( 'YmdHis' ) ) ); ?>"/>
|
485 |
+
<input type="hidden" name="server_address" value="<?php echo esc_attr( $server_addr ); ?>"/>
|
486 |
+
<input type="hidden" name="ip_address" value="<?php echo esc_attr( $remote_addr ); ?>"/>
|
487 |
+
<input type="hidden" name="server_type" value="<?php echo esc_attr( $server_software ); ?>"/>
|
488 |
+
<input type="hidden" name="user_agent" value="<?php echo esc_attr( $http_user_agent ); ?>"/>
|
489 |
</div>
|
490 |
</div><!-- .submit-bug-box -->
|
491 |
|
492 |
<div class="rtm-form-filed rtm-button-wrapper clearfix">
|
493 |
+
<?php wp_nonce_field( 'rtmedia-support-request','support_wpnonce' ); ?>
|
494 |
<?php submit_button( 'Submit', 'primary', 'rtmedia-submit-request', false ); ?>
|
495 |
<?php submit_button( 'Cancel', 'secondary', 'cancel-request', false ); ?>
|
496 |
</div>
|
510 |
* @return void
|
511 |
*/
|
512 |
public function submit_request() {
|
513 |
+
$nonce = filter_input( INPUT_POST, 'support_wpnonce', FILTER_SANITIZE_STRING );
|
514 |
+
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'rtmedia-support-request' ) ) {
|
515 |
+
wp_die(
|
516 |
+
'<h1>' . esc_html__( 'Cheatin\' uh?','buddypress-media' ) . '</h1>' .
|
517 |
+
'<p>' . esc_html__( 'Can not verify request source.','buddypress-media' ) . '</p>'
|
518 |
+
);
|
519 |
+
}
|
520 |
+
|
521 |
$this->debug_info();
|
522 |
+
$form_data = filter_input( INPUT_POST, 'form_data', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
523 |
+
$form_data = wp_parse_args( $form_data );
|
524 |
foreach ( $form_data as $key => $formdata ) {
|
525 |
+
if ( '' === $formdata && 'phone' !== $key ) {
|
526 |
echo 'false';
|
527 |
die();
|
528 |
}
|
529 |
}
|
530 |
+
if ( 'premium_support' === sanitize_text_field( $form_data['request_type'] ) ) {
|
531 |
$mail_type = 'Premium Support';
|
532 |
+
$title = esc_html__( 'rtMedia Premium Support Request from', 'buddypress-media' );
|
533 |
+
} else if ( 'new_feature' === sanitize_text_field( $form_data['request_type'] ) ) {
|
534 |
$mail_type = 'New Feature Request';
|
535 |
+
$title = esc_html__( 'rtMedia New Feature Request from', 'buddypress-media' );
|
536 |
+
} else if ( 'bug_report' === sanitize_text_field( $form_data['request_type'] ) ) {
|
537 |
$mail_type = 'Bug Report';
|
538 |
+
$title = esc_html__( 'rtMedia Bug Report from', 'buddypress-media' );
|
539 |
} else {
|
540 |
$mail_type = 'Bug Report';
|
541 |
+
$title = esc_html__( 'rtMedia Contact from', 'buddypress-media' );
|
542 |
}
|
543 |
$message = '<html>
|
544 |
+
<head>
|
545 |
+
<title>' . strip_tags( $title . get_bloginfo( 'name' ) ) . '</title>
|
546 |
+
</head>
|
547 |
+
<body>
|
548 |
+
<table>
|
549 |
+
<tr>
|
550 |
+
<td>Name</td><td>' . strip_tags( $form_data['name'] ) . '</td>
|
551 |
+
</tr>
|
552 |
+
<tr>
|
553 |
+
<td>Email</td><td>' . strip_tags( $form_data['email'] ) . '</td>
|
554 |
+
</tr>
|
555 |
+
<tr>
|
556 |
+
<td>Website</td><td>' . strip_tags( $form_data['website'] ) . '</td>
|
557 |
+
</tr>
|
558 |
+
<tr>
|
559 |
+
<td>Phone</td><td>' . strip_tags( $form_data['phone'] ) . '</td>
|
560 |
+
</tr>
|
561 |
+
<tr>
|
562 |
+
<td>Subject</td><td>' . strip_tags( $form_data['subject'] ) . '</td>
|
563 |
+
</tr>
|
564 |
+
<tr>
|
565 |
+
<td>Details</td><td>' . strip_tags( $form_data['details'] ) . '</td>
|
566 |
+
</tr>
|
567 |
+
<tr>
|
568 |
+
<td>Request ID</td><td>' . strip_tags( $form_data['request_id'] ) . '</td>
|
569 |
+
</tr>
|
570 |
+
<tr>
|
571 |
+
<td>Server Address</td><td>' . strip_tags( $form_data['server_address'] ) . '</td>
|
572 |
+
</tr>
|
573 |
+
<tr>
|
574 |
+
<td>IP Address</td><td>' . strip_tags( $form_data['ip_address'] ) . '</td>
|
575 |
+
</tr>
|
576 |
+
<tr>
|
577 |
+
<td>Server Type</td><td>' . strip_tags( $form_data['server_type'] ) . '</td>
|
578 |
+
</tr>
|
579 |
+
<tr>
|
580 |
+
<td>User Agent</td><td>' . strip_tags( $form_data['user_agent'] ) . '</td>
|
581 |
+
</tr>';
|
582 |
+
if ( 'bug_report' === sanitize_text_field( $form_data['request_type'] ) ) {
|
583 |
$message .= '<tr>
|
584 |
+
<td>WordPress Admin Username</td><td>' . strip_tags( $form_data['wp_admin_username'] ) . '</td>
|
585 |
+
</tr>
|
586 |
+
<tr>
|
587 |
+
<td>WordPress Admin Password</td><td>' . strip_tags( $form_data['wp_admin_pwd'] ) . '</td>
|
588 |
+
</tr>
|
589 |
+
<tr>
|
590 |
+
<td>SSH FTP Host</td><td>' . strip_tags( $form_data['ssh_ftp_host'] ) . '</td>
|
591 |
+
</tr>
|
592 |
+
<tr>
|
593 |
+
<td>SSH FTP Username</td><td>' . strip_tags( $form_data['ssh_ftp_username'] ) . '</td>
|
594 |
+
</tr>
|
595 |
+
<tr>
|
596 |
+
<td>SSH FTP Password</td><td>' . strip_tags( $form_data['ssh_ftp_pwd'] ) . '</td>
|
597 |
+
</tr>
|
598 |
+
';
|
599 |
}
|
600 |
$message .= '</table>';
|
601 |
if ( $this->debug_info ) {
|
602 |
+
$message .= '<h3>' . esc_html__( 'Debug Info', 'buddypress-media' ) . '</h3>';
|
603 |
$message .= '<table>';
|
604 |
foreach ( $this->debug_info as $configuration => $value ) {
|
605 |
$message .= '<tr>
|
606 |
+
<td style="vertical-align:top">' . esc_html( $configuration ) . '</td><td>' . $value . '</td>
|
607 |
+
</tr>';
|
608 |
}
|
609 |
$message .= '</table>';
|
610 |
}
|
611 |
$message .= '</body>
|
612 |
+
</html>';
|
613 |
+
add_filter( 'wp_mail_content_type', function(){ return 'text/html';
|
614 |
+
} );
|
615 |
+
$headers = 'From: ' . $form_data['name'] . ' <' . $form_data['email'] . '>' . "\r\n";
|
616 |
$support_email = 'support@rtcamp.com';
|
617 |
+
if ( wp_mail( $support_email, '[rtmedia] ' . $mail_type . ' from ' . str_replace( array(
|
618 |
+
'http://',
|
619 |
+
'https://',
|
620 |
+
), '', $form_data['website'] ), stripslashes( $message ), $headers ) ) {
|
621 |
echo '<div class="rtmedia-success" style="margin:10px 0;">';
|
622 |
+
if ( 'new_feature' === sanitize_text_field( $form_data['request_type'] ) ) {
|
623 |
+
echo '<p>' . esc_html__( 'Thank you for your Feedback/Suggestion.', 'buddypress-media' ) . '</p>';
|
624 |
} else {
|
625 |
+
echo '<p>' . esc_html__( 'Thank you for posting your support request.', 'buddypress-media' ) . '</p>';
|
626 |
+
echo '<p>' . esc_html__( 'We will get back to you shortly.', 'buddypress-media' ) . '</p>';
|
627 |
}
|
628 |
echo '</div>';
|
629 |
} else {
|
630 |
echo '<div class="rtmedia-error">';
|
631 |
+
echo '<p>' . esc_html__( 'Your server failed to send an email.', 'buddypress-media' ) . '</p>';
|
632 |
+
echo '<p>' . esc_html__( 'Kindly contact your server support to fix this.', 'buddypress-media' ) . '</p>';
|
633 |
+
echo '<p>' .
|
634 |
+
sprintf(
|
635 |
+
esc_html__( 'You can alternatively create a support request %s', 'buddypress-media' ),
|
636 |
+
'<a target="_blank" href="https://rtmedia.io/premium-support/">' . esc_html__( 'here', 'buddypress-media' ) . '</a>.'
|
637 |
+
) .
|
638 |
+
'</p>';
|
639 |
echo '</div>';
|
640 |
}
|
641 |
die();
|
642 |
}
|
|
|
643 |
}
|
644 |
|
645 |
+
}
|
app/helper/RTMediaThemes.php
CHANGED
@@ -28,18 +28,18 @@ class RTMediaThemes {
|
|
28 |
return;
|
29 |
}
|
30 |
|
31 |
-
foreach ( (
|
32 |
|
33 |
-
if ( $section[
|
34 |
-
call_user_func( $section[
|
35 |
}
|
36 |
|
37 |
-
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section[
|
38 |
continue;
|
39 |
}
|
40 |
|
41 |
echo '<table class="form-table">';
|
42 |
-
do_settings_fields( $page, $section[
|
43 |
echo '</table>';
|
44 |
}
|
45 |
}
|
@@ -57,18 +57,18 @@ class RTMediaThemes {
|
|
57 |
$tabs = array();
|
58 |
global $rtmedia_admin;
|
59 |
$tabs[] = array(
|
60 |
-
'title'
|
61 |
-
'name'
|
62 |
-
'href'
|
63 |
-
'icon'
|
64 |
-
'callback' => array( $this, 'rtmedia_themes_content' )
|
65 |
);
|
66 |
$tabs[] = array(
|
67 |
-
'title'
|
68 |
-
'name'
|
69 |
-
'href'
|
70 |
-
'icon'
|
71 |
-
'callback' => array( $this, 'rtmedia_3rd_party_themes_content' )
|
72 |
);
|
73 |
RTMediaAdmin::render_admin_ui( self::$page, $tabs );
|
74 |
}
|
@@ -99,38 +99,38 @@ class RTMediaThemes {
|
|
99 |
$inspirebook_purchase = '<a href="https://rtmedia.io/products/inspirebook/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media" target="_blank">Buy InspireBook</a> | ';
|
100 |
}
|
101 |
|
102 |
-
|
103 |
$themes = array(
|
104 |
-
'rtdating'
|
105 |
-
'name'
|
106 |
-
'image'
|
107 |
-
'demo_url'
|
108 |
-
'author'
|
109 |
-
'author_url'
|
110 |
-
'buy_url'
|
111 |
-
'description' =>
|
112 |
-
'tags'
|
113 |
),
|
114 |
'inspirebook' => array(
|
115 |
-
'name'
|
116 |
-
'image'
|
117 |
-
'demo_url'
|
118 |
-
'author'
|
119 |
-
'author_url'
|
120 |
-
'buy_url'
|
121 |
-
'description' =>
|
122 |
-
'tags'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
),
|
124 |
-
'foodmania' => array(
|
125 |
-
'name' => __( 'Foodmania', 'buddypress-media' ),
|
126 |
-
'image' => 'https://cdn.rtmedia.io/wp-content/uploads/edd/2015/08/foodmania-img1.png',
|
127 |
-
'demo_url' => $rtmedia_demo_url . 'foodmania/',
|
128 |
-
'author' => __( 'rtCamp', 'buddypress-media' ),
|
129 |
-
'author_url' => 'https://rtmedia.io/',
|
130 |
-
'buy_url' => 'https://rtmedia.io/products/foodmania/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media',
|
131 |
-
'description' => __( 'Its premium WordPress theme, designed especially for Food, recipe and photography community sites.', 'buddypress-media' ),
|
132 |
-
'tags' => 'black, yellow, white, dark, one-column, two-columns, right-sidebar, custom-header, custom-background, custom-menu, editor-style, theme-options, threaded-comments, sticky-post, translation-ready, responsive-layout, full-width-template, buddypress',
|
133 |
-
)
|
134 |
);
|
135 |
?>
|
136 |
|
@@ -143,44 +143,62 @@ class RTMediaThemes {
|
|
143 |
|
144 |
<div class="theme rtm-theme">
|
145 |
<div class="theme-screenshot">
|
146 |
-
<img src="<?php echo $theme[
|
147 |
</div>
|
148 |
|
149 |
-
<span class="more-details"><?php
|
150 |
|
151 |
-
<h3 class="theme-name"><?php echo $theme[
|
152 |
|
153 |
<div class="theme-actions">
|
154 |
-
<a class="button load-customize hide-if-no-customize"
|
155 |
-
|
|
|
|
|
156 |
</div>
|
157 |
|
158 |
<div class="rtm-theme-content hide">
|
159 |
<div class="theme-wrap">
|
160 |
<div class="theme-header">
|
161 |
-
<button class="left rtm-previous dashicons dashicons-no"><span
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
</div>
|
165 |
|
166 |
<div class="theme-about">
|
167 |
<div class="theme-screenshots">
|
168 |
<div class="screenshot">
|
169 |
-
<a href="<?php echo $theme[
|
|
|
170 |
</div>
|
171 |
</div>
|
172 |
|
173 |
<div class="theme-info">
|
174 |
-
<h3 class="theme-name"><?php echo $theme[
|
175 |
-
<h4 class="theme-author">By <a
|
176 |
-
|
177 |
-
<p class="theme-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
</div>
|
179 |
</div>
|
180 |
|
181 |
<div class="theme-actions">
|
182 |
-
<a class="button load-customize hide-if-no-customize"
|
183 |
-
|
|
|
|
|
184 |
</div>
|
185 |
</div>
|
186 |
</div>
|
@@ -205,66 +223,66 @@ class RTMediaThemes {
|
|
205 |
public function rtmedia_3rd_party_themes_content() {
|
206 |
|
207 |
$themes = array(
|
208 |
-
'woffice'
|
209 |
-
'name'
|
210 |
-
'image'
|
211 |
-
'demo_url'
|
212 |
-
'author'
|
213 |
-
'author_url'
|
214 |
-
'buy_url'
|
215 |
-
'description' =>
|
216 |
-
'tags'
|
217 |
),
|
218 |
-
'thrive'
|
219 |
-
'name'
|
220 |
-
'image'
|
221 |
-
'demo_url'
|
222 |
-
'author'
|
223 |
-
'author_url'
|
224 |
-
'buy_url'
|
225 |
-
'description' =>
|
226 |
-
'tags'
|
227 |
),
|
228 |
-
'msocial'
|
229 |
-
'name'
|
230 |
-
'image'
|
231 |
-
'demo_url'
|
232 |
-
'author'
|
233 |
-
'author_url'
|
234 |
-
'buy_url'
|
235 |
-
'description' =>
|
236 |
-
'tags'
|
237 |
),
|
238 |
-
'klein'
|
239 |
-
'name'
|
240 |
-
'image'
|
241 |
-
'demo_url'
|
242 |
-
'author'
|
243 |
-
'author_url'
|
244 |
-
'buy_url'
|
245 |
-
'description' =>
|
246 |
-
'tags'
|
247 |
),
|
248 |
'sweetdate' => array(
|
249 |
-
'name'
|
250 |
-
'image'
|
251 |
-
'demo_url'
|
252 |
-
'author'
|
253 |
-
'author_url'
|
254 |
-
'buy_url'
|
255 |
-
'description' =>
|
256 |
-
'tags'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
),
|
258 |
-
'kleo' => array(
|
259 |
-
'name' => __( 'KLEO', 'buddypress-media' ),
|
260 |
-
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-kleo.png',
|
261 |
-
'demo_url' => 'http://rt.cx/kleo',
|
262 |
-
'author' => __( 'SeventhQueen', 'buddypress-media' ),
|
263 |
-
'author_url' => 'http://rt.cx/kleo',
|
264 |
-
'buy_url' => 'http://rt.cx/kleo',
|
265 |
-
'description' => __( 'You no longer need to be a professional developer or designer to create an awesome website. Let your imagination run wild and create the site of your dreams. KLEO has all the tools to get you started.', 'buddypress-media' ),
|
266 |
-
'tags' => 'bbpress, Bootstrap 3, buddypress, clean design, community theme, e-commerce theme, multi-purpose, responsive design, retina, woocommerce, wordpress theme',
|
267 |
-
)
|
268 |
);
|
269 |
?>
|
270 |
|
@@ -278,44 +296,62 @@ class RTMediaThemes {
|
|
278 |
|
279 |
<div class="theme rtm-theme">
|
280 |
<div class="theme-screenshot">
|
281 |
-
<img src="<?php echo $theme[
|
282 |
</div>
|
283 |
|
284 |
-
<span class="more-details"><?php
|
285 |
|
286 |
-
<h3 class="theme-name"><?php echo $theme[
|
287 |
|
288 |
<div class="theme-actions">
|
289 |
-
<a class="button load-customize hide-if-no-customize"
|
290 |
-
|
|
|
|
|
291 |
</div>
|
292 |
|
293 |
<div class="rtm-theme-content hide">
|
294 |
<div class="theme-wrap">
|
295 |
<div class="theme-header">
|
296 |
-
<button class="left rtm-previous dashicons dashicons-no"><span
|
297 |
-
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
</div>
|
300 |
|
301 |
<div class="theme-about">
|
302 |
<div class="theme-screenshots">
|
303 |
<div class="screenshot">
|
304 |
-
<a href="<?php echo $theme[
|
|
|
305 |
</div>
|
306 |
</div>
|
307 |
|
308 |
<div class="theme-info">
|
309 |
-
<h3 class="theme-name"><?php echo $theme[
|
310 |
-
<h4 class="theme-author">By <a
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
</div>
|
314 |
</div>
|
315 |
|
316 |
<div class="theme-actions">
|
317 |
-
<a class="button load-customize hide-if-no-customize"
|
318 |
-
|
|
|
|
|
319 |
</div>
|
320 |
</div>
|
321 |
</div>
|
@@ -325,17 +361,17 @@ class RTMediaThemes {
|
|
325 |
</div>
|
326 |
</div>
|
327 |
|
328 |
-
<div
|
|
|
329 |
|
330 |
<div>
|
331 |
-
<h3 class="rtm-option-title"><?php
|
332 |
|
333 |
<p>
|
334 |
-
<?php
|
335 |
-
<a href="mailto:rtmedia@rtcamp.com"><?php
|
336 |
</p>
|
337 |
</div>
|
338 |
<?php
|
339 |
}
|
340 |
-
|
341 |
-
}
|
28 |
return;
|
29 |
}
|
30 |
|
31 |
+
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
|
32 |
|
33 |
+
if ( $section['callback'] ) {
|
34 |
+
call_user_func( $section['callback'], $section );
|
35 |
}
|
36 |
|
37 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
|
38 |
continue;
|
39 |
}
|
40 |
|
41 |
echo '<table class="form-table">';
|
42 |
+
do_settings_fields( $page, $section['id'] );
|
43 |
echo '</table>';
|
44 |
}
|
45 |
}
|
57 |
$tabs = array();
|
58 |
global $rtmedia_admin;
|
59 |
$tabs[] = array(
|
60 |
+
'title' => esc_html__( 'Themes By rtCamp', 'buddypress-media' ),
|
61 |
+
'name' => esc_html__( 'Themes By rtCamp', 'buddypress-media' ),
|
62 |
+
'href' => '#rtmedia-themes',
|
63 |
+
'icon' => 'dashicons-admin-appearance',
|
64 |
+
'callback' => array( $this, 'rtmedia_themes_content' ),
|
65 |
);
|
66 |
$tabs[] = array(
|
67 |
+
'title' => esc_html__( '3rd Party Themes', 'buddypress-media' ),
|
68 |
+
'name' => esc_html__( '3rd Party Themes', 'buddypress-media' ),
|
69 |
+
'href' => '#rtmedia-themes-3',
|
70 |
+
'icon' => 'dashicons-randomize',
|
71 |
+
'callback' => array( $this, 'rtmedia_3rd_party_themes_content' ),
|
72 |
);
|
73 |
RTMediaAdmin::render_admin_ui( self::$page, $tabs );
|
74 |
}
|
99 |
$inspirebook_purchase = '<a href="https://rtmedia.io/products/inspirebook/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media" target="_blank">Buy InspireBook</a> | ';
|
100 |
}
|
101 |
|
102 |
+
$rtmedia_demo_url = 'http://demo.rtmedia.io/';
|
103 |
$themes = array(
|
104 |
+
'rtdating' => array(
|
105 |
+
'name' => esc_html__( 'rtDating', 'buddypress-media' ),
|
106 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtDating.png',
|
107 |
+
'demo_url' => $rtmedia_demo_url . 'rtdating/',
|
108 |
+
'author' => esc_html__( 'rtCamp', 'buddypress-media' ),
|
109 |
+
'author_url' => 'https://rtcamp.com/',
|
110 |
+
'buy_url' => 'https://rtmedia.io/products/rtdating/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media',
|
111 |
+
'description' => esc_html__( 'rtDating is a unique, clean and modern theme only for WordPress. This theme is mostly useful for dating sites and community websites. It can also be use for any other WordPress based website.', 'buddypress-media' ),
|
112 |
+
'tags' => 'black, green, white, light, dark, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready',
|
113 |
),
|
114 |
'inspirebook' => array(
|
115 |
+
'name' => esc_html__( 'InspireBook', 'buddypress-media' ),
|
116 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-InspireBook.png',
|
117 |
+
'demo_url' => $rtmedia_demo_url . 'inspirebook/',
|
118 |
+
'author' => esc_html__( 'rtCamp', 'buddypress-media' ),
|
119 |
+
'author_url' => 'https://rtcamp.com/',
|
120 |
+
'buy_url' => 'https://rtmedia.io/products/inspirebook/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media',
|
121 |
+
'description' => esc_html__( 'InspireBook is a premium WordPress theme, designed especially for BuddyPress and rtMedia powered social-networks.', 'buddypress-media' ),
|
122 |
+
'tags' => 'black, blue, white, light, one-column, two-columns, right-sidebar, custom-header, custom-background, custom-menu, editor-style, theme-options, threaded-comments, sticky-post, translation-ready, responsive-layout, full-width-template, buddypress',
|
123 |
+
),
|
124 |
+
'foodmania' => array(
|
125 |
+
'name' => esc_html__( 'Foodmania', 'buddypress-media' ),
|
126 |
+
'image' => 'https://cdn.rtmedia.io/wp-content/uploads/edd/2015/08/foodmania-img1.png',
|
127 |
+
'demo_url' => $rtmedia_demo_url . 'foodmania/',
|
128 |
+
'author' => esc_html__( 'rtCamp', 'buddypress-media' ),
|
129 |
+
'author_url' => 'https://rtcamp.com/',
|
130 |
+
'buy_url' => 'https://rtmedia.io/products/foodmania/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media',
|
131 |
+
'description' => esc_html__( 'Its premium WordPress theme, designed especially for Food, recipe and photography community sites.', 'buddypress-media' ),
|
132 |
+
'tags' => 'black, yellow, white, dark, one-column, two-columns, right-sidebar, custom-header, custom-background, custom-menu, editor-style, theme-options, threaded-comments, sticky-post, translation-ready, responsive-layout, full-width-template, buddypress',
|
133 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
);
|
135 |
?>
|
136 |
|
143 |
|
144 |
<div class="theme rtm-theme">
|
145 |
<div class="theme-screenshot">
|
146 |
+
<img src="<?php echo esc_url( $theme['image'] ); ?>"/>
|
147 |
</div>
|
148 |
|
149 |
+
<span class="more-details"><?php esc_html_e( 'Theme Details', 'buddypress-media' ); ?></span>
|
150 |
|
151 |
+
<h3 class="theme-name"><?php echo esc_html( $theme['name'] ); ?></h3>
|
152 |
|
153 |
<div class="theme-actions">
|
154 |
+
<a class="button load-customize hide-if-no-customize"
|
155 |
+
href="<?php echo esc_url( $theme['demo_url'] ); ?>"><?php esc_html_e( 'Live Demo', 'buddypress-media' ); ?></a>
|
156 |
+
<a class="button button-primary load-customize hide-if-no-customize"
|
157 |
+
href="<?php echo esc_url( $theme['buy_url'] ); ?>"><?php esc_html_e( 'Buy Now', 'buddypress-media' ); ?></a>
|
158 |
</div>
|
159 |
|
160 |
<div class="rtm-theme-content hide">
|
161 |
<div class="theme-wrap">
|
162 |
<div class="theme-header">
|
163 |
+
<button class="left rtm-previous dashicons dashicons-no"><span
|
164 |
+
class="screen-reader-text"><?php esc_html_e( 'Show previous theme', 'buddypress-media' ); ?></span>
|
165 |
+
</button>
|
166 |
+
<button class="right rtm-next dashicons dashicons-no"><span
|
167 |
+
class="screen-reader-text"><?php esc_html_e( 'Show next theme', 'buddypress-media' ); ?></span>
|
168 |
+
</button>
|
169 |
+
<button class="close rtm-close dashicons dashicons-no"><span
|
170 |
+
class="screen-reader-text"><?php esc_html_e( 'Close overlay', 'buddypress-media' ); ?></span>
|
171 |
+
</button>
|
172 |
</div>
|
173 |
|
174 |
<div class="theme-about">
|
175 |
<div class="theme-screenshots">
|
176 |
<div class="screenshot">
|
177 |
+
<a href="<?php echo esc_url( $theme['buy_url'] ); ?>" target="_blank"><img
|
178 |
+
src="<?php echo esc_url( $theme['image'] ); ?>"/></a>
|
179 |
</div>
|
180 |
</div>
|
181 |
|
182 |
<div class="theme-info">
|
183 |
+
<h3 class="theme-name"><?php echo esc_html( $theme['name'] ); ?></h3>
|
184 |
+
<h4 class="theme-author">By <a
|
185 |
+
href="https://rtcamp.com/"><?php echo esc_html( $theme['author'] ); ?></a></h4>
|
186 |
+
<p class="theme-description"><?php echo esc_html( $theme['description'] ); ?> <a
|
187 |
+
href="<?php echo esc_url( $theme['buy_url'] ); ?>"
|
188 |
+
class="rtmedia-theme-inner-a"
|
189 |
+
target="_blank"><?php esc_html_e( 'Read More', 'buddypress-media' ); ?></a>
|
190 |
+
</p>
|
191 |
+
<p class="theme-tags">
|
192 |
+
<span><?php esc_html_e( 'Tags:', 'buddypress-media' ); ?></span><?php echo esc_html( $theme['tags'] ); ?>
|
193 |
+
</p>
|
194 |
</div>
|
195 |
</div>
|
196 |
|
197 |
<div class="theme-actions">
|
198 |
+
<a class="button load-customize hide-if-no-customize"
|
199 |
+
href="<?php echo esc_url( $theme['demo_url'] ); ?>"><?php esc_html_e( 'Live Demo', 'buddypress-media' ); ?></a>
|
200 |
+
<a class="button button-primary load-customize hide-if-no-customize"
|
201 |
+
href="<?php echo esc_url( $theme['buy_url'] ); ?>"><?php esc_html_e( 'Buy Now', 'buddypress-media' ); ?></a>
|
202 |
</div>
|
203 |
</div>
|
204 |
</div>
|
223 |
public function rtmedia_3rd_party_themes_content() {
|
224 |
|
225 |
$themes = array(
|
226 |
+
'woffice' => array(
|
227 |
+
'name' => esc_html__( 'Woffice - Intranet/Extranet WordPress Theme', 'buddypress-media' ),
|
228 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-woffice.jpg',
|
229 |
+
'demo_url' => 'http://rt.cx/woffice',
|
230 |
+
'author' => esc_html__( 'Alkaweb', 'buddypress-media' ),
|
231 |
+
'author_url' => 'http://rt.cx/woffice',
|
232 |
+
'buy_url' => 'http://rt.cx/woffice',
|
233 |
+
'description' => esc_html__( 'Woffice is a feature rich, powerful Multipurpose Intranet/Extranet Wordpress theme.', 'buddypress-media' ),
|
234 |
+
'tags' => 'association, community, extranet, intranet, management, network, office, private, projects, school, wiki',
|
235 |
),
|
236 |
+
'thrive' => array(
|
237 |
+
'name' => esc_html__( 'Thrive - Intranet & Community WordPress Theme', 'buddypress-media' ),
|
238 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-thrive.jpg',
|
239 |
+
'demo_url' => 'http://rt.cx/thrive',
|
240 |
+
'author' => esc_html__( 'dunhakdis', 'buddypress-media' ),
|
241 |
+
'author_url' => 'http://rt.cx/thrive',
|
242 |
+
'buy_url' => 'http://rt.cx/thrive',
|
243 |
+
'description' => esc_html__( 'Thrive is an innovative WordPress Theme designed to cater company portals, organisational websites, company intranet and extranets.', 'buddypress-media' ),
|
244 |
+
'tags' => 'community, events, extranet, forums, intranet, membership, network, polls, project management, rtl, social, tasks',
|
245 |
),
|
246 |
+
'msocial' => array(
|
247 |
+
'name' => esc_html__( '(M) SOCIAL NETWORK BUDDYPRESS THEME', 'buddypress-media' ),
|
248 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-msocial.jpg',
|
249 |
+
'demo_url' => 'http://rt.cx/msocial',
|
250 |
+
'author' => esc_html__( 'gavick', 'buddypress-media' ),
|
251 |
+
'author_url' => 'http://rt.cx/msocial',
|
252 |
+
'buy_url' => 'http://rt.cx/msocial',
|
253 |
+
'description' => esc_html__( '(M)Social is a sophisticated, vibrant community theme that offers incredible grid layouts, with full BuddyPress support so your users can interact with each other, create their own pages, and share their thoughts and images with the community.', 'buddypress-media' ),
|
254 |
+
'tags' => 'responsive, WPML, BuddyPress, social, business',
|
255 |
),
|
256 |
+
'klein' => array(
|
257 |
+
'name' => esc_html__( 'Klein', 'buddypress-media' ),
|
258 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-klein.jpg',
|
259 |
+
'demo_url' => 'http://rt.cx/klein',
|
260 |
+
'author' => esc_html__( 'dunhakdis', 'buddypress-media' ),
|
261 |
+
'author_url' => 'http://rt.cx/klein',
|
262 |
+
'buy_url' => 'http://rt.cx/klein',
|
263 |
+
'description' => esc_html__( 'Klein is an innovative WordPress theme built to support BuddyPress, bbPress, and WooCommerce out of the box. Perfect for websites that interacts with many users.', 'buddypress-media' ),
|
264 |
+
'tags' => 'bbpress, bp, buddypress, buddypress flat design, buddypress theme, community, responsive buddypress, responsive buddypress theme, social network, wordpress community theme',
|
265 |
),
|
266 |
'sweetdate' => array(
|
267 |
+
'name' => esc_html__( 'SweetDate', 'buddypress-media' ),
|
268 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-sweetdate.png',
|
269 |
+
'demo_url' => 'http://rt.cx/sweetdate',
|
270 |
+
'author' => esc_html__( 'SeventhQueen', 'buddypress-media' ),
|
271 |
+
'author_url' => 'http://rt.cx/sweetdate',
|
272 |
+
'buy_url' => 'http://rt.cx/sweetdate',
|
273 |
+
'description' => esc_html__( 'SweetDate is a unique, clean and modern Premium Wordpress theme. It is perfect for a dating or community website but can be used as well for any other domain. They added all the things you need to create a perfect community system.', 'buddypress-media' ),
|
274 |
+
'tags' => 'bbpress, buddypress, clean, community, creative, dating, facebook, foundation, mailchimp, retina, seo, social, woocommerce, wordpress, zurb',
|
275 |
+
),
|
276 |
+
'kleo' => array(
|
277 |
+
'name' => esc_html__( 'KLEO', 'buddypress-media' ),
|
278 |
+
'image' => RTMEDIA_URL . 'app/assets/admin/img/rtmedia-theme-kleo.png',
|
279 |
+
'demo_url' => 'http://rt.cx/kleo',
|
280 |
+
'author' => esc_html__( 'SeventhQueen', 'buddypress-media' ),
|
281 |
+
'author_url' => 'http://rt.cx/kleo',
|
282 |
+
'buy_url' => 'http://rt.cx/kleo',
|
283 |
+
'description' => esc_html__( 'You no longer need to be a professional developer or designer to create an awesome website. Let your imagination run wild and create the site of your dreams. KLEO has all the tools to get you started.', 'buddypress-media' ),
|
284 |
+
'tags' => 'bbpress, Bootstrap 3, buddypress, clean design, community theme, e-commerce theme, multi-purpose, responsive design, retina, woocommerce, wordpress theme',
|
285 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
);
|
287 |
?>
|
288 |
|
296 |
|
297 |
<div class="theme rtm-theme">
|
298 |
<div class="theme-screenshot">
|
299 |
+
<img src="<?php echo esc_url( $theme['image'] ); ?>"/>
|
300 |
</div>
|
301 |
|
302 |
+
<span class="more-details"><?php esc_html_e( 'Theme Details', 'buddypress-media' ); ?></span>
|
303 |
|
304 |
+
<h3 class="theme-name"><?php echo esc_html( $theme['name'] ); ?></h3>
|
305 |
|
306 |
<div class="theme-actions">
|
307 |
+
<a class="button load-customize hide-if-no-customize"
|
308 |
+
href="<?php echo esc_url( $theme['demo_url'] ); ?>"><?php esc_html_e( 'Live Demo', 'buddypress-media' ); ?></a>
|
309 |
+
<a class="button button-primary load-customize hide-if-no-customize"
|
310 |
+
href="<?php echo esc_url( $theme['buy_url'] ); ?>"><?php esc_html_e( 'Buy Now', 'buddypress-media' ); ?></a>
|
311 |
</div>
|
312 |
|
313 |
<div class="rtm-theme-content hide">
|
314 |
<div class="theme-wrap">
|
315 |
<div class="theme-header">
|
316 |
+
<button class="left rtm-previous dashicons dashicons-no"><span
|
317 |
+
class="screen-reader-text"><?php esc_html_e( 'Show previous theme', 'buddypress-media' ); ?></span>
|
318 |
+
</button>
|
319 |
+
<button class="right rtm-next dashicons dashicons-no"><span
|
320 |
+
class="screen-reader-text"><?php esc_html_e( 'Show next theme', 'buddypress-media' ); ?></span>
|
321 |
+
</button>
|
322 |
+
<button class="close rtm-close dashicons dashicons-no"><span
|
323 |
+
class="screen-reader-text"><?php esc_html_e( 'Close overlay', 'buddypress-media' ); ?></span>
|
324 |
+
</button>
|
325 |
</div>
|
326 |
|
327 |
<div class="theme-about">
|
328 |
<div class="theme-screenshots">
|
329 |
<div class="screenshot">
|
330 |
+
<a href="<?php echo esc_url( $theme['buy_url'] ); ?>" target="_blank"><img
|
331 |
+
src="<?php echo esc_url( $theme['image'] ); ?>"/></a>
|
332 |
</div>
|
333 |
</div>
|
334 |
|
335 |
<div class="theme-info">
|
336 |
+
<h3 class="theme-name"><?php echo esc_html( $theme['name'] ); ?></h3>
|
337 |
+
<h4 class="theme-author">By <a
|
338 |
+
href="<?php echo esc_url( $theme['author_url'] ); ?>"><?php echo esc_html( $theme['author'] ); ?></a>
|
339 |
+
</h4>
|
340 |
+
<p class="theme-description"><?php echo esc_html( $theme['description'] ); ?> <a
|
341 |
+
href="<?php echo esc_url( $theme['buy_url'] ); ?>" class="rtmedia-theme-inner-a"
|
342 |
+
target="_blank"><?php esc_html_e( 'Read More', 'buddypress-media' ); ?></a>
|
343 |
+
</p>
|
344 |
+
<p class="theme-tags">
|
345 |
+
<span><?php esc_html_e( 'Tags:', 'buddypress-media' ); ?></span><?php echo esc_html( $theme['tags'] ); ?>
|
346 |
+
</p>
|
347 |
</div>
|
348 |
</div>
|
349 |
|
350 |
<div class="theme-actions">
|
351 |
+
<a class="button load-customize hide-if-no-customize"
|
352 |
+
href="<?php echo esc_url( $theme['demo_url'] ); ?>"><?php esc_html_e( 'Live Demo', 'buddypress-media' ); ?></a>
|
353 |
+
<a class="button button-primary load-customize hide-if-no-customize"
|
354 |
+
href="<?php echo esc_url( $theme['buy_url'] ); ?>"><?php esc_html_e( 'Buy Now', 'buddypress-media' ); ?></a>
|
355 |
</div>
|
356 |
</div>
|
357 |
</div>
|
361 |
</div>
|
362 |
</div>
|
363 |
|
364 |
+
<div
|
365 |
+
class="rtmedia-theme-warning rtm-warning"><?php esc_html_e( 'These are the third party themes. For any issues or queries regarding these themes please contact theme developers.', 'buddypress-media' ); ?></div>
|
366 |
|
367 |
<div>
|
368 |
+
<h3 class="rtm-option-title"><?php esc_html_e( 'Are you a developer?', 'buddypress-media' ); ?></h3>
|
369 |
|
370 |
<p>
|
371 |
+
<?php esc_html_e( 'If you have developed a rtMedia compatible theme and would like it to list here, please email us at', 'buddypress-media' ) ?>
|
372 |
+
<a href="mailto:rtmedia@rtcamp.com"><?php esc_html_e( 'rtmedia@rtcamp.com', 'buddypress-media' ) ?></a>.
|
373 |
</p>
|
374 |
</div>
|
375 |
<?php
|
376 |
}
|
377 |
+
}
|
|
app/helper/RTMediaUploadException.php
CHANGED
@@ -20,7 +20,7 @@ class RTMediaUploadException extends Exception {
|
|
20 |
* @param type $code
|
21 |
* @param type $msg
|
22 |
*/
|
23 |
-
public function __construct( $code, $msg = false ){
|
24 |
$message = $this->codeToMessage( $code, $msg );
|
25 |
parent::__construct( $message, $code );
|
26 |
}
|
@@ -34,33 +34,33 @@ class RTMediaUploadException extends Exception {
|
|
34 |
*
|
35 |
* @return type
|
36 |
*/
|
37 |
-
private function codeToMessage( $code, $msg ){
|
38 |
switch ( $code ) {
|
39 |
case UPLOAD_ERR_INI_SIZE:
|
40 |
case UPLOAD_ERR_FORM_SIZE:
|
41 |
-
$message = apply_filters( 'bp_media_file_size_error',
|
42 |
break;
|
43 |
case UPLOAD_ERR_NO_FILE:
|
44 |
-
$message = apply_filters( 'bp_media_file_null_error',
|
45 |
break;
|
46 |
case UPLOAD_ERR_PARTIAL:
|
47 |
case UPLOAD_ERR_NO_TMP_DIR:
|
48 |
case UPLOAD_ERR_CANT_WRITE:
|
49 |
-
$message = apply_filters( 'bp_media_file_internal_error',
|
50 |
break;
|
51 |
case UPLOAD_ERR_EXTENSION:
|
52 |
-
$message = apply_filters( 'bp_media_file_extension_error',
|
53 |
break;
|
54 |
|
55 |
case $this->upload_err_invalid_context:
|
56 |
-
$message = apply_filters( 'rtmedia_invalid_context_error',
|
57 |
break;
|
58 |
default:
|
59 |
-
$msg = $msg ? $msg :
|
60 |
$message = apply_filters( 'bp_media_file_unknown_error', $msg );
|
61 |
break;
|
62 |
}
|
63 |
|
64 |
return $message;
|
65 |
}
|
66 |
-
}
|
20 |
* @param type $code
|
21 |
* @param type $msg
|
22 |
*/
|
23 |
+
public function __construct( $code, $msg = false ) {
|
24 |
$message = $this->codeToMessage( $code, $msg );
|
25 |
parent::__construct( $message, $code );
|
26 |
}
|
34 |
*
|
35 |
* @return type
|
36 |
*/
|
37 |
+
private function codeToMessage( $code, $msg ) {
|
38 |
switch ( $code ) {
|
39 |
case UPLOAD_ERR_INI_SIZE:
|
40 |
case UPLOAD_ERR_FORM_SIZE:
|
41 |
+
$message = apply_filters( 'bp_media_file_size_error', esc_html__( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 'buddypress-media' ) );
|
42 |
break;
|
43 |
case UPLOAD_ERR_NO_FILE:
|
44 |
+
$message = apply_filters( 'bp_media_file_null_error', esc_html__( 'No file was uploaded', 'buddypress-media' ) );
|
45 |
break;
|
46 |
case UPLOAD_ERR_PARTIAL:
|
47 |
case UPLOAD_ERR_NO_TMP_DIR:
|
48 |
case UPLOAD_ERR_CANT_WRITE:
|
49 |
+
$message = apply_filters( 'bp_media_file_internal_error', esc_html__( 'Uploade failed due to internal server error.', 'buddypress-media' ) );
|
50 |
break;
|
51 |
case UPLOAD_ERR_EXTENSION:
|
52 |
+
$message = apply_filters( 'bp_media_file_extension_error', esc_html__( 'File type not allowed.', 'buddypress-media' ) );
|
53 |
break;
|
54 |
|
55 |
case $this->upload_err_invalid_context:
|
56 |
+
$message = apply_filters( 'rtmedia_invalid_context_error', esc_html__( 'Invalid Context for upload.', 'buddypress-media' ) );
|
57 |
break;
|
58 |
default:
|
59 |
+
$msg = $msg ? $msg : esc_html__( 'Unknown file upload error.', 'buddypress-media' );
|
60 |
$message = apply_filters( 'bp_media_file_unknown_error', $msg );
|
61 |
break;
|
62 |
}
|
63 |
|
64 |
return $message;
|
65 |
}
|
66 |
+
}
|
app/helper/db/RTDBModel.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @author udit
|
8 |
*/
|
9 |
|
10 |
-
if ( ! class_exists( 'RTDBModel' ) ){
|
11 |
class RTDBModel {
|
12 |
|
13 |
/**
|
@@ -24,10 +24,10 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
24 |
|
25 |
/**
|
26 |
*
|
27 |
-
* @param string
|
28 |
* @param boolean $withprefix Set true if $tablename is with prefix otherwise it will prepend wordpress prefix with "rt_"
|
29 |
*/
|
30 |
-
function __construct( $table_name, $withprefix = false, $per_page = 10, $mu_single_table = false ){
|
31 |
$this->mu_single_table = $mu_single_table;
|
32 |
$this->set_table_name( $table_name, $withprefix );
|
33 |
$this->set_per_page( $per_page );
|
@@ -37,12 +37,12 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
37 |
*
|
38 |
* @global object $wpdb
|
39 |
*
|
40 |
-
* @param string
|
41 |
-
* @param mixed
|
42 |
*/
|
43 |
-
public function set_table_name( $table_name, $withprefix = false ){
|
44 |
global $wpdb;
|
45 |
-
if ( ! $withprefix ){
|
46 |
$table_name = ( ( $this->mu_single_table ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'rt_' . $table_name;
|
47 |
}
|
48 |
$this->table_name = $table_name;
|
@@ -53,7 +53,7 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
53 |
*
|
54 |
* @param integer $per_page
|
55 |
*/
|
56 |
-
public function set_per_page( $per_page ){
|
57 |
$this->per_page = $per_page;
|
58 |
}
|
59 |
|
@@ -63,57 +63,57 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
63 |
*
|
64 |
* @global object $wpdb
|
65 |
*
|
66 |
-
* @param string
|
67 |
-
* @param array
|
68 |
*
|
69 |
* @return array result array
|
70 |
*/
|
71 |
-
function __call( $name, $arguments ){
|
72 |
$column_name = str_replace( 'get_by_', '', strtolower( $name ) );
|
73 |
$paging = false;
|
74 |
$page = 1;
|
75 |
-
if ( $arguments && ! empty( $arguments ) ){
|
76 |
-
if ( ! isset( $arguments[1] ) ){
|
77 |
$paging = true;
|
78 |
} else {
|
79 |
$paging = $arguments[1];
|
80 |
}
|
81 |
|
82 |
-
if ( ! isset( $arguments[2] ) ){
|
83 |
$page = 1;
|
84 |
} else {
|
85 |
$page = $arguments[2];
|
86 |
}
|
87 |
|
88 |
-
$this->per_page
|
89 |
-
$return_array
|
90 |
$return_array['result'] = false;
|
91 |
global $wpdb;
|
92 |
-
$return_array['total'] = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM
|
93 |
-
if ( $return_array['total'] > 0 ){
|
94 |
$other = '';
|
95 |
-
if ( $paging ){
|
96 |
-
if ( intval( $this->per_page ) < 0 ){
|
97 |
$this->per_page = 1;
|
98 |
}
|
99 |
|
100 |
$offset = ( $page - 1 ) * $this->per_page;
|
101 |
|
102 |
-
if ( ! is_integer( $offset ) ){
|
103 |
$offset = 0;
|
104 |
}
|
105 |
-
if ( intval( $offset ) < 0 ){
|
106 |
$offset = 0;
|
107 |
}
|
108 |
|
109 |
-
if ( $offset <= $return_array['total'] ){
|
110 |
$other = ' LIMIT ' . $offset . ',' . $this->per_page;
|
111 |
} else {
|
112 |
return false;
|
113 |
}
|
114 |
}
|
115 |
//echo $wpdb->prepare("SELECT * FROM " . $this->table_name . " WHERE {$column_name} = %s {$other}", $arguments[0]);
|
116 |
-
$return_array['result'] = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM
|
117 |
}
|
118 |
|
119 |
return $return_array;
|
@@ -124,17 +124,17 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
124 |
|
125 |
/**
|
126 |
*
|
127 |
-
* @global object
|
128 |
*
|
129 |
-
* @param array
|
130 |
*
|
131 |
* @return integer
|
132 |
*/
|
133 |
-
function insert( $row ){
|
134 |
global $wpdb;
|
135 |
$insertdata = array();
|
136 |
foreach ( $row as $key => $val ) {
|
137 |
-
if ( $val
|
138 |
$insertdata[ $key ] = $val;
|
139 |
}
|
140 |
}
|
@@ -148,10 +148,10 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
148 |
*
|
149 |
* @global object $wpdb
|
150 |
*
|
151 |
-
* @param array
|
152 |
-
* @param array
|
153 |
*/
|
154 |
-
function update( $data, $where ){
|
155 |
global $wpdb;
|
156 |
|
157 |
return $wpdb->update( $this->table_name, $data, $where );
|
@@ -163,68 +163,67 @@ if ( ! class_exists( 'RTDBModel' ) ){
|
|
163 |
*
|
164 |
* @global object $wpdb
|
165 |
*
|
166 |
-
* @param array
|
167 |
*
|
168 |
* @return array
|
169 |
*/
|
170 |
-
function get( $columns, $offset = false, $per_page = false, $order_by = 'id desc' ){
|
|
|
|
|
171 |
$select = "SELECT * FROM {$this->table_name}";
|
172 |
$where = ' where 2=2 ';
|
173 |
foreach ( $columns as $colname => $colvalue ) {
|
174 |
-
if ( is_array( $colvalue ) ){
|
175 |
-
if ( ! isset( $colvalue['compare'] ) ){
|
176 |
$compare = 'IN';
|
177 |
} else {
|
178 |
$compare = $colvalue['compare'];
|
179 |
}
|
180 |
-
if ( ! isset( $colvalue['value'] ) ){
|
181 |
-
$colvalue['value'] = $colvalue;
|
182 |
}
|
183 |
$col_val_comapare = ( is_array( $colvalue['value'] ) ) ? '(\'' . implode( "','", $colvalue['value'] ) . '\')' : '(\'' . $colvalue['value'] . '\')';
|
184 |
$where .= " AND {$this->table_name}.{$colname} {$compare} {$col_val_comapare}";
|
185 |
} else {
|
186 |
-
$where .= " AND {$this->table_name}.{$colname} =
|
187 |
}
|
188 |
}
|
189 |
$sql = $select . $where;
|
190 |
|
191 |
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
192 |
-
if ( false !== $offset ){
|
193 |
-
if ( ! is_integer( $offset ) ){
|
194 |
$offset = 0;
|
195 |
}
|
196 |
-
if ( intval( $offset ) < 0 ){
|
197 |
$offset = 0;
|
198 |
}
|
199 |
|
200 |
-
if ( ! is_integer( $per_page ) ){
|
201 |
$per_page = 0;
|
202 |
}
|
203 |
-
if ( intval( $per_page ) < 0 ){
|
204 |
$per_page = 1;
|
205 |
}
|
206 |
-
$sql .= ' LIMIT '
|
207 |
|
208 |
}
|
209 |
-
global $wpdb;
|
210 |
|
211 |
-
return $wpdb->get_results( $sql );
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
*
|
216 |
* @global object $wpdb
|
217 |
*
|
218 |
-
* @param array
|
219 |
*
|
220 |
* @return array
|
221 |
*/
|
222 |
-
function delete( $where ){
|
223 |
global $wpdb;
|
224 |
|
225 |
return $wpdb->delete( $this->table_name, $where );
|
226 |
}
|
227 |
-
|
228 |
-
|
229 |
}
|
230 |
-
}
|
7 |
* @author udit
|
8 |
*/
|
9 |
|
10 |
+
if ( ! class_exists( 'RTDBModel' ) ) {
|
11 |
class RTDBModel {
|
12 |
|
13 |
/**
|
24 |
|
25 |
/**
|
26 |
*
|
27 |
+
* @param string $table_name Table name for model
|
28 |
* @param boolean $withprefix Set true if $tablename is with prefix otherwise it will prepend wordpress prefix with "rt_"
|
29 |
*/
|
30 |
+
function __construct( $table_name, $withprefix = false, $per_page = 10, $mu_single_table = false ) {
|
31 |
$this->mu_single_table = $mu_single_table;
|
32 |
$this->set_table_name( $table_name, $withprefix );
|
33 |
$this->set_per_page( $per_page );
|
37 |
*
|
38 |
* @global object $wpdb
|
39 |
*
|
40 |
+
* @param string $table_name
|
41 |
+
* @param mixed $withprefix
|
42 |
*/
|
43 |
+
public function set_table_name( $table_name, $withprefix = false ) {
|
44 |
global $wpdb;
|
45 |
+
if ( ! $withprefix ) {
|
46 |
$table_name = ( ( $this->mu_single_table ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'rt_' . $table_name;
|
47 |
}
|
48 |
$this->table_name = $table_name;
|
53 |
*
|
54 |
* @param integer $per_page
|
55 |
*/
|
56 |
+
public function set_per_page( $per_page ) {
|
57 |
$this->per_page = $per_page;
|
58 |
}
|
59 |
|
63 |
*
|
64 |
* @global object $wpdb
|
65 |
*
|
66 |
+
* @param string $name - Added get_by_<coulmname>(value,pagging=true,page_no=1)
|
67 |
+
* @param array $arguments
|
68 |
*
|
69 |
* @return array result array
|
70 |
*/
|
71 |
+
function __call( $name, $arguments ) {
|
72 |
$column_name = str_replace( 'get_by_', '', strtolower( $name ) );
|
73 |
$paging = false;
|
74 |
$page = 1;
|
75 |
+
if ( $arguments && ! empty( $arguments ) ) {
|
76 |
+
if ( ! isset( $arguments[1] ) ) {
|
77 |
$paging = true;
|
78 |
} else {
|
79 |
$paging = $arguments[1];
|
80 |
}
|
81 |
|
82 |
+
if ( ! isset( $arguments[2] ) ) {
|
83 |
$page = 1;
|
84 |
} else {
|
85 |
$page = $arguments[2];
|
86 |
}
|
87 |
|
88 |
+
$this->per_page = apply_filters( 'rt_db_model_per_page', $this->per_page, $this->table_name );
|
89 |
+
$return_array = array();
|
90 |
$return_array['result'] = false;
|
91 |
global $wpdb;
|
92 |
+
$return_array[ 'total' ] = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$this->table_name} WHERE {$column_name} = %s", $arguments[ 0 ] ) ) ); // @codingStandardsIgnoreLine
|
93 |
+
if ( $return_array['total'] > 0 ) {
|
94 |
$other = '';
|
95 |
+
if ( $paging ) {
|
96 |
+
if ( intval( $this->per_page ) < 0 ) {
|
97 |
$this->per_page = 1;
|
98 |
}
|
99 |
|
100 |
$offset = ( $page - 1 ) * $this->per_page;
|
101 |
|
102 |
+
if ( ! is_integer( $offset ) ) {
|
103 |
$offset = 0;
|
104 |
}
|
105 |
+
if ( intval( $offset ) < 0 ) {
|
106 |
$offset = 0;
|
107 |
}
|
108 |
|
109 |
+
if ( $offset <= $return_array['total'] ) {
|
110 |
$other = ' LIMIT ' . $offset . ',' . $this->per_page;
|
111 |
} else {
|
112 |
return false;
|
113 |
}
|
114 |
}
|
115 |
//echo $wpdb->prepare("SELECT * FROM " . $this->table_name . " WHERE {$column_name} = %s {$other}", $arguments[0]);
|
116 |
+
$return_array[ 'result' ] = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$this->table_name} WHERE {$column_name} = %s {$other}", $arguments[ 0 ] ), ARRAY_A ); // @codingStandardsIgnoreLine
|
117 |
}
|
118 |
|
119 |
return $return_array;
|
124 |
|
125 |
/**
|
126 |
*
|
127 |
+
* @global object $wpdb
|
128 |
*
|
129 |
+
* @param array $row
|
130 |
*
|
131 |
* @return integer
|
132 |
*/
|
133 |
+
function insert( $row ) {
|
134 |
global $wpdb;
|
135 |
$insertdata = array();
|
136 |
foreach ( $row as $key => $val ) {
|
137 |
+
if ( null !== $val ) {
|
138 |
$insertdata[ $key ] = $val;
|
139 |
}
|
140 |
}
|
148 |
*
|
149 |
* @global object $wpdb
|
150 |
*
|
151 |
+
* @param array $data
|
152 |
+
* @param array $where
|
153 |
*/
|
154 |
+
function update( $data, $where ) {
|
155 |
global $wpdb;
|
156 |
|
157 |
return $wpdb->update( $this->table_name, $data, $where );
|
163 |
*
|
164 |
* @global object $wpdb
|
165 |
*
|
166 |
+
* @param array $columns
|
167 |
*
|
168 |
* @return array
|
169 |
*/
|
170 |
+
function get( $columns, $offset = false, $per_page = false, $order_by = 'id desc' ) {
|
171 |
+
global $wpdb;
|
172 |
+
|
173 |
$select = "SELECT * FROM {$this->table_name}";
|
174 |
$where = ' where 2=2 ';
|
175 |
foreach ( $columns as $colname => $colvalue ) {
|
176 |
+
if ( is_array( $colvalue ) ) {
|
177 |
+
if ( ! isset( $colvalue['compare'] ) ) {
|
178 |
$compare = 'IN';
|
179 |
} else {
|
180 |
$compare = $colvalue['compare'];
|
181 |
}
|
182 |
+
if ( ! isset( $colvalue['value'] ) ) {
|
183 |
+
$colvalue['value'] = esc_sql( $colvalue );
|
184 |
}
|
185 |
$col_val_comapare = ( is_array( $colvalue['value'] ) ) ? '(\'' . implode( "','", $colvalue['value'] ) . '\')' : '(\'' . $colvalue['value'] . '\')';
|
186 |
$where .= " AND {$this->table_name}.{$colname} {$compare} {$col_val_comapare}";
|
187 |
} else {
|
188 |
+
$where .= $wpdb->prepare( " AND {$this->table_name}.{$colname} = %s", $colvalue ); // @codingStandardsIgnoreLine
|
189 |
}
|
190 |
}
|
191 |
$sql = $select . $where;
|
192 |
|
193 |
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
194 |
+
if ( false !== $offset ) {
|
195 |
+
if ( ! is_integer( $offset ) ) {
|
196 |
$offset = 0;
|
197 |
}
|
198 |
+
if ( intval( $offset ) < 0 ) {
|
199 |
$offset = 0;
|
200 |
}
|
201 |
|
202 |
+
if ( ! is_integer( $per_page ) ) {
|
203 |
$per_page = 0;
|
204 |
}
|
205 |
+
if ( intval( $per_page ) < 0 ) {
|
206 |
$per_page = 1;
|
207 |
}
|
208 |
+
$sql .= $wpdb->prepare( ' LIMIT %d, %d', $offset, $per_page );
|
209 |
|
210 |
}
|
|
|
211 |
|
212 |
+
return $wpdb->get_results( $sql ); // @codingStandardsIgnoreLine
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
*
|
217 |
* @global object $wpdb
|
218 |
*
|
219 |
+
* @param array $where
|
220 |
*
|
221 |
* @return array
|
222 |
*/
|
223 |
+
function delete( $where ) {
|
224 |
global $wpdb;
|
225 |
|
226 |
return $wpdb->delete( $this->table_name, $where );
|
227 |
}
|
|
|
|
|
228 |
}
|
229 |
+
}
|
app/helper/db/RTDBUpdate.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* version 1.1
|
9 |
*/
|
10 |
|
11 |
-
if ( ! class_exists( 'RTDBUpdate' ) ){
|
12 |
class RTDBUpdate {
|
13 |
/**
|
14 |
*
|
@@ -27,15 +27,15 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
27 |
*
|
28 |
* @param type string $current_version Optional if not defined then will use plugin version
|
29 |
*/
|
30 |
-
public function __construct( $current_version = false, $plugin_path = false, $schema_path = false, $mu_single_table = false ){
|
31 |
|
32 |
-
if ( false
|
33 |
$this->schema_path = $schema_path;
|
34 |
} else {
|
35 |
$this->schema_path = realpath( dirname( __FILE__ ) . $this->schema_path );
|
36 |
}
|
37 |
|
38 |
-
if ( false
|
39 |
$this->plugin_path = $plugin_path;
|
40 |
} else {
|
41 |
$this->plugin_path = realpath( dirname( __FILE__ ) . $this->plugin_path );
|
@@ -44,7 +44,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
44 |
$this->mu_single_table = $mu_single_table;
|
45 |
|
46 |
$this->rt_plugin_info = new rt_plugin_info( $this->plugin_path );
|
47 |
-
if ( false
|
48 |
$current_version = $this->rt_plugin_info->version;
|
49 |
}
|
50 |
$this->db_version = $current_version;
|
@@ -61,7 +61,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
-
public function create_table( $sql ){
|
65 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
66 |
dbDelta( $sql );
|
67 |
}
|
@@ -75,7 +75,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
75 |
*
|
76 |
* @return string
|
77 |
*/
|
78 |
-
public function get_db_version_option_name(){
|
79 |
return strtoupper( 'RT_' . str_replace( '-', '_', sanitize_title( $this->rt_plugin_info->name ) ) . '_DB_VERSIONS' );
|
80 |
}
|
81 |
|
@@ -88,7 +88,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
88 |
*
|
89 |
* @return string
|
90 |
*/
|
91 |
-
public function get_install_db_version(){
|
92 |
return ( $this->mu_single_table ) ? get_site_option( $this->db_version_option_name, '0.0' ) : get_option( $this->db_version_option_name, '0.0' );
|
93 |
}
|
94 |
|
@@ -101,7 +101,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
101 |
*
|
102 |
* @return bool
|
103 |
*/
|
104 |
-
public function check_upgrade(){
|
105 |
return version_compare( $this->db_version, $this->install_db_version, '>' );
|
106 |
}
|
107 |
|
@@ -115,24 +115,23 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
115 |
*
|
116 |
* @return void
|
117 |
*/
|
118 |
-
public function do_upgrade(){
|
119 |
global $wpdb;
|
120 |
-
if ( version_compare( $this->db_version, $this->install_db_version, '>' ) ){
|
121 |
$path = $this->schema_path;
|
122 |
-
if ( $handle = opendir( $path ) ){
|
123 |
while ( false !== ( $entry = readdir( $handle ) ) ) {
|
124 |
-
if (
|
125 |
-
if (
|
126 |
-
if ( is_multisite() ){
|
127 |
$table_name = str_replace( '.schema', '', strtolower( $entry ) );
|
128 |
-
$
|
129 |
-
$check_res
|
130 |
-
if ( $check_res && sizeof( $check_res ) > 0 && is_array( $check_res ) && isset( $check_res[0][0] ) ){
|
131 |
$tb_name = $check_res[0][0];
|
132 |
$table_name = ( ( $this->mu_single_table ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'rt_' . $table_name;
|
133 |
-
if ( $tb_name
|
134 |
$alter_sql = 'ALTER TABLE ' . $tb_name . ' RENAME TO ' . $table_name;
|
135 |
-
$wpdb->query( $alter_sql );
|
136 |
}
|
137 |
}
|
138 |
}
|
@@ -142,7 +141,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
142 |
}
|
143 |
closedir( $handle );
|
144 |
}
|
145 |
-
if ( $this->mu_single_table ){
|
146 |
update_site_option( $this->db_version_option_name, $this->db_version );
|
147 |
} else {
|
148 |
update_option( $this->db_version_option_name, $this->db_version );
|
@@ -160,10 +159,10 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
160 |
*
|
161 |
* @return bool
|
162 |
*/
|
163 |
-
static function table_exists( $table ){
|
164 |
global $wpdb;
|
165 |
|
166 |
-
if ( 1
|
167 |
return true;
|
168 |
}
|
169 |
|
@@ -180,7 +179,7 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
180 |
*
|
181 |
* @return string sql query
|
182 |
*/
|
183 |
-
public function genrate_sql( $file_name, $file_content ){
|
184 |
return sprintf( $file_content, $this->genrate_table_name( $file_name ) );
|
185 |
}
|
186 |
|
@@ -193,12 +192,11 @@ if ( ! class_exists( 'RTDBUpdate' ) ){
|
|
193 |
*
|
194 |
* @return string
|
195 |
*/
|
196 |
-
public function genrate_table_name( $file_name ){
|
197 |
global $wpdb;
|
198 |
|
199 |
return ( ( $this->mu_single_table ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'rt_' . str_replace( '.schema', '', strtolower( $file_name ) );
|
200 |
}
|
201 |
-
|
202 |
}
|
203 |
|
204 |
-
}
|
8 |
* version 1.1
|
9 |
*/
|
10 |
|
11 |
+
if ( ! class_exists( 'RTDBUpdate' ) ) {
|
12 |
class RTDBUpdate {
|
13 |
/**
|
14 |
*
|
27 |
*
|
28 |
* @param type string $current_version Optional if not defined then will use plugin version
|
29 |
*/
|
30 |
+
public function __construct( $current_version = false, $plugin_path = false, $schema_path = false, $mu_single_table = false ) {
|
31 |
|
32 |
+
if ( false !== $schema_path ) {
|
33 |
$this->schema_path = $schema_path;
|
34 |
} else {
|
35 |
$this->schema_path = realpath( dirname( __FILE__ ) . $this->schema_path );
|
36 |
}
|
37 |
|
38 |
+
if ( false !== $plugin_path ) {
|
39 |
$this->plugin_path = $plugin_path;
|
40 |
} else {
|
41 |
$this->plugin_path = realpath( dirname( __FILE__ ) . $this->plugin_path );
|
44 |
$this->mu_single_table = $mu_single_table;
|
45 |
|
46 |
$this->rt_plugin_info = new rt_plugin_info( $this->plugin_path );
|
47 |
+
if ( false === $current_version ) {
|
48 |
$current_version = $this->rt_plugin_info->version;
|
49 |
}
|
50 |
$this->db_version = $current_version;
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
+
public function create_table( $sql ) {
|
65 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
66 |
dbDelta( $sql );
|
67 |
}
|
75 |
*
|
76 |
* @return string
|
77 |
*/
|
78 |
+
public function get_db_version_option_name() {
|
79 |
return strtoupper( 'RT_' . str_replace( '-', '_', sanitize_title( $this->rt_plugin_info->name ) ) . '_DB_VERSIONS' );
|
80 |
}
|
81 |
|
88 |
*
|
89 |
* @return string
|
90 |
*/
|
91 |
+
public function get_install_db_version() {
|
92 |
return ( $this->mu_single_table ) ? get_site_option( $this->db_version_option_name, '0.0' ) : get_option( $this->db_version_option_name, '0.0' );
|
93 |
}
|
94 |
|
101 |
*
|
102 |
* @return bool
|
103 |
*/
|
104 |
+
public function check_upgrade() {
|
105 |
return version_compare( $this->db_version, $this->install_db_version, '>' );
|
106 |
}
|
107 |
|
115 |
*
|
116 |
* @return void
|
117 |
*/
|
118 |
+
public function do_upgrade() {
|
119 |
global $wpdb;
|
120 |
+
if ( version_compare( $this->db_version, $this->install_db_version, '>' ) ) {
|
121 |
$path = $this->schema_path;
|
122 |
+
if ( $handle = opendir( $path ) ) {
|
123 |
while ( false !== ( $entry = readdir( $handle ) ) ) {
|
124 |
+
if ( '.' !== $entry && '..' !== $entry ) {
|
125 |
+
if ( false !== strpos( $entry, '.schema' ) && file_exists( $path . '/' . $entry ) ) {
|
126 |
+
if ( is_multisite() ) {
|
127 |
$table_name = str_replace( '.schema', '', strtolower( $entry ) );
|
128 |
+
$check_res = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', '%rt_' . $table_name ), ARRAY_N );
|
129 |
+
if ( $check_res && count( $check_res ) > 0 && is_array( $check_res ) && isset( $check_res[0][0] ) ) {
|
|
|
130 |
$tb_name = $check_res[0][0];
|
131 |
$table_name = ( ( $this->mu_single_table ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'rt_' . $table_name;
|
132 |
+
if ( $tb_name !== $table_name ) {
|
133 |
$alter_sql = 'ALTER TABLE ' . $tb_name . ' RENAME TO ' . $table_name;
|
134 |
+
$wpdb->query( $alter_sql ); // @codingStandardsIgnoreLine
|
135 |
}
|
136 |
}
|
137 |
}
|
141 |
}
|
142 |
closedir( $handle );
|
143 |
}
|
144 |
+
if ( $this->mu_single_table ) {
|
145 |
update_site_option( $this->db_version_option_name, $this->db_version );
|
146 |
} else {
|
147 |
update_option( $this->db_version_option_name, $this->db_version );
|
159 |
*
|
160 |
* @return bool
|
161 |
*/
|
162 |
+
static function table_exists( $table ) {
|
163 |
global $wpdb;
|
164 |
|
165 |
+
if ( 1 === intval( $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ) ) ) {
|
166 |
return true;
|
167 |
}
|
168 |
|
179 |
*
|
180 |
* @return string sql query
|
181 |
*/
|
182 |
+
public function genrate_sql( $file_name, $file_content ) {
|
183 |
return sprintf( $file_content, $this->genrate_table_name( $file_name ) );
|
184 |
}
|
185 |
|
192 |
*
|
193 |
* @return string
|
194 |
*/
|
195 |
+
public function genrate_table_name( $file_name ) {
|
196 |
global $wpdb;
|
197 |
|
198 |
return ( ( $this->mu_single_table ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'rt_' . str_replace( '.schema', '', strtolower( $file_name ) );
|
199 |
}
|
|
|
200 |
}
|
201 |
|
202 |
+
}
|
app/helper/db/rt_plugin_info.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @author udit
|
7 |
*/
|
8 |
|
9 |
-
if ( ! class_exists( 'rt_plugin_info' ) ){
|
10 |
class rt_plugin_info {
|
11 |
|
12 |
//put your code here
|
@@ -27,6 +27,7 @@ if ( ! class_exists( 'rt_plugin_info' ) ){
|
|
27 |
* __construct.
|
28 |
*
|
29 |
* @access public
|
|
|
30 |
* @param void
|
31 |
*
|
32 |
*/
|
@@ -39,11 +40,14 @@ if ( ! class_exists( 'rt_plugin_info' ) ){
|
|
39 |
* get_plugin_data.
|
40 |
*
|
41 |
* @access public
|
|
|
42 |
* @param void
|
43 |
*
|
|
|
44 |
*/
|
45 |
public function get_plugin_data() {
|
46 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
|
|
47 |
return @get_plugin_data( $this->plugin_path );
|
48 |
}
|
49 |
|
@@ -51,37 +55,38 @@ if ( ! class_exists( 'rt_plugin_info' ) ){
|
|
51 |
* set_plugin_data.
|
52 |
*
|
53 |
* @access public
|
|
|
54 |
* @param void
|
55 |
*
|
56 |
*/
|
57 |
public function set_plugin_data() {
|
58 |
-
$this->plugin_data
|
59 |
-
$this->name
|
60 |
-
$this->title
|
61 |
$this->desctipriton = $this->plugin_data['Description'];
|
62 |
-
$this->author
|
63 |
-
$this->authoruri
|
64 |
-
$this->version
|
65 |
-
$this->pluginuri
|
66 |
-
$this->textdomain
|
67 |
-
$this->domain_path
|
68 |
-
$this->network
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
* set_current_plugin_path.
|
73 |
*
|
74 |
* @access public
|
|
|
75 |
* @param string $path
|
76 |
*
|
77 |
*/
|
78 |
public function set_current_plugin_path( $path ) {
|
79 |
-
if ( $path
|
80 |
$this->plugin_path = $path;
|
81 |
} else {
|
82 |
$this->plugin_path = realpath( plugin_dir_path( __FILE__ ) . '../../index.php' );
|
83 |
}
|
84 |
}
|
85 |
-
|
86 |
}
|
87 |
-
}
|
6 |
* @author udit
|
7 |
*/
|
8 |
|
9 |
+
if ( ! class_exists( 'rt_plugin_info' ) ) {
|
10 |
class rt_plugin_info {
|
11 |
|
12 |
//put your code here
|
27 |
* __construct.
|
28 |
*
|
29 |
* @access public
|
30 |
+
*
|
31 |
* @param void
|
32 |
*
|
33 |
*/
|
40 |
* get_plugin_data.
|
41 |
*
|
42 |
* @access public
|
43 |
+
*
|
44 |
* @param void
|
45 |
*
|
46 |
+
* @return array
|
47 |
*/
|
48 |
public function get_plugin_data() {
|
49 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
50 |
+
|
51 |
return @get_plugin_data( $this->plugin_path );
|
52 |
}
|
53 |
|
55 |
* set_plugin_data.
|
56 |
*
|
57 |
* @access public
|
58 |
+
*
|
59 |
* @param void
|
60 |
*
|
61 |
*/
|
62 |
public function set_plugin_data() {
|
63 |
+
$this->plugin_data = $this->get_plugin_data();
|
64 |
+
$this->name = $this->plugin_data['Name'];
|
65 |
+
$this->title = $this->plugin_data['Title'];
|
66 |
$this->desctipriton = $this->plugin_data['Description'];
|
67 |
+
$this->author = $this->plugin_data['Author'];
|
68 |
+
$this->authoruri = $this->plugin_data['AuthorURI'];
|
69 |
+
$this->version = $this->plugin_data['Version'];
|
70 |
+
$this->pluginuri = $this->plugin_data['PluginURI'];
|
71 |
+
$this->textdomain = $this->plugin_data['TextDomain'];
|
72 |
+
$this->domain_path = $this->plugin_data['DomainPath'];
|
73 |
+
$this->network = $this->plugin_data['Network'];
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
* set_current_plugin_path.
|
78 |
*
|
79 |
* @access public
|
80 |
+
*
|
81 |
* @param string $path
|
82 |
*
|
83 |
*/
|
84 |
public function set_current_plugin_path( $path ) {
|
85 |
+
if ( null !== $path ) {
|
86 |
$this->plugin_path = $path;
|
87 |
} else {
|
88 |
$this->plugin_path = realpath( plugin_dir_path( __FILE__ ) . '../../index.php' );
|
89 |
}
|
90 |
}
|
|
|
91 |
}
|
92 |
+
}
|
app/helper/rtDimensions.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
-
* Description of
|
10 |
*
|
11 |
* @author udit
|
12 |
*/
|
@@ -55,18 +55,20 @@ class rtDimensions extends rtForm {
|
|
55 |
return self::$default_class;
|
56 |
}
|
57 |
|
|
|
58 |
/**
|
59 |
* Embedd html class to html output.
|
60 |
*
|
61 |
* @access private
|
62 |
*
|
63 |
-
* @param
|
64 |
-
* @param
|
65 |
*
|
66 |
-
* @return string
|
|
|
67 |
*/
|
68 |
private function embedd_class( $element, $class = null ) {
|
69 |
-
$html = 'class
|
70 |
|
71 |
if ( isset( $class ) ) {
|
72 |
|
@@ -93,9 +95,10 @@ class rtDimensions extends rtForm {
|
|
93 |
protected function generate_dimensions( $attributes ) {
|
94 |
$element = 'rtDimension';
|
95 |
global $rtmedia;
|
96 |
-
$options
|
97 |
$defaults = array(
|
98 |
-
'desc'
|
|
|
99 |
);
|
100 |
|
101 |
$attributes = wp_parse_args( $attributes, $defaults );
|
@@ -103,39 +106,54 @@ class rtDimensions extends rtForm {
|
|
103 |
|
104 |
$html = '';
|
105 |
|
106 |
-
$html .= '<td>' .
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
if ( isset( $height ) ) {
|
111 |
-
$html .= '<td>' .
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
if ( isset( $crop ) ) {
|
117 |
-
$html .= '<td>' .
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
129 |
}
|
130 |
|
131 |
if ( $desc && $show_desc ) {
|
132 |
-
$html .= '<span class="clearfix large-offset-3 description">' . $desc . '</span>';
|
133 |
}
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
if ( isset( $attributes[ 'label' ] ) ) {
|
138 |
-
$html = parent::enclose_label( 'container', $html, $attributes[ 'label' ] );
|
139 |
}
|
140 |
|
141 |
return $html;
|
@@ -154,4 +172,8 @@ class rtDimensions extends rtForm {
|
|
154 |
return $this->generate_dimensions( $attributes );
|
155 |
}
|
156 |
|
|
|
|
|
|
|
|
|
157 |
}
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
+
* Description of rtDimension
|
10 |
*
|
11 |
* @author udit
|
12 |
*/
|
55 |
return self::$default_class;
|
56 |
}
|
57 |
|
58 |
+
|
59 |
/**
|
60 |
* Embedd html class to html output.
|
61 |
*
|
62 |
* @access private
|
63 |
*
|
64 |
+
* @param string $element
|
65 |
+
* @param null $class
|
66 |
*
|
67 |
+
* @return string
|
68 |
+
* @throws rtFormsInvalidArgumentsException
|
69 |
*/
|
70 |
private function embedd_class( $element, $class = null ) {
|
71 |
+
$html = 'class= "' . $this->get_default_class();
|
72 |
|
73 |
if ( isset( $class ) ) {
|
74 |
|
95 |
protected function generate_dimensions( $attributes ) {
|
96 |
$element = 'rtDimension';
|
97 |
global $rtmedia;
|
98 |
+
$options = $rtmedia->options;
|
99 |
$defaults = array(
|
100 |
+
'desc' => '',
|
101 |
+
'show_desc' => false,
|
102 |
);
|
103 |
|
104 |
$attributes = wp_parse_args( $attributes, $defaults );
|
106 |
|
107 |
$html = '';
|
108 |
|
109 |
+
$html .= '<td>' .
|
110 |
+
parent::get_number(
|
111 |
+
array(
|
112 |
+
'name' => "rtmedia-options[{$key}_width]",
|
113 |
+
'value' => $width,
|
114 |
+
'class' => array( 'small-text large-offset-1' ),
|
115 |
+
'show_desc' => $show_desc,
|
116 |
+
)
|
117 |
+
) .
|
118 |
+
'</td>';
|
119 |
|
120 |
if ( isset( $height ) ) {
|
121 |
+
$html .= '<td>' .
|
122 |
+
parent::get_number(
|
123 |
+
array(
|
124 |
+
'name' => "rtmedia-options[{$key}_height]",
|
125 |
+
'value' => $height,
|
126 |
+
'class' => array( 'small-text large-offset-1' ),
|
127 |
+
'show_desc' => $show_desc,
|
128 |
+
)
|
129 |
+
) .
|
130 |
+
'</td>';
|
131 |
}
|
132 |
|
133 |
if ( isset( $crop ) ) {
|
134 |
+
$html .= '<td>' .
|
135 |
+
parent::get_switch(
|
136 |
+
array(
|
137 |
+
'name' => "rtmedia-options[{$key}_crop]",
|
138 |
+
'rtForm_options' => array(
|
139 |
+
array(
|
140 |
+
'' => 1, //label would be blank
|
141 |
+
'checked' => $crop,
|
142 |
+
),
|
143 |
+
),
|
144 |
+
'value' => ( isset( $options[ "rtmedia-options[{$key}_crop]" ] ) ) ? $options[ "rtmedia-options[{$key}_crop]" ] : '0',
|
145 |
+
'show_desc' => $show_desc,
|
146 |
+
)
|
147 |
+
) .
|
148 |
+
'</td>';
|
149 |
}
|
150 |
|
151 |
if ( $desc && $show_desc ) {
|
152 |
+
$html .= '<span class="clearfix large-offset-3 description">' . esc_html( $desc ) . '</span>';
|
153 |
}
|
154 |
|
155 |
+
if ( isset( $attributes['label'] ) ) {
|
156 |
+
$html = parent::enclose_label( 'container', $html, $attributes['label'] );
|
|
|
|
|
157 |
}
|
158 |
|
159 |
return $html;
|
172 |
return $this->generate_dimensions( $attributes );
|
173 |
}
|
174 |
|
175 |
+
public function display_dimensions( $args = '' ) {
|
176 |
+
echo $this->get_dimensions( $args );
|
177 |
+
}
|
178 |
+
|
179 |
}
|
app/helper/rtForm.php
CHANGED
@@ -78,26 +78,26 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
78 |
* if id for any element is not given then these count will be used in id generation
|
79 |
*/
|
80 |
private static $id_counts = array(
|
81 |
-
'rtText'
|
82 |
-
'rtNumber'
|
83 |
-
'rtDate'
|
84 |
-
'rtRadio'
|
85 |
'rtCheckbox' => 0,
|
86 |
-
'rtSelect'
|
87 |
'rtTextarea' => 0,
|
88 |
-
'rtHidden'
|
89 |
-
'rtWysiwyg'
|
90 |
);
|
91 |
private static $default_classes = array(
|
92 |
-
'rtText'
|
93 |
-
'rtNumber'
|
94 |
-
'rtDate'
|
95 |
-
'rtRadio'
|
96 |
'rtCheckbox' => 'rtm-form-checkbox',
|
97 |
-
'rtSelect'
|
98 |
'rtTextarea' => 'rtm-form-textarea',
|
99 |
-
'rtHidden'
|
100 |
-
'rtWysiwyg'
|
101 |
);
|
102 |
|
103 |
/**
|
@@ -142,18 +142,19 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
142 |
* @access private
|
143 |
*
|
144 |
* @param string $element
|
145 |
-
* @param array
|
146 |
*
|
147 |
* @return string $html
|
|
|
148 |
*/
|
149 |
private function embedd_class( $element, $class = null ) {
|
150 |
|
151 |
-
$html = 'class="' . $this->get_default_class( $element );
|
152 |
|
153 |
if ( isset( $class ) ) {
|
154 |
|
155 |
if ( is_array( $class ) ) {
|
156 |
-
$html .= ' ' . implode( ' ', $class );
|
157 |
} else {
|
158 |
throw new rtFormInvalidArgumentsException( 'class [' . $element . ']' );
|
159 |
}
|
@@ -177,10 +178,10 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
177 |
|
178 |
$html = 'id="';
|
179 |
if ( isset( $id ) ) {
|
180 |
-
$html .= $id . '"';
|
181 |
$this->element_id = $id;
|
182 |
} else {
|
183 |
-
$html .= $this->get_default_class( $element ) . '-' . $this->get_default_id( $element ) . '"';
|
184 |
$this->element_id = $this->get_default_class( $element ) . '-' . $this->get_default_id( $element );
|
185 |
$this->update_default_id( $element );
|
186 |
}
|
@@ -204,14 +205,14 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
204 |
$html = 'name="';
|
205 |
if ( $multiple ) {
|
206 |
|
207 |
-
$html .= isset( $name ) ? $name . '[]' : $element . '[]';
|
208 |
|
209 |
// for select - add multiple = multiple
|
210 |
-
if ( 'rtSelect'
|
211 |
$html .= 'multiple = "multiple"';
|
212 |
}
|
213 |
} else {
|
214 |
-
$html .= isset( $name ) ? $name : $element;
|
215 |
}
|
216 |
$html .= '"';
|
217 |
|
@@ -224,7 +225,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
224 |
* @access private
|
225 |
*
|
226 |
* @param string $element
|
227 |
-
* @param mixed
|
228 |
*
|
229 |
* @return string $html
|
230 |
*/
|
@@ -236,7 +237,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
236 |
case 'rtNumber': //number
|
237 |
case 'rtText' : //text
|
238 |
$html .= 'value="';
|
239 |
-
$html .= ( isset( $attributes[
|
240 |
$html .= '" ';
|
241 |
break;
|
242 |
|
@@ -249,7 +250,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
249 |
|
250 |
case 'rtCheckbox' : //checkbox
|
251 |
case 'rtRadio' : //radio
|
252 |
-
$html .= 'value = "' . $attributes[
|
253 |
break;
|
254 |
}
|
255 |
|
@@ -267,9 +268,9 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
267 |
*/
|
268 |
private function generate_element_desc( $attributes ) {
|
269 |
|
270 |
-
if ( isset( $attributes[
|
271 |
|
272 |
-
$html = '<span class="clearfix large-offset-3 description">' . $attributes[
|
273 |
|
274 |
return $html;
|
275 |
}
|
@@ -282,22 +283,22 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
282 |
*
|
283 |
* @access private
|
284 |
*
|
285 |
-
* @param
|
286 |
*
|
287 |
-
* @return string
|
|
|
288 |
*/
|
289 |
private function embedd_misc_attributes( $misc ) {
|
290 |
|
291 |
if ( ! is_array( $misc ) ) {
|
292 |
throw new rtFormInvalidArgumentsException( 'attributes : misc' );
|
293 |
-
|
294 |
return;
|
295 |
}
|
296 |
|
297 |
$html = '';
|
298 |
|
299 |
foreach ( $misc as $key => $value ) {
|
300 |
-
$html .= $key . '="' . $value . '" ';
|
301 |
}
|
302 |
|
303 |
return $html;
|
@@ -309,23 +310,23 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
309 |
* @access private
|
310 |
*
|
311 |
* @param string $element
|
312 |
-
* @param mixed
|
313 |
-
* @param
|
314 |
*
|
315 |
* @return string $html
|
316 |
*/
|
317 |
private function processAttributes( $element, $attributes, $container = false ) {
|
318 |
|
319 |
/* generating the id on its own if not provided otherwise taken from the parameter provided */
|
320 |
-
if ( isset( $attributes[
|
321 |
-
$html = $this->generate_element_id( $element, $attributes[
|
322 |
} else {
|
323 |
$html = $this->generate_element_id( $element ) . ' ';
|
324 |
}
|
325 |
|
326 |
/* name attrbute according to multiple flag */
|
327 |
-
$multiple = ( isset( $attributes[
|
328 |
-
$name
|
329 |
$html .= $this->generate_element_name( $element, $multiple, $name ) . ' ';
|
330 |
|
331 |
/*
|
@@ -334,15 +335,15 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
334 |
*/
|
335 |
if ( ! $container ) {
|
336 |
|
337 |
-
if ( isset( $attributes[
|
338 |
-
$html .= $this->embedd_class( $element, $attributes[
|
339 |
} else {
|
340 |
$html .= $this->embedd_class( $element );
|
341 |
}
|
342 |
}
|
343 |
|
344 |
-
if ( isset( $attributes[
|
345 |
-
$html .= ' ' . $this->embedd_misc_attributes( $attributes[
|
346 |
}
|
347 |
|
348 |
$html .= $this->generate_element_value( $element, $attributes );
|
@@ -356,50 +357,50 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
356 |
* @access private
|
357 |
*
|
358 |
* @param string $element
|
359 |
-
* @param array
|
360 |
-
* @param array
|
361 |
*
|
362 |
* @return string $html
|
363 |
*/
|
364 |
private function container_enclosed_elements( $element, $attrib, $rtForm_options ) {
|
365 |
|
366 |
-
$html = '';
|
367 |
$size = count( $rtForm_options );
|
368 |
-
if ( isset( $attrib[
|
369 |
-
$id = $attrib[
|
370 |
}
|
371 |
|
372 |
foreach ( $rtForm_options as $opt ) {
|
373 |
|
374 |
-
if ( isset( $attrib[
|
375 |
-
$attrib[
|
376 |
$this->update_default_id( $element );
|
377 |
}
|
378 |
|
379 |
-
foreach ( (
|
380 |
|
381 |
-
if ( 'checked'
|
382 |
-
$attrib[
|
383 |
} else {
|
384 |
-
if ( 'selected'
|
385 |
-
$attrib[
|
386 |
} else {
|
387 |
-
if ( 'desc'
|
388 |
-
$attrib[
|
389 |
} else {
|
390 |
-
if ( 'id'
|
391 |
-
$attrib[
|
392 |
} else {
|
393 |
-
$attrib[
|
394 |
-
$attrib[
|
395 |
}
|
396 |
}
|
397 |
}
|
398 |
}
|
399 |
}
|
400 |
|
401 |
-
$checked = ( isset( $attrib[
|
402 |
-
if ( isset( $attrib[
|
403 |
$switch = 'data-toggle="switch"';
|
404 |
} else {
|
405 |
$switch = '';
|
@@ -414,33 +415,33 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
414 |
$data = '<input type="checkbox" ' . $checked . ' ' . $switch . ' ';
|
415 |
break;
|
416 |
case 'rtSelect' :
|
417 |
-
$selected = ( $attrib[
|
418 |
-
$data
|
419 |
break;
|
420 |
}
|
421 |
|
422 |
-
if ( 'rtSelect'
|
423 |
$data .= $this->processAttributes( $element, $attrib, true );
|
424 |
|
425 |
// span elements for checkbox on/off switch
|
426 |
-
if ( 'rtCheckbox'
|
427 |
$data .= '<span class="switch-label" data-on="On" data-off="Off"></span><span class="switch-handle"></span>';
|
428 |
}
|
429 |
|
430 |
-
if ( isset( $attrib[
|
431 |
|
432 |
$data = '<div class="rt-switch switch-square" data-on-label="<i class=\'fui-check\'></i>" data-off-label="<i class=\'fui-cross\'></i>">' . $data . '</div>';
|
433 |
} else {
|
434 |
-
if ( ( isset( $attrib[
|
435 |
|
436 |
$label_class = array( 'switch' );
|
437 |
|
438 |
-
$data = $this->enclose_label( $element, $data, $attrib[
|
439 |
if ( $size > 1 ) {
|
440 |
$data = '<div>' . $data . '</div>';
|
441 |
}
|
442 |
} else {
|
443 |
-
$data = $this->enclose_label( $element, $data, $attrib[
|
444 |
}
|
445 |
}
|
446 |
|
@@ -449,41 +450,43 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
449 |
|
450 |
$html .= $data;
|
451 |
|
452 |
-
unset( $attrib[
|
453 |
-
unset( $attrib[
|
454 |
-
unset( $attrib[
|
455 |
}
|
456 |
|
457 |
return $html;
|
458 |
}
|
459 |
|
460 |
/**
|
461 |
-
*
|
462 |
*
|
463 |
* @access private
|
464 |
*
|
465 |
-
* @param
|
466 |
-
* @param
|
467 |
*
|
|
|
|
|
468 |
*/
|
469 |
private function parse_multiple_options( $element, $attributes ) {
|
470 |
|
471 |
if ( is_array( $attributes ) ) {
|
472 |
|
473 |
-
if ( isset( $attributes[
|
474 |
|
475 |
$attribKeys = array_keys( $attributes );
|
476 |
-
$attrib
|
477 |
|
478 |
foreach ( $attribKeys as $key ) {
|
479 |
-
if ( 'rtForm_options'
|
480 |
$attrib[ $key ] = $attributes[ $key ];
|
481 |
}
|
482 |
}
|
483 |
|
484 |
-
$rtForm_options = (
|
485 |
|
486 |
-
return array( 'attrib' => $attrib, 'rtForm_options' => $rtForm_options
|
487 |
} else {
|
488 |
throw new rtFormInvalidArgumentsException( 'rtForm_options [' . $element . ']' );
|
489 |
}
|
@@ -497,23 +500,23 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
497 |
*
|
498 |
* @access protected
|
499 |
*
|
500 |
-
* @param
|
501 |
-
* @param
|
502 |
-
* @param
|
503 |
-
* @param
|
504 |
*
|
505 |
-
* @return string
|
506 |
*/
|
507 |
protected function enclose_label( $element, $html, $label, $class = false ) {
|
508 |
|
509 |
$labelClass = '';
|
510 |
if ( ! empty( $class ) && is_array( $class ) ) {
|
511 |
-
$labelClass = 'class="' . implode( ' ', $class ) . '"';
|
512 |
}
|
513 |
|
514 |
-
$data = '<label for="' . $this->element_id . '" ' . $labelClass . '>';
|
515 |
|
516 |
-
if ( 'rtRadio'
|
517 |
$data .= $html . ' ' . $label;
|
518 |
} else {
|
519 |
$data .= $label . ' ' . $html;
|
@@ -529,9 +532,10 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
529 |
*
|
530 |
* @access protected
|
531 |
*
|
532 |
-
* @param
|
533 |
*
|
534 |
-
* @return string
|
|
|
535 |
*/
|
536 |
protected function generate_textbox( $attributes ) {
|
537 |
|
@@ -547,15 +551,15 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
547 |
/* ending the tag */
|
548 |
$html .= ' />';
|
549 |
|
550 |
-
if ( isset( $attributes[
|
551 |
-
if ( isset( $attributes[
|
552 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
553 |
} else {
|
554 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
555 |
}
|
556 |
}
|
557 |
|
558 |
-
if ( isset( $attributes[
|
559 |
$html .= $this->generate_element_desc( $attributes );
|
560 |
}
|
561 |
|
@@ -570,23 +574,29 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
570 |
*
|
571 |
* @access public
|
572 |
*
|
573 |
-
* @param
|
574 |
*
|
575 |
* @return string
|
|
|
576 |
*/
|
577 |
public function get_textbox( $attributes = '' ) {
|
578 |
|
579 |
return $this->generate_textbox( $attributes );
|
580 |
}
|
581 |
|
|
|
|
|
|
|
|
|
582 |
/**
|
583 |
-
* Generate rtmedia html number field in admin options
|
584 |
*
|
585 |
* @access protected
|
586 |
*
|
587 |
-
* @param
|
588 |
*
|
589 |
-
* @return string
|
|
|
590 |
*/
|
591 |
protected function generate_number( $attributes ) {
|
592 |
|
@@ -598,28 +608,28 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
598 |
|
599 |
/* generating attributes */
|
600 |
$html .= $this->processAttributes( $element, $attributes );
|
601 |
-
if ( isset( $attributes[
|
602 |
-
$html .= " min='" . $attributes[
|
603 |
}
|
604 |
-
if ( isset( $attributes[
|
605 |
-
$html .= " max='" . $attributes[
|
606 |
}
|
607 |
-
if ( isset( $attributes[
|
608 |
-
$html .= " step='" . $attributes[
|
609 |
}
|
610 |
|
611 |
/* ending the tag */
|
612 |
$html .= ' />';
|
613 |
|
614 |
-
if ( isset( $attributes[
|
615 |
-
if ( isset( $attributes[
|
616 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
617 |
} else {
|
618 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
619 |
}
|
620 |
}
|
621 |
|
622 |
-
if ( isset( $attributes[
|
623 |
$html .= $this->generate_element_desc( $attributes );
|
624 |
}
|
625 |
|
@@ -634,7 +644,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
634 |
*
|
635 |
* @access public
|
636 |
*
|
637 |
-
* @param array $attributes
|
638 |
*
|
639 |
* @return string
|
640 |
*/
|
@@ -643,14 +653,19 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
643 |
return $this->generate_number( $attributes );
|
644 |
}
|
645 |
|
|
|
|
|
|
|
|
|
646 |
/**
|
647 |
* Generate rtmedia html date field in admin options.
|
648 |
*
|
649 |
* @access protected
|
650 |
*
|
651 |
-
* @param
|
652 |
*
|
653 |
-
* @return string
|
|
|
654 |
*/
|
655 |
protected function generate_date( $attributes ) {
|
656 |
|
@@ -662,15 +677,15 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
662 |
|
663 |
$html .= ' />';
|
664 |
|
665 |
-
if ( isset( $attributes[
|
666 |
-
if ( isset( $attributes[
|
667 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
668 |
} else {
|
669 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
670 |
}
|
671 |
}
|
672 |
|
673 |
-
if ( isset( $attributes[
|
674 |
$html .= $this->generate_element_desc( $attributes );
|
675 |
}
|
676 |
|
@@ -698,9 +713,10 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
698 |
*
|
699 |
* @access protected
|
700 |
*
|
701 |
-
* @param
|
702 |
*
|
703 |
-
* @return string
|
|
|
704 |
*/
|
705 |
protected function generate_hidden( $attributes ) {
|
706 |
|
@@ -716,15 +732,15 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
716 |
/* ending the tag */
|
717 |
$html .= ' />';
|
718 |
|
719 |
-
if ( isset( $attributes[
|
720 |
-
if ( isset( $attributes[
|
721 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
722 |
} else {
|
723 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
724 |
}
|
725 |
}
|
726 |
|
727 |
-
if ( isset( $attributes[
|
728 |
$html .= $this->generate_element_desc( $attributes );
|
729 |
}
|
730 |
|
@@ -739,7 +755,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
739 |
*
|
740 |
* @access public
|
741 |
*
|
742 |
-
* @param array $attributes
|
743 |
*
|
744 |
* @return string
|
745 |
*/
|
@@ -753,9 +769,10 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
753 |
*
|
754 |
* @access protected
|
755 |
*
|
756 |
-
* @param
|
757 |
*
|
758 |
-
* @return string
|
|
|
759 |
*/
|
760 |
protected function generate_textarea( $attributes ) {
|
761 |
|
@@ -766,19 +783,19 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
766 |
$html .= $this->processAttributes( $element, $attributes );
|
767 |
$html .= '>';
|
768 |
|
769 |
-
$html .= ( isset( $attributes[
|
770 |
|
771 |
$html .= '</textarea>';
|
772 |
|
773 |
-
if ( isset( $attributes[
|
774 |
-
if ( isset( $attributes[
|
775 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
776 |
} else {
|
777 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
778 |
}
|
779 |
}
|
780 |
|
781 |
-
if ( isset( $attributes[
|
782 |
$html .= $this->generate_element_desc( $attributes );
|
783 |
}
|
784 |
|
@@ -793,7 +810,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
793 |
*
|
794 |
* @access public
|
795 |
*
|
796 |
-
* @param array $attributes
|
797 |
*
|
798 |
* @return string
|
799 |
*/
|
@@ -802,6 +819,10 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
802 |
return $this->generate_textarea( $attributes );
|
803 |
}
|
804 |
|
|
|
|
|
|
|
|
|
805 |
/* wysiwyg
|
806 |
*
|
807 |
* pending as of now.
|
@@ -809,32 +830,32 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
809 |
* functionality and flow needs to be decided
|
810 |
*
|
811 |
* */
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
|
839 |
/**
|
840 |
* Generate rtmedia html input type radio in admin options.
|
@@ -848,18 +869,18 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
848 |
protected function generate_radio( $attributes ) {
|
849 |
|
850 |
$element = 'rtRadio';
|
851 |
-
$html
|
852 |
|
853 |
$meta = $this->parse_multiple_options( $element, $attributes );
|
854 |
-
$html .= $this->container_enclosed_elements( $element, $meta[
|
855 |
|
856 |
-
if ( isset( $attributes[
|
857 |
$html .= $this->generate_element_desc( $attributes );
|
858 |
}
|
859 |
|
860 |
$container = '<span ';
|
861 |
-
if ( isset( $attributes[
|
862 |
-
$container .= $this->embedd_class( $element, $attributes[
|
863 |
} else {
|
864 |
$container .= $this->embedd_class( $element );
|
865 |
}
|
@@ -869,9 +890,6 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
869 |
|
870 |
$container .= '</span>';
|
871 |
|
872 |
-
// if( isset($attributes['label']) )
|
873 |
-
// $container = $this->enclose_label('container', $container, $attributes['label']);
|
874 |
-
|
875 |
return $container;
|
876 |
}
|
877 |
|
@@ -880,7 +898,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
880 |
*
|
881 |
* @access public
|
882 |
*
|
883 |
-
* @param array $attributes
|
884 |
*
|
885 |
* @return string
|
886 |
*/
|
@@ -889,6 +907,10 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
889 |
return $this->generate_radio( $attributes );
|
890 |
}
|
891 |
|
|
|
|
|
|
|
|
|
892 |
/**
|
893 |
* Generate rtmedia html input type checkbox in admin options.
|
894 |
*
|
@@ -901,18 +923,18 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
901 |
protected function generate_checkbox( $attributes ) {
|
902 |
|
903 |
$element = 'rtCheckbox';
|
904 |
-
$html
|
905 |
|
906 |
$meta = $this->parse_multiple_options( $element, $attributes );
|
907 |
-
$html .= $this->container_enclosed_elements( $element, $meta[
|
908 |
|
909 |
-
if ( isset( $attributes[
|
910 |
$html .= $this->generate_element_desc( $attributes );
|
911 |
}
|
912 |
|
913 |
$container = '<span ';
|
914 |
-
if ( isset( $attributes[
|
915 |
-
$container .= $this->embedd_class( $element, $attributes[
|
916 |
} else {
|
917 |
$container .= $this->embedd_class( $element );
|
918 |
}
|
@@ -922,9 +944,6 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
922 |
|
923 |
$container .= '</span>';
|
924 |
|
925 |
-
// if( isset($attributes['label']) )
|
926 |
-
// $container = $this->enclose_label('container', $container, $attributes['label']);
|
927 |
-
|
928 |
return $container;
|
929 |
}
|
930 |
|
@@ -933,7 +952,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
933 |
*
|
934 |
* @access public
|
935 |
*
|
936 |
-
* @param array $attributes
|
937 |
*
|
938 |
* @return string
|
939 |
*/
|
@@ -947,29 +966,33 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
947 |
*
|
948 |
* @access public
|
949 |
*
|
950 |
-
* @param array $attributes
|
951 |
*
|
952 |
* @return string
|
953 |
*/
|
954 |
public function get_switch( $attributes = '' ) {
|
955 |
|
956 |
-
$attributes[
|
957 |
|
958 |
return $this->generate_checkbox( $attributes );
|
959 |
}
|
960 |
|
|
|
|
|
|
|
|
|
961 |
/**
|
962 |
* Get rtmedia html input type checkbox (get_switch_square) in admin options.
|
963 |
*
|
964 |
* @access public
|
965 |
*
|
966 |
-
* @param array $attributes
|
967 |
*
|
968 |
* @return string
|
969 |
*/
|
970 |
public function get_switch_square( $attributes = '' ) {
|
971 |
|
972 |
-
$attributes[
|
973 |
|
974 |
return $this->generate_checkbox( $attributes );
|
975 |
}
|
@@ -979,52 +1002,53 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
979 |
*
|
980 |
* @access protected
|
981 |
*
|
982 |
-
* @param
|
983 |
*
|
984 |
-
* @return string
|
|
|
985 |
*/
|
986 |
protected function generate_select( $attributes ) {
|
987 |
|
988 |
if ( is_array( $attributes ) ) {
|
989 |
$element = 'rtSelect';
|
990 |
-
$html
|
991 |
|
992 |
-
if ( isset( $attributes[
|
993 |
-
$id = $attributes[
|
994 |
} else {
|
995 |
$id = $element . $this->get_default_id( $element );
|
996 |
$this->update_default_id( $element );
|
997 |
}
|
998 |
$html .= $this->generate_element_id( $element, $id ) . ' ';
|
999 |
-
$multiple = ( isset( $attributes[
|
1000 |
-
$name
|
1001 |
$html .= $this->generate_element_name( $element, $multiple, $name ) . ' ';
|
1002 |
-
if ( isset( $attributes[
|
1003 |
-
$html .= $this->embedd_class( $element, $attributes[
|
1004 |
} else {
|
1005 |
$html .= $this->embedd_class( $element );
|
1006 |
}
|
1007 |
|
1008 |
-
if ( isset( $attributes[
|
1009 |
-
$html .= ' ' . $this->embedd_misc_attributes( $attributes[
|
1010 |
}
|
1011 |
|
1012 |
$html .= '>';
|
1013 |
|
1014 |
$meta = $this->parse_multiple_options( $element, $attributes );
|
1015 |
-
$html .= $this->container_enclosed_elements( $element, $meta[
|
1016 |
|
1017 |
$html .= '</select>';
|
1018 |
|
1019 |
-
if ( isset( $attributes[
|
1020 |
-
if ( isset( $attributes[
|
1021 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
1022 |
} else {
|
1023 |
-
$html = $this->enclose_label( $element, $html, $attributes[
|
1024 |
}
|
1025 |
}
|
1026 |
|
1027 |
-
if ( isset( $attributes[
|
1028 |
$html .= $this->generate_element_desc( $attributes );
|
1029 |
}
|
1030 |
|
@@ -1039,7 +1063,7 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
1039 |
*
|
1040 |
* @access public
|
1041 |
*
|
1042 |
-
* @param array $attributes
|
1043 |
*
|
1044 |
* @return string
|
1045 |
*/
|
@@ -1048,6 +1072,9 @@ if ( ! class_exists( 'rtForm' ) ) {
|
|
1048 |
return $this->generate_select( $attributes );
|
1049 |
}
|
1050 |
|
|
|
|
|
|
|
1051 |
}
|
1052 |
|
1053 |
-
}
|
78 |
* if id for any element is not given then these count will be used in id generation
|
79 |
*/
|
80 |
private static $id_counts = array(
|
81 |
+
'rtText' => 0,
|
82 |
+
'rtNumber' => 0,
|
83 |
+
'rtDate' => 0,
|
84 |
+
'rtRadio' => 0,
|
85 |
'rtCheckbox' => 0,
|
86 |
+
'rtSelect' => 0,
|
87 |
'rtTextarea' => 0,
|
88 |
+
'rtHidden' => 0,
|
89 |
+
'rtWysiwyg' => 0,
|
90 |
);
|
91 |
private static $default_classes = array(
|
92 |
+
'rtText' => 'rtm-form-text',
|
93 |
+
'rtNumber' => 'rtm-form-number',
|
94 |
+
'rtDate' => 'rtm-form-date',
|
95 |
+
'rtRadio' => 'rtm-form-radio',
|
96 |
'rtCheckbox' => 'rtm-form-checkbox',
|
97 |
+
'rtSelect' => 'rtm-form-select',
|
98 |
'rtTextarea' => 'rtm-form-textarea',
|
99 |
+
'rtHidden' => 'rtm-form-hidden',
|
100 |
+
'rtWysiwyg' => 'rtm-form-wysiwyg',
|
101 |
);
|
102 |
|
103 |
/**
|
142 |
* @access private
|
143 |
*
|
144 |
* @param string $element
|
145 |
+
* @param array $class
|
146 |
*
|
147 |
* @return string $html
|
148 |
+
* @throws rtFormInvalidArgumentsException
|
149 |
*/
|
150 |
private function embedd_class( $element, $class = null ) {
|
151 |
|
152 |
+
$html = 'class="' . esc_attr( $this->get_default_class( $element ) );
|
153 |
|
154 |
if ( isset( $class ) ) {
|
155 |
|
156 |
if ( is_array( $class ) ) {
|
157 |
+
$html .= ' ' . esc_attr( implode( ' ', $class ) );
|
158 |
} else {
|
159 |
throw new rtFormInvalidArgumentsException( 'class [' . $element . ']' );
|
160 |
}
|
178 |
|
179 |
$html = 'id="';
|
180 |
if ( isset( $id ) ) {
|
181 |
+
$html .= esc_attr( $id ) . '"';
|
182 |
$this->element_id = $id;
|
183 |
} else {
|
184 |
+
$html .= esc_attr( $this->get_default_class( $element ) . '-' . $this->get_default_id( $element ) ) . '"';
|
185 |
$this->element_id = $this->get_default_class( $element ) . '-' . $this->get_default_id( $element );
|
186 |
$this->update_default_id( $element );
|
187 |
}
|
205 |
$html = 'name="';
|
206 |
if ( $multiple ) {
|
207 |
|
208 |
+
$html .= esc_attr( isset( $name ) ? $name . '[]' : $element . '[]' );
|
209 |
|
210 |
// for select - add multiple = multiple
|
211 |
+
if ( 'rtSelect' === $element ) {
|
212 |
$html .= 'multiple = "multiple"';
|
213 |
}
|
214 |
} else {
|
215 |
+
$html .= esc_attr( isset( $name ) ? $name : $element );
|
216 |
}
|
217 |
$html .= '"';
|
218 |
|
225 |
* @access private
|
226 |
*
|
227 |
* @param string $element
|
228 |
+
* @param mixed $attributes
|
229 |
*
|
230 |
* @return string $html
|
231 |
*/
|
237 |
case 'rtNumber': //number
|
238 |
case 'rtText' : //text
|
239 |
$html .= 'value="';
|
240 |
+
$html .= esc_attr( ( isset( $attributes['value'] ) ) ? $attributes['value'] : '' );
|
241 |
$html .= '" ';
|
242 |
break;
|
243 |
|
250 |
|
251 |
case 'rtCheckbox' : //checkbox
|
252 |
case 'rtRadio' : //radio
|
253 |
+
$html .= 'value = "' . esc_attr( $attributes['value'] ) . '">';
|
254 |
break;
|
255 |
}
|
256 |
|
268 |
*/
|
269 |
private function generate_element_desc( $attributes ) {
|
270 |
|
271 |
+
if ( isset( $attributes['desc'] ) ) {
|
272 |
|
273 |
+
$html = '<span class="clearfix large-offset-3 description">' . esc_html( $attributes['desc'] ) . '</span>';
|
274 |
|
275 |
return $html;
|
276 |
}
|
283 |
*
|
284 |
* @access private
|
285 |
*
|
286 |
+
* @param $misc
|
287 |
*
|
288 |
+
* @return string|void
|
289 |
+
* @throws rtFormInvalidArgumentsException
|
290 |
*/
|
291 |
private function embedd_misc_attributes( $misc ) {
|
292 |
|
293 |
if ( ! is_array( $misc ) ) {
|
294 |
throw new rtFormInvalidArgumentsException( 'attributes : misc' );
|
|
|
295 |
return;
|
296 |
}
|
297 |
|
298 |
$html = '';
|
299 |
|
300 |
foreach ( $misc as $key => $value ) {
|
301 |
+
$html .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
302 |
}
|
303 |
|
304 |
return $html;
|
310 |
* @access private
|
311 |
*
|
312 |
* @param string $element
|
313 |
+
* @param mixed $attributes
|
314 |
+
* @param bool $container
|
315 |
*
|
316 |
* @return string $html
|
317 |
*/
|
318 |
private function processAttributes( $element, $attributes, $container = false ) {
|
319 |
|
320 |
/* generating the id on its own if not provided otherwise taken from the parameter provided */
|
321 |
+
if ( isset( $attributes['id'] ) ) {
|
322 |
+
$html = $this->generate_element_id( $element, $attributes['id'] ) . ' ';
|
323 |
} else {
|
324 |
$html = $this->generate_element_id( $element ) . ' ';
|
325 |
}
|
326 |
|
327 |
/* name attrbute according to multiple flag */
|
328 |
+
$multiple = ( isset( $attributes['multiple'] ) && $attributes['multiple'] ) ? true : false;
|
329 |
+
$name = ( isset( $attributes['name'] ) ) ? $attributes['name'] : $element;
|
330 |
$html .= $this->generate_element_name( $element, $multiple, $name ) . ' ';
|
331 |
|
332 |
/*
|
335 |
*/
|
336 |
if ( ! $container ) {
|
337 |
|
338 |
+
if ( isset( $attributes['class'] ) ) {
|
339 |
+
$html .= $this->embedd_class( $element, $attributes['class'] );
|
340 |
} else {
|
341 |
$html .= $this->embedd_class( $element );
|
342 |
}
|
343 |
}
|
344 |
|
345 |
+
if ( isset( $attributes['misc'] ) ) {
|
346 |
+
$html .= ' ' . $this->embedd_misc_attributes( $attributes['misc'] );
|
347 |
}
|
348 |
|
349 |
$html .= $this->generate_element_value( $element, $attributes );
|
357 |
* @access private
|
358 |
*
|
359 |
* @param string $element
|
360 |
+
* @param array $attrib
|
361 |
+
* @param array $rtForm_options
|
362 |
*
|
363 |
* @return string $html
|
364 |
*/
|
365 |
private function container_enclosed_elements( $element, $attrib, $rtForm_options ) {
|
366 |
|
367 |
+
$html = $id = '';
|
368 |
$size = count( $rtForm_options );
|
369 |
+
if ( isset( $attrib['id'] ) ) {
|
370 |
+
$id = $attrib['id'];
|
371 |
}
|
372 |
|
373 |
foreach ( $rtForm_options as $opt ) {
|
374 |
|
375 |
+
if ( isset( $attrib['id'] ) && $size > 1 ) {
|
376 |
+
$attrib['id'] = $id . '-' . $this->get_default_id( $element );
|
377 |
$this->update_default_id( $element );
|
378 |
}
|
379 |
|
380 |
+
foreach ( (array) $opt as $key => $val ) {
|
381 |
|
382 |
+
if ( 'checked' === $key ) {
|
383 |
+
$attrib['checked'] = esc_attr( $val );
|
384 |
} else {
|
385 |
+
if ( 'selected' === $key ) {
|
386 |
+
$attrib['selected'] = esc_attr( $val );
|
387 |
} else {
|
388 |
+
if ( 'desc' === $key ) {
|
389 |
+
$attrib['desc'] = esc_attr( $val );
|
390 |
} else {
|
391 |
+
if ( 'id' === $key ) {
|
392 |
+
$attrib['id'] = esc_attr( $val );
|
393 |
} else {
|
394 |
+
$attrib['key'] = $key;
|
395 |
+
$attrib['value'] = esc_attr( $val );
|
396 |
}
|
397 |
}
|
398 |
}
|
399 |
}
|
400 |
}
|
401 |
|
402 |
+
$checked = ( isset( $attrib['checked'] ) && $attrib['checked'] ) ? 'checked=checked' : '';
|
403 |
+
if ( isset( $attrib['switch'] ) && $attrib['switch'] ) {
|
404 |
$switch = 'data-toggle="switch"';
|
405 |
} else {
|
406 |
$switch = '';
|
415 |
$data = '<input type="checkbox" ' . $checked . ' ' . $switch . ' ';
|
416 |
break;
|
417 |
case 'rtSelect' :
|
418 |
+
$selected = ( $attrib['selected'] ) ? 'selected=selected' : '';
|
419 |
+
$data = '<option value="' . esc_attr( $attrib['value'] ) . '" ' . $selected . '>' . esc_html( $attrib['key'] ) . '</option>';
|
420 |
break;
|
421 |
}
|
422 |
|
423 |
+
if ( 'rtSelect' !== $element ) {
|
424 |
$data .= $this->processAttributes( $element, $attrib, true );
|
425 |
|
426 |
// span elements for checkbox on/off switch
|
427 |
+
if ( 'rtCheckbox' === $element ) {
|
428 |
$data .= '<span class="switch-label" data-on="On" data-off="Off"></span><span class="switch-handle"></span>';
|
429 |
}
|
430 |
|
431 |
+
if ( isset( $attrib['switch_square'] ) && $attrib['switch_square'] ) {
|
432 |
|
433 |
$data = '<div class="rt-switch switch-square" data-on-label="<i class=\'fui-check\'></i>" data-off-label="<i class=\'fui-cross\'></i>">' . $data . '</div>';
|
434 |
} else {
|
435 |
+
if ( ( isset( $attrib['switch'] ) && $attrib['switch'] ) || ( isset( $attrib['switch_square'] ) && $attrib['switch_square'] ) ) {
|
436 |
|
437 |
$label_class = array( 'switch' );
|
438 |
|
439 |
+
$data = $this->enclose_label( $element, $data, $attrib['key'], $label_class );
|
440 |
if ( $size > 1 ) {
|
441 |
$data = '<div>' . $data . '</div>';
|
442 |
}
|
443 |
} else {
|
444 |
+
$data = $this->enclose_label( $element, $data, $attrib['key'] );
|
445 |
}
|
446 |
}
|
447 |
|
450 |
|
451 |
$html .= $data;
|
452 |
|
453 |
+
unset( $attrib['id'] );
|
454 |
+
unset( $attrib['key'] );
|
455 |
+
unset( $attrib['value'] );
|
456 |
}
|
457 |
|
458 |
return $html;
|
459 |
}
|
460 |
|
461 |
/**
|
462 |
+
*Parse multiple options in admin options.
|
463 |
*
|
464 |
* @access private
|
465 |
*
|
466 |
+
* @param $element
|
467 |
+
* @param $attributes
|
468 |
*
|
469 |
+
* @return array
|
470 |
+
* @throws rtFormInvalidArgumentsException
|
471 |
*/
|
472 |
private function parse_multiple_options( $element, $attributes ) {
|
473 |
|
474 |
if ( is_array( $attributes ) ) {
|
475 |
|
476 |
+
if ( isset( $attributes['rtForm_options'] ) && is_array( $attributes['rtForm_options'] ) ) {
|
477 |
|
478 |
$attribKeys = array_keys( $attributes );
|
479 |
+
$attrib = array();
|
480 |
|
481 |
foreach ( $attribKeys as $key ) {
|
482 |
+
if ( 'rtForm_options' !== $key ) {
|
483 |
$attrib[ $key ] = $attributes[ $key ];
|
484 |
}
|
485 |
}
|
486 |
|
487 |
+
$rtForm_options = (array) $attributes['rtForm_options'];
|
488 |
|
489 |
+
return array( 'attrib' => $attrib, 'rtForm_options' => $rtForm_options );
|
490 |
} else {
|
491 |
throw new rtFormInvalidArgumentsException( 'rtForm_options [' . $element . ']' );
|
492 |
}
|
500 |
*
|
501 |
* @access protected
|
502 |
*
|
503 |
+
* @param $element
|
504 |
+
* @param $html
|
505 |
+
* @param $label
|
506 |
+
* @param bool $class
|
507 |
*
|
508 |
+
* @return string
|
509 |
*/
|
510 |
protected function enclose_label( $element, $html, $label, $class = false ) {
|
511 |
|
512 |
$labelClass = '';
|
513 |
if ( ! empty( $class ) && is_array( $class ) ) {
|
514 |
+
$labelClass = 'class="' . esc_attr( implode( ' ', $class ) ) . '"';
|
515 |
}
|
516 |
|
517 |
+
$data = '<label for="' . esc_attr( $this->element_id ) . '" ' . $labelClass . '>';
|
518 |
|
519 |
+
if ( 'rtRadio' === $element || 'rtCheckbox' === $element ) {
|
520 |
$data .= $html . ' ' . $label;
|
521 |
} else {
|
522 |
$data .= $label . ' ' . $html;
|
532 |
*
|
533 |
* @access protected
|
534 |
*
|
535 |
+
* @param $attributes
|
536 |
*
|
537 |
+
* @return string
|
538 |
+
* @throws rtFormInvalidArgumentsException
|
539 |
*/
|
540 |
protected function generate_textbox( $attributes ) {
|
541 |
|
551 |
/* ending the tag */
|
552 |
$html .= ' />';
|
553 |
|
554 |
+
if ( isset( $attributes['label'] ) ) {
|
555 |
+
if ( isset( $attributes['labelClass'] ) ) {
|
556 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'], $attributes['labelClass'] );
|
557 |
} else {
|
558 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'] );
|
559 |
}
|
560 |
}
|
561 |
|
562 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
563 |
$html .= $this->generate_element_desc( $attributes );
|
564 |
}
|
565 |
|
574 |
*
|
575 |
* @access public
|
576 |
*
|
577 |
+
* @param string/array $attributes
|
578 |
*
|
579 |
* @return string
|
580 |
+
* @throws rtFormInvalidArgumentsException
|
581 |
*/
|
582 |
public function get_textbox( $attributes = '' ) {
|
583 |
|
584 |
return $this->generate_textbox( $attributes );
|
585 |
}
|
586 |
|
587 |
+
public function display_textbox( $args = '' ) {
|
588 |
+
echo $this->get_textbox( $args );
|
589 |
+
}
|
590 |
+
|
591 |
/**
|
592 |
+
* Generate rtmedia html number field in admin options
|
593 |
*
|
594 |
* @access protected
|
595 |
*
|
596 |
+
* @param $attributes
|
597 |
*
|
598 |
+
* @return string
|
599 |
+
* @throws rtFormInvalidArgumentsException
|
600 |
*/
|
601 |
protected function generate_number( $attributes ) {
|
602 |
|
608 |
|
609 |
/* generating attributes */
|
610 |
$html .= $this->processAttributes( $element, $attributes );
|
611 |
+
if ( isset( $attributes['min'] ) ) {
|
612 |
+
$html .= " min='" . esc_attr( $attributes['min'] ) . "' ";
|
613 |
}
|
614 |
+
if ( isset( $attributes['max'] ) ) {
|
615 |
+
$html .= " max='" . esc_attr( $attributes['max'] ) . "' ";
|
616 |
}
|
617 |
+
if ( isset( $attributes['step'] ) ) {
|
618 |
+
$html .= " step='" . esc_attr( $attributes['step'] ) . "' ";
|
619 |
}
|
620 |
|
621 |
/* ending the tag */
|
622 |
$html .= ' />';
|
623 |
|
624 |
+
if ( isset( $attributes['label'] ) ) {
|
625 |
+
if ( isset( $attributes['labelClass'] ) ) {
|
626 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'], $attributes['labelClass'] );
|
627 |
} else {
|
628 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'] );
|
629 |
}
|
630 |
}
|
631 |
|
632 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
633 |
$html .= $this->generate_element_desc( $attributes );
|
634 |
}
|
635 |
|
644 |
*
|
645 |
* @access public
|
646 |
*
|
647 |
+
* @param string/array $attributes
|
648 |
*
|
649 |
* @return string
|
650 |
*/
|
653 |
return $this->generate_number( $attributes );
|
654 |
}
|
655 |
|
656 |
+
public function display_number( $args = '' ) {
|
657 |
+
echo $this->get_number( $args );
|
658 |
+
}
|
659 |
+
|
660 |
/**
|
661 |
* Generate rtmedia html date field in admin options.
|
662 |
*
|
663 |
* @access protected
|
664 |
*
|
665 |
+
* @param $attributes
|
666 |
*
|
667 |
+
* @return string
|
668 |
+
* @throws rtFormInvalidArgumentsException
|
669 |
*/
|
670 |
protected function generate_date( $attributes ) {
|
671 |
|
677 |
|
678 |
$html .= ' />';
|
679 |
|
680 |
+
if ( isset( $attributes['label'] ) ) {
|
681 |
+
if ( isset( $attributes['labelClass'] ) ) {
|
682 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'], $attributes['labelClass'] );
|
683 |
} else {
|
684 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'] );
|
685 |
}
|
686 |
}
|
687 |
|
688 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['desc'] ) {
|
689 |
$html .= $this->generate_element_desc( $attributes );
|
690 |
}
|
691 |
|
713 |
*
|
714 |
* @access protected
|
715 |
*
|
716 |
+
* @param $attributes
|
717 |
*
|
718 |
+
* @return string
|
719 |
+
* @throws rtFormInvalidArgumentsException
|
720 |
*/
|
721 |
protected function generate_hidden( $attributes ) {
|
722 |
|
732 |
/* ending the tag */
|
733 |
$html .= ' />';
|
734 |
|
735 |
+
if ( isset( $attributes['label'] ) ) {
|
736 |
+
if ( isset( $attributes['labelClass'] ) ) {
|
737 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'], $attributes['labelClass'] );
|
738 |
} else {
|
739 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'] );
|
740 |
}
|
741 |
}
|
742 |
|
743 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
744 |
$html .= $this->generate_element_desc( $attributes );
|
745 |
}
|
746 |
|
755 |
*
|
756 |
* @access public
|
757 |
*
|
758 |
+
* @param string/array $attributes
|
759 |
*
|
760 |
* @return string
|
761 |
*/
|
769 |
*
|
770 |
* @access protected
|
771 |
*
|
772 |
+
* @param $attributes
|
773 |
*
|
774 |
+
* @return string
|
775 |
+
* @throws rtFormInvalidArgumentsException
|
776 |
*/
|
777 |
protected function generate_textarea( $attributes ) {
|
778 |
|
783 |
$html .= $this->processAttributes( $element, $attributes );
|
784 |
$html .= '>';
|
785 |
|
786 |
+
$html .= esc_html( ( isset( $attributes['value'] ) ) ? $attributes['value'] : '' );
|
787 |
|
788 |
$html .= '</textarea>';
|
789 |
|
790 |
+
if ( isset( $attributes['label'] ) ) {
|
791 |
+
if ( isset( $attributes['labelClass'] ) ) {
|
792 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'], $attributes['labelClass'] );
|
793 |
} else {
|
794 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'] );
|
795 |
}
|
796 |
}
|
797 |
|
798 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
799 |
$html .= $this->generate_element_desc( $attributes );
|
800 |
}
|
801 |
|
810 |
*
|
811 |
* @access public
|
812 |
*
|
813 |
+
* @param string/array $attributes
|
814 |
*
|
815 |
* @return string
|
816 |
*/
|
819 |
return $this->generate_textarea( $attributes );
|
820 |
}
|
821 |
|
822 |
+
public function display_textarea( $args = '' ) {
|
823 |
+
echo $this->get_textarea( $args );
|
824 |
+
}
|
825 |
+
|
826 |
/* wysiwyg
|
827 |
*
|
828 |
* pending as of now.
|
830 |
* functionality and flow needs to be decided
|
831 |
*
|
832 |
* */
|
833 |
+
/*
|
834 |
+
protected function generate_wysiwyg($attributes) {
|
835 |
+
$element = 'rtWysiwyg';
|
836 |
+
if( is_array($attributes) ) {
|
837 |
+
|
838 |
+
$id = isset( $attributes['id'] ) ? $attributes['id'] : $this->get_default_class($element) . "-" . $this->get_default_id($element);
|
839 |
+
$name = isset( $attributes['name'] ) ? $attributes['name'] : $element;
|
840 |
+
if(isset($attributes['class']))
|
841 |
+
$class = $this->embedd_class($element, $attributes['class']);
|
842 |
+
else
|
843 |
+
$class = $this->embedd_class($element);
|
844 |
+
$value = isset( $attributes['value'] ) ? $attributes['value'] : "";
|
845 |
+
|
846 |
+
echo '<label for="' . $id . '">';
|
847 |
+
wp_editor( $value, $id, array('textarea_name' => $name, 'editor_class' => $class) );
|
848 |
+
echo '</label>';
|
849 |
+
} else
|
850 |
+
throw new rtFormInvalidArgumentsException( "attributes" );
|
851 |
+
}
|
852 |
+
|
853 |
+
public function get_wysiwyg( $attributes = '' ) {
|
854 |
+
|
855 |
+
ob_start();
|
856 |
+
$this->generate_wysiwyg($attributes);
|
857 |
+
return ob_get_clean();
|
858 |
+
}*/
|
859 |
|
860 |
/**
|
861 |
* Generate rtmedia html input type radio in admin options.
|
869 |
protected function generate_radio( $attributes ) {
|
870 |
|
871 |
$element = 'rtRadio';
|
872 |
+
$html = '';
|
873 |
|
874 |
$meta = $this->parse_multiple_options( $element, $attributes );
|
875 |
+
$html .= $this->container_enclosed_elements( $element, $meta['attrib'], $meta['rtForm_options'] );
|
876 |
|
877 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
878 |
$html .= $this->generate_element_desc( $attributes );
|
879 |
}
|
880 |
|
881 |
$container = '<span ';
|
882 |
+
if ( isset( $attributes['class'] ) ) {
|
883 |
+
$container .= $this->embedd_class( $element, $attributes['class'] );
|
884 |
} else {
|
885 |
$container .= $this->embedd_class( $element );
|
886 |
}
|
890 |
|
891 |
$container .= '</span>';
|
892 |
|
|
|
|
|
|
|
893 |
return $container;
|
894 |
}
|
895 |
|
898 |
*
|
899 |
* @access public
|
900 |
*
|
901 |
+
* @param string/array $attributes
|
902 |
*
|
903 |
* @return string
|
904 |
*/
|
907 |
return $this->generate_radio( $attributes );
|
908 |
}
|
909 |
|
910 |
+
public function display_radio( $args = '' ) {
|
911 |
+
echo $this->get_radio( $args );
|
912 |
+
}
|
913 |
+
|
914 |
/**
|
915 |
* Generate rtmedia html input type checkbox in admin options.
|
916 |
*
|
923 |
protected function generate_checkbox( $attributes ) {
|
924 |
|
925 |
$element = 'rtCheckbox';
|
926 |
+
$html = '';
|
927 |
|
928 |
$meta = $this->parse_multiple_options( $element, $attributes );
|
929 |
+
$html .= $this->container_enclosed_elements( $element, $meta['attrib'], $meta['rtForm_options'] );
|
930 |
|
931 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
932 |
$html .= $this->generate_element_desc( $attributes );
|
933 |
}
|
934 |
|
935 |
$container = '<span ';
|
936 |
+
if ( isset( $attributes['class'] ) ) {
|
937 |
+
$container .= $this->embedd_class( $element, $attributes['class'] );
|
938 |
} else {
|
939 |
$container .= $this->embedd_class( $element );
|
940 |
}
|
944 |
|
945 |
$container .= '</span>';
|
946 |
|
|
|
|
|
|
|
947 |
return $container;
|
948 |
}
|
949 |
|
952 |
*
|
953 |
* @access public
|
954 |
*
|
955 |
+
* @param string/array $attributes
|
956 |
*
|
957 |
* @return string
|
958 |
*/
|
966 |
*
|
967 |
* @access public
|
968 |
*
|
969 |
+
* @param string/array $attributes
|
970 |
*
|
971 |
* @return string
|
972 |
*/
|
973 |
public function get_switch( $attributes = '' ) {
|
974 |
|
975 |
+
$attributes['switch'] = true;
|
976 |
|
977 |
return $this->generate_checkbox( $attributes );
|
978 |
}
|
979 |
|
980 |
+
public function display_switch( $args = '' ) {
|
981 |
+
echo $this->get_switch( $args );
|
982 |
+
}
|
983 |
+
|
984 |
/**
|
985 |
* Get rtmedia html input type checkbox (get_switch_square) in admin options.
|
986 |
*
|
987 |
* @access public
|
988 |
*
|
989 |
+
* @param string/array $attributes
|
990 |
*
|
991 |
* @return string
|
992 |
*/
|
993 |
public function get_switch_square( $attributes = '' ) {
|
994 |
|
995 |
+
$attributes['switch_square'] = true;
|
996 |
|
997 |
return $this->generate_checkbox( $attributes );
|
998 |
}
|
1002 |
*
|
1003 |
* @access protected
|
1004 |
*
|
1005 |
+
* @param $attributes
|
1006 |
*
|
1007 |
+
* @return string
|
1008 |
+
* @throws rtFormInvalidArgumentsException
|
1009 |
*/
|
1010 |
protected function generate_select( $attributes ) {
|
1011 |
|
1012 |
if ( is_array( $attributes ) ) {
|
1013 |
$element = 'rtSelect';
|
1014 |
+
$html = '<select ';
|
1015 |
|
1016 |
+
if ( isset( $attributes['id'] ) ) {
|
1017 |
+
$id = $attributes['id'];
|
1018 |
} else {
|
1019 |
$id = $element . $this->get_default_id( $element );
|
1020 |
$this->update_default_id( $element );
|
1021 |
}
|
1022 |
$html .= $this->generate_element_id( $element, $id ) . ' ';
|
1023 |
+
$multiple = ( isset( $attributes['multiple'] ) && $attributes['multiple'] ) ? true : false;
|
1024 |
+
$name = ( isset( $attributes['name'] ) ) ? $attributes['name'] : $element;
|
1025 |
$html .= $this->generate_element_name( $element, $multiple, $name ) . ' ';
|
1026 |
+
if ( isset( $attributes['class'] ) ) {
|
1027 |
+
$html .= $this->embedd_class( $element, $attributes['class'] );
|
1028 |
} else {
|
1029 |
$html .= $this->embedd_class( $element );
|
1030 |
}
|
1031 |
|
1032 |
+
if ( isset( $attributes['misc'] ) ) {
|
1033 |
+
$html .= ' ' . $this->embedd_misc_attributes( $attributes['misc'] );
|
1034 |
}
|
1035 |
|
1036 |
$html .= '>';
|
1037 |
|
1038 |
$meta = $this->parse_multiple_options( $element, $attributes );
|
1039 |
+
$html .= $this->container_enclosed_elements( $element, $meta['attrib'], $meta['rtForm_options'] );
|
1040 |
|
1041 |
$html .= '</select>';
|
1042 |
|
1043 |
+
if ( isset( $attributes['label'] ) ) {
|
1044 |
+
if ( isset( $attributes['labelClass'] ) ) {
|
1045 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'], $attributes['labelClass'] );
|
1046 |
} else {
|
1047 |
+
$html = $this->enclose_label( $element, $html, $attributes['label'] );
|
1048 |
}
|
1049 |
}
|
1050 |
|
1051 |
+
if ( isset( $attributes['show_desc'] ) && $attributes['show_desc'] ) {
|
1052 |
$html .= $this->generate_element_desc( $attributes );
|
1053 |
}
|
1054 |
|
1063 |
*
|
1064 |
* @access public
|
1065 |
*
|
1066 |
+
* @param string/array $attributes
|
1067 |
*
|
1068 |
* @return string
|
1069 |
*/
|
1072 |
return $this->generate_select( $attributes );
|
1073 |
}
|
1074 |
|
1075 |
+
public function display_select( $args = '' ) {
|
1076 |
+
echo $this->get_select( $args );
|
1077 |
+
}
|
1078 |
}
|
1079 |
|
1080 |
+
}
|
app/helper/rtFormInvalidArgumentsException.php
CHANGED
@@ -11,16 +11,17 @@
|
|
11 |
* @author udit
|
12 |
*/
|
13 |
|
14 |
-
if ( ! class_exists(
|
15 |
|
16 |
class rtFormInvalidArgumentsException extends Exception {
|
17 |
|
18 |
-
public function __construct( $msg ){
|
19 |
|
20 |
//Error Message
|
21 |
-
$errorMsg = sprintf(
|
|
|
22 |
|
23 |
-
echo $errorMsg;
|
24 |
}
|
25 |
}
|
26 |
-
}
|
11 |
* @author udit
|
12 |
*/
|
13 |
|
14 |
+
if ( ! class_exists( 'rtFormsInvalidArgumentsException' ) ) {
|
15 |
|
16 |
class rtFormInvalidArgumentsException extends Exception {
|
17 |
|
18 |
+
public function __construct( $msg ) {
|
19 |
|
20 |
//Error Message
|
21 |
+
$errorMsg = sprintf( esc_html__( 'Error on line %s in %s : ', 'buddypress-media' ), $this->getLine(), $this->getFile() );
|
22 |
+
$errorMsg .= '<b>' . sprintf( esc_html__( 'The method expects an array in arguments for %s provided.', 'buddypress-media' ), $msg ) . '</b>';
|
23 |
|
24 |
+
echo $errorMsg; // @codingStandardsIgnoreLine
|
25 |
}
|
26 |
}
|
27 |
+
}
|
app/helper/rtPluginUpdateChecker.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
class rtPluginUpdateChecker {
|
4 |
-
function __construct( $url, $path, $slug, $priority ){
|
5 |
//code removed
|
6 |
}
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
class rtPluginUpdateChecker {
|
4 |
+
function __construct( $url, $path, $slug, $priority ) {
|
5 |
//code removed
|
6 |
}
|
7 |
}
|
app/helper/rtProgress.php
CHANGED
@@ -26,19 +26,21 @@ class rtProgress {
|
|
26 |
* Show progress_ui.
|
27 |
*
|
28 |
* @access public
|
29 |
-
*
|
30 |
-
* @param
|
|
|
|
|
31 |
* @return string $progress_ui
|
32 |
*/
|
33 |
public function progress_ui( $progress, $echo = true ) {
|
34 |
$progress_ui = '
|
35 |
<div id="rtprogressbar">
|
36 |
-
<div style="width:'
|
37 |
</div>
|
38 |
';
|
39 |
|
40 |
-
if ( $echo ){
|
41 |
-
echo $progress_ui;
|
42 |
} else {
|
43 |
return $progress_ui;
|
44 |
}
|
@@ -48,16 +50,17 @@ class rtProgress {
|
|
48 |
* Calculate progress %.
|
49 |
*
|
50 |
* @access public
|
51 |
-
*
|
52 |
-
* @param float
|
|
|
|
|
53 |
* @return float
|
54 |
*/
|
55 |
public function progress( $progress, $total ) {
|
56 |
-
if ( $total < 1 ){
|
57 |
return 100;
|
58 |
}
|
59 |
|
60 |
return ( $progress / $total ) * 100;
|
61 |
}
|
62 |
-
|
63 |
}
|
26 |
* Show progress_ui.
|
27 |
*
|
28 |
* @access public
|
29 |
+
*
|
30 |
+
* @param float $progress
|
31 |
+
* @param bool $echo
|
32 |
+
*
|
33 |
* @return string $progress_ui
|
34 |
*/
|
35 |
public function progress_ui( $progress, $echo = true ) {
|
36 |
$progress_ui = '
|
37 |
<div id="rtprogressbar">
|
38 |
+
<div style="width:' . esc_attr( $progress ) . '%"></div>
|
39 |
</div>
|
40 |
';
|
41 |
|
42 |
+
if ( $echo ) {
|
43 |
+
echo $progress_ui; // @codingStandardsIgnoreLine
|
44 |
} else {
|
45 |
return $progress_ui;
|
46 |
}
|
50 |
* Calculate progress %.
|
51 |
*
|
52 |
* @access public
|
53 |
+
*
|
54 |
+
* @param float $progress
|
55 |
+
* @param float $total
|
56 |
+
*
|
57 |
* @return float
|
58 |
*/
|
59 |
public function progress( $progress, $total ) {
|
60 |
+
if ( $total < 1 ) {
|
61 |
return 100;
|
62 |
}
|
63 |
|
64 |
return ( $progress / $total ) * 100;
|
65 |
}
|
|
|
66 |
}
|
app/importers/BPMediaAlbumimporter.php
CHANGED
@@ -16,7 +16,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
16 |
global $wpdb;
|
17 |
parent::__construct();
|
18 |
$table = "{$wpdb->base_prefix}bp_album";
|
19 |
-
if ( BPMediaImporter::table_exists( $table ) && BPMediaAlbumimporter::_active( 'bp-album/loader.php' )
|
20 |
$this->update_table();
|
21 |
}
|
22 |
}
|
@@ -37,152 +37,152 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
37 |
function column_exists( $column ) {
|
38 |
global $wpdb;
|
39 |
|
40 |
-
return $wpdb->query( "SHOW COLUMNS FROM {$wpdb->base_prefix}bp_album LIKE
|
41 |
}
|
42 |
|
43 |
function ui() {
|
44 |
global $wpdb;
|
45 |
$bp_album_active = BPMediaImporter::_active( 'bp-album/loader.php' );
|
46 |
-
$table
|
47 |
if ( BPMediaImporter::table_exists( $table ) ) {
|
48 |
|
49 |
$this->progress = new rtProgress();
|
50 |
-
$total
|
51 |
-
// print_r($total);
|
52 |
$remaining_comments = $this->get_remaining_comments();
|
53 |
-
// print_r($remaining_comments);
|
54 |
$finished = BPMediaAlbumimporter::get_completed_media( $total );
|
55 |
-
// print_r($finished);
|
56 |
$finished_users = BPMediaAlbumimporter::get_completed_users();
|
57 |
-
// print_R($finished_users);
|
58 |
$finished_comments = $this->get_finished_comments();
|
59 |
-
|
60 |
-
$
|
61 |
-
// print_r($total_comments);
|
62 |
-
$completed_users_favorites = ( int ) get_site_option( 'bp_media_bp_album_favorite_import_status', 0 );
|
63 |
-
// print_r($completed_users_favorites);
|
64 |
$users = count_users();
|
65 |
-
// print_r($users);
|
66 |
|
67 |
echo '<div id="bpmedia-bpalbumimporter">';
|
68 |
-
|
69 |
-
|
|
|
70 |
echo '<div id="setting-error-bp-album-importer" class="error settings-error below-h2">
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
echo '<button id="bpmedia-bpalbumimport" class="button button-primary">';
|
75 |
-
|
76 |
echo '</button>';
|
77 |
echo '<div class="bp-album-importer-wizard">';
|
78 |
echo '<div class="bp-album-users">';
|
79 |
echo '<strong>';
|
80 |
-
echo
|
81 |
echo '</strong>';
|
82 |
-
if ( 0
|
83 |
-
$users_progress = $this->progress->progress( $finished_users[
|
84 |
$this->progress->progress_ui( $users_progress );
|
85 |
}
|
86 |
echo '</div>';
|
87 |
echo '<br />';
|
88 |
echo '<div class="bp-album-media">';
|
89 |
echo '<strong>';
|
90 |
-
echo
|
91 |
echo '</strong>';
|
92 |
$progress = 100;
|
93 |
-
if ( 0
|
94 |
-
$todo
|
95 |
-
$steps
|
96 |
$laststep = $todo % 5;
|
97 |
-
$progress = $this->progress->progress( $finished[
|
98 |
-
echo '<input type="hidden" value="' . $finished[
|
99 |
-
echo '<input type="hidden" value="' . $total[
|
100 |
-
echo '<input type="hidden" value="' . $todo . '" name="todo"/>';
|
101 |
-
echo '<input type="hidden" value="' . $steps . '" name="steps"/>';
|
102 |
-
echo '<input type="hidden" value="' . $laststep . '" name="laststep"/>';
|
103 |
$this->progress->progress_ui( $progress );
|
104 |
}
|
105 |
echo '</div>';
|
106 |
echo '<br>';
|
107 |
echo '<div class="bp-album-comments">';
|
108 |
-
if ( 0
|
109 |
echo '<strong>';
|
110 |
-
echo
|
111 |
echo '</strong>';
|
112 |
$comments_progress = $this->progress->progress( $finished_comments, $total_comments );
|
113 |
$this->progress->progress_ui( $comments_progress );
|
114 |
echo '<br />';
|
115 |
} else {
|
116 |
-
echo '<p><strong>' .
|
117 |
}
|
118 |
echo '</div>';
|
119 |
-
if ( 0
|
120 |
echo '<br />';
|
121 |
echo '<div class="bp-album-favorites">';
|
122 |
echo '<strong>';
|
123 |
-
echo
|
124 |
echo '</strong>';
|
125 |
-
$favorites_progress = $this->progress->progress( $completed_users_favorites, $users[
|
126 |
$this->progress->progress_ui( $favorites_progress );
|
127 |
echo '</div>';
|
128 |
}
|
129 |
echo '</div>';
|
130 |
} else {
|
131 |
$deactivate_link = wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $this->path ) ), 'deactivate-plugin_' . $this->path );
|
132 |
-
echo '<p>' .
|
133 |
-
echo '<p><a class="button button-primary deactivate-bp-album" href="' . $deactivate_link . '">' .
|
134 |
}
|
135 |
} else {
|
136 |
$corrupt_media = BPMediaAlbumimporter::get_corrupt_media();
|
137 |
if ( $corrupt_media ) {
|
138 |
echo '<div class="error below-h2">';
|
139 |
-
echo '<p><strong>' .
|
140 |
-
echo '<p>' . sprintf(
|
141 |
$corrupt_prefix_path = str_replace( '/wp-content', '', WP_CONTENT_URL );
|
142 |
foreach ( $corrupt_media as $corrupt ) {
|
143 |
-
echo '<p>' . $corrupt->id . ' => <a href="' . $corrupt_prefix_path . $corrupt->pic_org_url . '">' . $corrupt->title . '</a></p>';
|
144 |
}
|
145 |
echo '</div>';
|
146 |
} else {
|
147 |
echo '<div class="bp-album-import-accept i-accept">';
|
148 |
echo '<p class="info">';
|
149 |
-
$message = sprintf(
|
150 |
-
echo '<strong>' .
|
151 |
-
echo ' <a href="http://twitter.com/home/?status=' . $message . '" class="button button-import-tweet" target= "_blank">' .
|
152 |
echo '</p>';
|
153 |
echo '</div>';
|
154 |
}
|
155 |
-
echo '<p>' .
|
156 |
echo '<br />';
|
157 |
echo '<button id="bpmedia-bpalbumimport-cleanup" class="button btn-warning">';
|
158 |
-
|
159 |
echo '</button>';
|
160 |
echo ' <a href="' . esc_url( add_query_arg( array( 'page' => 'bp-media-settings' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) ) . '" id="bpmedia-bpalbumimport-cleanup-later" class="button">';
|
161 |
-
|
162 |
echo '</a>';
|
163 |
echo '<br />';
|
164 |
echo '<br />';
|
165 |
echo '<br />';
|
166 |
-
echo '<strong>' .
|
167 |
echo '<div class="bp-media-addon">
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
}
|
182 |
echo '</div>';
|
183 |
} else {
|
184 |
-
echo '<p>' .
|
185 |
-
echo '<p>' .
|
|
|
186 |
}
|
187 |
}
|
188 |
|
@@ -190,19 +190,18 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
190 |
global $bp_media, $wpdb;
|
191 |
|
192 |
if ( array_key_exists( 'bp_album_import_name', $bp_media->options ) ) {
|
193 |
-
if ( ''
|
194 |
-
$album_name = $bp_media->options[
|
195 |
}
|
196 |
}
|
197 |
|
198 |
-
$
|
199 |
-
$result = $wpdb->get_results( $query );
|
200 |
if ( count( $result ) < 1 ) {
|
201 |
$album = new BPMediaAlbum();
|
202 |
$album->add_album( $album_name, $author_id );
|
203 |
$album_id = $album->get_id();
|
204 |
} else {
|
205 |
-
$album_id = $result[
|
206 |
}
|
207 |
$wpdb->update( $wpdb->base_prefix . 'bp_activity', array( 'secondary_item_id' => - 999 ), array( 'id' => get_post_meta( $album_id, 'bp_media_child_activity', true ) ) );
|
208 |
|
@@ -213,7 +212,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
213 |
global $wpdb;
|
214 |
$table = $wpdb->base_prefix . 'bp_album';
|
215 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
216 |
-
return $wpdb->get_results( "SELECT COUNT(DISTINCT owner_id) as users, COUNT(id) as media FROM $table" );
|
217 |
}
|
218 |
|
219 |
return 0;
|
@@ -224,11 +223,12 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
224 |
$bp_album_table = $wpdb->base_prefix . 'bp_album';
|
225 |
$activity_table = $wpdb->base_prefix . 'bp_activity';
|
226 |
if ( $this->table_exists( $bp_album_table ) ) {
|
|
|
227 |
return $wpdb->get_var( "SELECT SUM( b.count ) AS total
|
228 |
FROM (
|
229 |
SELECT (
|
230 |
SELECT COUNT( a.id )
|
231 |
-
FROM $activity_table a
|
232 |
WHERE a.item_id = activity.id
|
233 |
AND a.component = 'activity'
|
234 |
AND a.type = 'activity_comment'
|
@@ -238,7 +238,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
238 |
WHERE activity.component = 'album'
|
239 |
AND activity.type = 'bp_album_picture'
|
240 |
AND album.import_status =0
|
241 |
-
)b" );
|
242 |
}
|
243 |
|
244 |
return 0;
|
@@ -249,11 +249,12 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
249 |
$bp_album_table = $wpdb->base_prefix . 'bp_album';
|
250 |
$activity_table = $wpdb->base_prefix . 'bp_activity';
|
251 |
if ( $this->table_exists( $bp_album_table ) ) {
|
|
|
252 |
return $wpdb->get_var( "SELECT COUNT( activity.id ) AS count
|
253 |
FROM $activity_table AS activity
|
254 |
INNER JOIN $bp_album_table AS album ON ( activity.item_id = album.import_status )
|
255 |
WHERE activity.component = 'activity'
|
256 |
-
AND activity.type = 'activity_comment'" );
|
257 |
}
|
258 |
|
259 |
return 0;
|
@@ -263,6 +264,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
263 |
global $wpdb;
|
264 |
$table = $wpdb->base_prefix . 'bp_album';
|
265 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
|
|
266 |
return $wpdb->get_results( "SELECT COUNT( DISTINCT owner_id ) AS users
|
267 |
FROM $table
|
268 |
WHERE owner_id NOT
|
@@ -272,6 +274,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
272 |
WHERE a.import_status =0
|
273 |
)
|
274 |
" );
|
|
|
275 |
}
|
276 |
|
277 |
return 0;
|
@@ -281,7 +284,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
281 |
global $wpdb;
|
282 |
$table = $wpdb->base_prefix . 'bp_album';
|
283 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
284 |
-
return $wpdb->get_results( "SELECT COUNT(id) as media FROM $table WHERE import_status!=0" );
|
285 |
}
|
286 |
|
287 |
return 0;
|
@@ -291,7 +294,7 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
291 |
global $wpdb;
|
292 |
$table = $wpdb->base_prefix . 'bp_album';
|
293 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
294 |
-
return $wpdb->get_results( "SELECT id,title,pic_org_url FROM $table WHERE import_status=-1" );
|
295 |
}
|
296 |
|
297 |
return 0;
|
@@ -299,40 +302,49 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
299 |
|
300 |
static function batch_import( $count = 5 ) {
|
301 |
global $wpdb;
|
302 |
-
$table
|
303 |
-
$bp_album_data = $wpdb->get_results( "SELECT * FROM $table WHERE import_status = 0 ORDER BY owner_id LIMIT $count
|
304 |
|
305 |
return $bp_album_data;
|
306 |
}
|
307 |
|
308 |
static function bpmedia_ajax_import_callback() {
|
309 |
-
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
312 |
$bp_album_data = BPMediaAlbumimporter::batch_import( $count );
|
313 |
global $wpdb;
|
314 |
-
$table
|
315 |
-
$activity_table
|
316 |
$activity_meta_table = $wpdb->base_prefix . 'bp_activity_meta';
|
317 |
-
$comments
|
318 |
foreach ( $bp_album_data as &$bp_album_item ) {
|
319 |
|
320 |
-
if ( get_site_option( 'bp_media_bp_album_importer_base_path' )
|
321 |
$base_path = pathinfo( $bp_album_item->pic_org_path );
|
322 |
-
update_site_option( 'bp_media_bp_album_importer_base_path', $base_path[
|
323 |
}
|
324 |
$bpm_host_wp = new BPMediaHostWordpress();
|
325 |
$bpm_host_wp->check_and_create_album( 0, 0, $bp_album_item->owner_id );
|
326 |
-
$album_id
|
327 |
$imported_media_id = BPMediaImporter::add_media( $album_id, $bp_album_item->title, $bp_album_item->description, $bp_album_item->pic_org_path, $bp_album_item->privacy, $bp_album_item->owner_id, 'Imported Media' );
|
328 |
$wpdb->update( $table, array( 'import_status' => ( $imported_media_id ) ? $imported_media_id : - 1 ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
329 |
if ( $imported_media_id ) {
|
330 |
-
$comments += (
|
331 |
-
|
|
|
332 |
$wpdb->update( $table, array( 'old_activity_id' => $bp_album_media_id ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
333 |
-
$bp_new_activity_id = $wpdb->get_var( "SELECT id from $activity_table WHERE item_id = $imported_media_id AND component = 'activity' AND type='activity_update' AND secondary_item_id=0" );
|
334 |
$wpdb->update( $table, array( 'new_activity_id' => $bp_new_activity_id ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
335 |
-
if ( $wpdb->update( $activity_meta_table, array( 'activity_id' => $bp_new_activity_id ), array(
|
|
|
|
|
|
|
|
|
336 |
$wpdb->update( $table, array( 'favorites' => 1 ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
337 |
}
|
338 |
}
|
@@ -340,23 +352,35 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
340 |
|
341 |
$finished_users = BPMediaAlbumimporter::get_completed_users();
|
342 |
|
343 |
-
echo
|
344 |
die();
|
345 |
}
|
346 |
|
347 |
static function bpmedia_ajax_import_favorites() {
|
|
|
|
|
|
|
348 |
global $wpdb;
|
349 |
$table = $wpdb->base_prefix . 'bp_album';
|
350 |
$users = count_users();
|
351 |
-
echo
|
|
|
|
|
|
|
|
|
352 |
die();
|
353 |
}
|
354 |
|
355 |
static function bpmedia_ajax_import_step_favorites() {
|
356 |
-
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
358 |
global $wpdb;
|
359 |
-
$table
|
360 |
$blogusers = get_users( array( 'meta_key' => 'bp_favorite_activities', 'offset' => $offset, 'number' => 1 ) );
|
361 |
if ( $blogusers ) {
|
362 |
foreach ( $blogusers as $user ) {
|
@@ -364,24 +388,27 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
364 |
if ( $favorite_activities ) {
|
365 |
$new_favorite_activities = $favorite_activities;
|
366 |
foreach ( $favorite_activities as $key => $favorite ) {
|
367 |
-
if ( $new_act = $wpdb->get_var( "SELECT new_activity_id from $table WHERE old_activity_id = $favorite
|
368 |
$new_favorite_activities[ $key ] = $new_act;
|
369 |
}
|
370 |
}
|
371 |
update_user_meta( $user->ID, 'bp_favorite_activities', $new_favorite_activities );
|
372 |
}
|
373 |
-
$completed_users_favorites = (
|
374 |
update_site_option( 'bp_media_bp_album_favorite_import_status', $completed_users_favorites );
|
375 |
}
|
376 |
}
|
377 |
-
echo $redirect;
|
378 |
die();
|
379 |
}
|
380 |
|
381 |
static function cleanup_after_install() {
|
382 |
global $wpdb;
|
|
|
|
|
|
|
383 |
$table = $wpdb->base_prefix . 'bp_album';
|
384 |
-
$dir
|
385 |
BPMediaImporter::cleanup( $table, $dir );
|
386 |
die();
|
387 |
}
|
@@ -398,14 +425,14 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
398 |
}
|
399 |
$activity_id = get_post_meta( $media->get_id(), 'bp_media_child_activity', true );
|
400 |
if ( $activity_id ) {
|
401 |
-
$date_uploaded
|
402 |
-
$old_activity_id = $wpdb->get_var( "SELECT id from {$wpdb->base_prefix}bp_activity WHERE component = 'album' AND type = 'bp_album_picture' AND item_id = $bp_album_id
|
403 |
if ( $old_activity_id ) {
|
404 |
-
$comments = $wpdb->get_results( "SELECT id,secondary_item_id from {$wpdb->base_prefix}bp_activity WHERE component = 'activity' AND type = 'activity_comment' AND item_id = $old_activity_id
|
405 |
foreach ( $comments as $comment ) {
|
406 |
$update = array( 'item_id' => $activity_id );
|
407 |
-
if ( $comment->secondary_item_id
|
408 |
-
$update[
|
409 |
}
|
410 |
$wpdb->update( $wpdb->base_prefix . 'bp_activity', $update, array( 'id' => $comment->id ) );
|
411 |
BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
|
@@ -421,8 +448,9 @@ class BPMediaAlbumimporter extends BPMediaImporter {
|
|
421 |
}
|
422 |
|
423 |
static function bp_album_deactivate() {
|
424 |
-
|
|
|
|
|
425 |
die( true );
|
426 |
}
|
427 |
-
|
428 |
}
|
16 |
global $wpdb;
|
17 |
parent::__construct();
|
18 |
$table = "{$wpdb->base_prefix}bp_album";
|
19 |
+
if ( BPMediaImporter::table_exists( $table ) && BPMediaAlbumimporter::_active( 'bp-album/loader.php' ) !== - 1 && ! $this->column_exists( 'import_status' ) ) {
|
20 |
$this->update_table();
|
21 |
}
|
22 |
}
|
37 |
function column_exists( $column ) {
|
38 |
global $wpdb;
|
39 |
|
40 |
+
return $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM {$wpdb->base_prefix}bp_album LIKE %s limit 1", $column ) );
|
41 |
}
|
42 |
|
43 |
function ui() {
|
44 |
global $wpdb;
|
45 |
$bp_album_active = BPMediaImporter::_active( 'bp-album/loader.php' );
|
46 |
+
$table = "{$wpdb->base_prefix}bp_album";
|
47 |
if ( BPMediaImporter::table_exists( $table ) ) {
|
48 |
|
49 |
$this->progress = new rtProgress();
|
50 |
+
$total = BPMediaAlbumimporter::get_total_count();
|
|
|
51 |
$remaining_comments = $this->get_remaining_comments();
|
|
|
52 |
$finished = BPMediaAlbumimporter::get_completed_media( $total );
|
|
|
53 |
$finished_users = BPMediaAlbumimporter::get_completed_users();
|
|
|
54 |
$finished_comments = $this->get_finished_comments();
|
55 |
+
$total_comments = (int) $finished_comments + (int) $remaining_comments;
|
56 |
+
$completed_users_favorites = (int) get_site_option( 'bp_media_bp_album_favorite_import_status', 0 );
|
|
|
|
|
|
|
57 |
$users = count_users();
|
|
|
58 |
|
59 |
echo '<div id="bpmedia-bpalbumimporter">';
|
60 |
+
wp_nonce_field( 'bpmedia-bpalbumimporter', 'bpaimporter_wpnonce' );
|
61 |
+
if ( ( $finished[0]->media !== $total[0]->media ) || ( $users['total_users'] > $completed_users_favorites ) ) {
|
62 |
+
if ( 1 !== $bp_album_active ) {
|
63 |
echo '<div id="setting-error-bp-album-importer" class="error settings-error below-h2">
|
64 |
+
<p><strong>' . esc_html__( 'Warning!', 'buddypress-media' ) . '</strong> ' .
|
65 |
+
esc_html__( 'This import process is irreversible. Although everything is tested, please take a ', 'buddypress-media' ) .
|
66 |
+
'<a target="_blank" href="http://codex.wordpress.org/WordPress_Backups">' . esc_html__( 'backup of your database and files', 'buddypress-media' ) . '</a>' .
|
67 |
+
esc_html__( ', before proceeding. If you don\'t know your way around databases and files, consider ', 'buddypress-media' ) .
|
68 |
+
'<a target="_blank" href="http://rtmedia.io/contact/?purpose=buddypress&utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">' . esc_html__( 'hiring us', 'buddypress-media' ) . '</a>' .
|
69 |
+
esc_html__( ', or another professional.', 'buddypress-media' ) .
|
70 |
+
'</p>';
|
71 |
+
echo '<p>' . esc_html__( 'If you have set "WP_DEBUG" in you wp-config.php file, please make sure it is set to "false", so that it doesn\'t conflict with the import process.', 'buddypress-media' ) . '</p></div>';
|
72 |
+
echo '<div class="bp-album-import-accept"><p><strong><label for="bp-album-import-accept"><input type="checkbox" value="accept" name="bp-album-import-accept" id="bp-album-import-accept" /> ' . esc_html__( 'I have taken a backup of the database and files of this site.', 'buddypress-media' ) . '</label></strong></p></div>';
|
73 |
echo '<button id="bpmedia-bpalbumimport" class="button button-primary">';
|
74 |
+
esc_html__( 'Start Import', 'buddypress-media' );
|
75 |
echo '</button>';
|
76 |
echo '<div class="bp-album-importer-wizard">';
|
77 |
echo '<div class="bp-album-users">';
|
78 |
echo '<strong>';
|
79 |
+
echo esc_html__( 'Users', 'buddypress-media' ) . ': <span class="finished">' . esc_html( $finished_users[0]->users ) . '</span> / <span class="total">' . esc_html( $total[0]->users ) . '</span>';
|
80 |
echo '</strong>';
|
81 |
+
if ( 0 !== $total[0]->users ) {
|
82 |
+
$users_progress = $this->progress->progress( $finished_users[0]->users, $total[0]->users );
|
83 |
$this->progress->progress_ui( $users_progress );
|
84 |
}
|
85 |
echo '</div>';
|
86 |
echo '<br />';
|
87 |
echo '<div class="bp-album-media">';
|
88 |
echo '<strong>';
|
89 |
+
echo esc_html__( 'Media', 'buddypress-media' ) . ': <span class="finished">' . esc_html( $finished[0]->media ) . '</span> / <span class="total">' . esc_html( $total[0]->media ) . '</span>';
|
90 |
echo '</strong>';
|
91 |
$progress = 100;
|
92 |
+
if ( 0 !== $total[0]->media ) {
|
93 |
+
$todo = $total[0]->media - $finished[0]->media;
|
94 |
+
$steps = ceil( $todo / 5 );
|
95 |
$laststep = $todo % 5;
|
96 |
+
$progress = $this->progress->progress( $finished[0]->media, $total[0]->media );
|
97 |
+
echo '<input type="hidden" value="' . esc_attr( $finished[0]->media ) . '" name="finished"/>';
|
98 |
+
echo '<input type="hidden" value="' . esc_attr( $total[0]->media ) . '" name="total"/>';
|
99 |
+
echo '<input type="hidden" value="' . esc_attr( $todo ) . '" name="todo"/>';
|
100 |
+
echo '<input type="hidden" value="' . esc_attr( $steps ) . '" name="steps"/>';
|
101 |
+
echo '<input type="hidden" value="' . esc_attr( $laststep ) . '" name="laststep"/>';
|
102 |
$this->progress->progress_ui( $progress );
|
103 |
}
|
104 |
echo '</div>';
|
105 |
echo '<br>';
|
106 |
echo '<div class="bp-album-comments">';
|
107 |
+
if ( 0 !== $total_comments ) {
|
108 |
echo '<strong>';
|
109 |
+
echo esc_html__( 'Comments', 'buddypress-media' ) . ': <span class="finished">' . esc_html( $finished_comments ) . '</span> / <span class="total">' . esc_html( $total_comments ) . '</span>';
|
110 |
echo '</strong>';
|
111 |
$comments_progress = $this->progress->progress( $finished_comments, $total_comments );
|
112 |
$this->progress->progress_ui( $comments_progress );
|
113 |
echo '<br />';
|
114 |
} else {
|
115 |
+
echo '<p><strong>' . esc_html__( 'Comments: 0/0 (No comments to import)', 'buddypress-media' ) . '</strong></p>';
|
116 |
}
|
117 |
echo '</div>';
|
118 |
+
if ( 0 !== $completed_users_favorites ) {
|
119 |
echo '<br />';
|
120 |
echo '<div class="bp-album-favorites">';
|
121 |
echo '<strong>';
|
122 |
+
echo esc_html__( 'User\'s Favorites', 'buddypress-media' ) . ': <span class="finished">' . esc_html( $completed_users_favorites ) . '</span> / <span class="total">' . esc_html( $users['total_users'] ) . '</span>';
|
123 |
echo '</strong>';
|
124 |
+
$favorites_progress = $this->progress->progress( $completed_users_favorites, $users['total_users'] );
|
125 |
$this->progress->progress_ui( $favorites_progress );
|
126 |
echo '</div>';
|
127 |
}
|
128 |
echo '</div>';
|
129 |
} else {
|
130 |
$deactivate_link = wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $this->path ) ), 'deactivate-plugin_' . $this->path );
|
131 |
+
echo '<p>' . esc_html__( 'BP-Album is active on your site and will cause problems with the import.', 'buddypress-media' ) . '</p>';
|
132 |
+
echo '<p><a class="button button-primary deactivate-bp-album" href="' . esc_url( $deactivate_link ) . '">' . esc_html__( 'Click here to deactivate BP-Album and continue importing', 'buddypress-media' ) . '</a></p>';
|
133 |
}
|
134 |
} else {
|
135 |
$corrupt_media = BPMediaAlbumimporter::get_corrupt_media();
|
136 |
if ( $corrupt_media ) {
|
137 |
echo '<div class="error below-h2">';
|
138 |
+
echo '<p><strong>' . esc_html__( 'Some of the media failed to import. The file might be corrupt or deleted.', 'buddypress-media' ) . '</strong></p>';
|
139 |
+
echo '<p>' . sprintf( esc_html__( 'The following %d BP Album Media id\'s could not be imported', 'buddypress-media' ), count( $corrupt_media ) ) . ': </p>';
|
140 |
$corrupt_prefix_path = str_replace( '/wp-content', '', WP_CONTENT_URL );
|
141 |
foreach ( $corrupt_media as $corrupt ) {
|
142 |
+
echo '<p>' . esc_html( $corrupt->id ) . ' => <a href="' . esc_url( $corrupt_prefix_path . $corrupt->pic_org_url ) . '">' . esc_html( $corrupt->title ) . '</a></p>';
|
143 |
}
|
144 |
echo '</div>';
|
145 |
} else {
|
146 |
echo '<div class="bp-album-import-accept i-accept">';
|
147 |
echo '<p class="info">';
|
148 |
+
$message = sprintf( esc_html__( 'I just imported bp-album to @rtMediaWP http://rt.cx/rtmedia on %s', 'buddypress-media' ), home_url() );
|
149 |
+
echo '<strong>' . esc_html__( 'Congratulations!', 'buddypress-media' ) . '</strong> ' . esc_html__( 'All media from BP Album has been imported.', 'buddypress-media' );
|
150 |
+
echo ' <a href="http://twitter.com/home/?status=' . esc_url( $message ) . '" class="button button-import-tweet" target= "_blank">' . esc_html__( 'Tweet this', 'buddypress-media' ) . '</a>';
|
151 |
echo '</p>';
|
152 |
echo '</div>';
|
153 |
}
|
154 |
+
echo '<p>' . esc_html__( 'However, a lot of unnecessary files and a database table are still eating up your resources. If everything seems fine, you can clean this data up.', 'buddypress-media' ) . '</p>';
|
155 |
echo '<br />';
|
156 |
echo '<button id="bpmedia-bpalbumimport-cleanup" class="button btn-warning">';
|
157 |
+
esc_html_e( 'Clean up Now', 'buddypress-media' );
|
158 |
echo '</button>';
|
159 |
echo ' <a href="' . esc_url( add_query_arg( array( 'page' => 'bp-media-settings' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) ) . '" id="bpmedia-bpalbumimport-cleanup-later" class="button">';
|
160 |
+
esc_html_e( 'Clean up Later', 'buddypress-media' );
|
161 |
echo '</a>';
|
162 |
echo '<br />';
|
163 |
echo '<br />';
|
164 |
echo '<br />';
|
165 |
+
echo '<strong>' . esc_html__( 'Why don\'t you try adding some instagram like effects to your images?', 'buddypress-media' ) . '</strong>';
|
166 |
echo '<div class="bp-media-addon">
|
167 |
+
<a href="https://rtmedia.io/products/rtmedia-photo-filters/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media&utm_content=bp-album-importer" title="rtMedia Photo Filters" target="_blank">
|
168 |
+
<img width="240" height="184" title="rtMedia Photo Filters" alt="rtMedia Photo Filters" src="' . esc_url( $img_src ) . 'BuddyPressMedia-Instagram.png?ref=bp-album-importer">
|
169 |
+
</a>
|
170 |
+
<h4><a href="https://rtmedia.io/products/rtmedia-photo-filters/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media&utm_content=bp-album-importer" title="rtMedia Photo Filters" target="_blank">rtMedia Photo Filters</a></h4>
|
171 |
+
<div class="product_desc">
|
172 |
+
<p>' . esc_html__( 'rtMedia Photo Filters adds Instagram like filters to images uploaded with BuddyPress Media.', 'buddypress-media' ) . '</p>
|
173 |
+
<p><strong>' . esc_html__( 'Important', 'buddypress-media' ) . ':</strong> ' . esc_html__( 'You need to have ImageMagick installed on your server for this addon to work.', 'buddypress-media' ) . '</p>
|
174 |
+
</div>
|
175 |
+
<div class="product_footer">
|
176 |
+
<span class="price alignleft"><span class="amount">$19</span></span>
|
177 |
+
<a class="add_to_cart_button alignright product_type_simple" href="https://rtmedia.io/products/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media&utm_content=bp-album-importer&add-to-cart=34379" target="_blank">' . esc_html__( 'Buy Now', 'buddypress-media' ) . '</a>
|
178 |
+
<a class="alignleft product_demo_link" href="http://demo.rtmedia.io/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media&utm_content=bp-album-importer" title="rtMedia Photo Filters" target="_blank">' . esc_html__( 'Live Demo', 'buddypress-media' ) . '</a>
|
179 |
+
</div></div>';
|
180 |
}
|
181 |
echo '</div>';
|
182 |
} else {
|
183 |
+
echo '<p>' . esc_html__( 'Looks like you don\'t use BP Album. Is there any other BuddyPress Plugin you want an importer for?', 'buddypress-media' ) . '</p>';
|
184 |
+
echo '<p>' . '<a href="https://github.com/rtCamp/rtMedia/issues/new">' . esc_html__( 'Create an issue', 'buddypress-media' ) . '</a>';
|
185 |
+
echo esc_html__( ' on GitHub requesting the same.', 'buddypress-media' ) . '</p>';
|
186 |
}
|
187 |
}
|
188 |
|
190 |
global $bp_media, $wpdb;
|
191 |
|
192 |
if ( array_key_exists( 'bp_album_import_name', $bp_media->options ) ) {
|
193 |
+
if ( '' !== $bp_media->options['bp_album_import_name'] ) {
|
194 |
+
$album_name = $bp_media->options['bp_album_import_name'];
|
195 |
}
|
196 |
}
|
197 |
|
198 |
+
$result = $wpdb->get_results( $wpdb->prepare( "SELECT ID from $wpdb->posts WHERE post_type='bp_media_album' AND post_status = 'publish' AND post_author = %d AND post_title LIKE %s limit 1", $author_id, $album_name ) );
|
|
|
199 |
if ( count( $result ) < 1 ) {
|
200 |
$album = new BPMediaAlbum();
|
201 |
$album->add_album( $album_name, $author_id );
|
202 |
$album_id = $album->get_id();
|
203 |
} else {
|
204 |
+
$album_id = $result[0]->ID;
|
205 |
}
|
206 |
$wpdb->update( $wpdb->base_prefix . 'bp_activity', array( 'secondary_item_id' => - 999 ), array( 'id' => get_post_meta( $album_id, 'bp_media_child_activity', true ) ) );
|
207 |
|
212 |
global $wpdb;
|
213 |
$table = $wpdb->base_prefix . 'bp_album';
|
214 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
215 |
+
return $wpdb->get_results( "SELECT COUNT(DISTINCT owner_id) as users, COUNT(id) as media FROM {$table}" ); // @codingStandardsIgnoreLine
|
216 |
}
|
217 |
|
218 |
return 0;
|
223 |
$bp_album_table = $wpdb->base_prefix . 'bp_album';
|
224 |
$activity_table = $wpdb->base_prefix . 'bp_activity';
|
225 |
if ( $this->table_exists( $bp_album_table ) ) {
|
226 |
+
// @codingStandardsIgnoreStart
|
227 |
return $wpdb->get_var( "SELECT SUM( b.count ) AS total
|
228 |
FROM (
|
229 |
SELECT (
|
230 |
SELECT COUNT( a.id )
|
231 |
+
FROM {$activity_table} a
|
232 |
WHERE a.item_id = activity.id
|
233 |
AND a.component = 'activity'
|
234 |
AND a.type = 'activity_comment'
|
238 |
WHERE activity.component = 'album'
|
239 |
AND activity.type = 'bp_album_picture'
|
240 |
AND album.import_status =0
|
241 |
+
)b" ); // @codingStandardsIgnoreEnd
|
242 |
}
|
243 |
|
244 |
return 0;
|
249 |
$bp_album_table = $wpdb->base_prefix . 'bp_album';
|
250 |
$activity_table = $wpdb->base_prefix . 'bp_activity';
|
251 |
if ( $this->table_exists( $bp_album_table ) ) {
|
252 |
+
// @codingStandardsIgnoreStart
|
253 |
return $wpdb->get_var( "SELECT COUNT( activity.id ) AS count
|
254 |
FROM $activity_table AS activity
|
255 |
INNER JOIN $bp_album_table AS album ON ( activity.item_id = album.import_status )
|
256 |
WHERE activity.component = 'activity'
|
257 |
+
AND activity.type = 'activity_comment'" ); // @codingStandardsIgnoreEnd
|
258 |
}
|
259 |
|
260 |
return 0;
|
264 |
global $wpdb;
|
265 |
$table = $wpdb->base_prefix . 'bp_album';
|
266 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
267 |
+
// @codingStandardsIgnoreStart
|
268 |
return $wpdb->get_results( "SELECT COUNT( DISTINCT owner_id ) AS users
|
269 |
FROM $table
|
270 |
WHERE owner_id NOT
|
274 |
WHERE a.import_status =0
|
275 |
)
|
276 |
" );
|
277 |
+
// @codingStandardsIgnoreEnd
|
278 |
}
|
279 |
|
280 |
return 0;
|
284 |
global $wpdb;
|
285 |
$table = $wpdb->base_prefix . 'bp_album';
|
286 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
287 |
+
return $wpdb->get_results( "SELECT COUNT(id) as media FROM $table WHERE import_status!=0" ); // @codingStandardsIgnoreLine
|
288 |
}
|
289 |
|
290 |
return 0;
|
294 |
global $wpdb;
|
295 |
$table = $wpdb->base_prefix . 'bp_album';
|
296 |
if ( BPMediaAlbumimporter::table_exists( $table ) ) {
|
297 |
+
return $wpdb->get_results( "SELECT id,title,pic_org_url FROM $table WHERE import_status=-1" ); // @codingStandardsIgnoreLine
|
298 |
}
|
299 |
|
300 |
return 0;
|
302 |
|
303 |
static function batch_import( $count = 5 ) {
|
304 |
global $wpdb;
|
305 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
306 |
+
$bp_album_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table} WHERE import_status = 0 ORDER BY owner_id LIMIT %d", $count ) ); // @codingStandardsIgnoreLine
|
307 |
|
308 |
return $bp_album_data;
|
309 |
}
|
310 |
|
311 |
static function bpmedia_ajax_import_callback() {
|
312 |
+
if ( ! check_ajax_referer( 'bpmedia-bpalbumimporter', 'rtm_wpnonce' ) ) {
|
313 |
+
wp_send_json( false );
|
314 |
+
}
|
315 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_NUMBER_INT );
|
316 |
+
$count = filter_input( INPUT_GET, 'count', FILTER_SANITIZE_NUMBER_INT );
|
317 |
+
$page = isset( $page ) ? $page : 1;
|
318 |
+
$count = isset( $count ) ? $count : 5;
|
319 |
$bp_album_data = BPMediaAlbumimporter::batch_import( $count );
|
320 |
global $wpdb;
|
321 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
322 |
+
$activity_table = $wpdb->base_prefix . 'bp_activity';
|
323 |
$activity_meta_table = $wpdb->base_prefix . 'bp_activity_meta';
|
324 |
+
$comments = 0;
|
325 |
foreach ( $bp_album_data as &$bp_album_item ) {
|
326 |
|
327 |
+
if ( get_site_option( 'bp_media_bp_album_importer_base_path' ) === '' ) {
|
328 |
$base_path = pathinfo( $bp_album_item->pic_org_path );
|
329 |
+
update_site_option( 'bp_media_bp_album_importer_base_path', $base_path['dirname'] );
|
330 |
}
|
331 |
$bpm_host_wp = new BPMediaHostWordpress();
|
332 |
$bpm_host_wp->check_and_create_album( 0, 0, $bp_album_item->owner_id );
|
333 |
+
$album_id = BPMediaAlbumimporter::create_album( $bp_album_item->owner_id, 'Imported Media' );
|
334 |
$imported_media_id = BPMediaImporter::add_media( $album_id, $bp_album_item->title, $bp_album_item->description, $bp_album_item->pic_org_path, $bp_album_item->privacy, $bp_album_item->owner_id, 'Imported Media' );
|
335 |
$wpdb->update( $table, array( 'import_status' => ( $imported_media_id ) ? $imported_media_id : - 1 ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
336 |
if ( $imported_media_id ) {
|
337 |
+
$comments += (int) BPMediaAlbumimporter::update_recorded_time_and_comments( $imported_media_id, $bp_album_item->id, "{$wpdb->base_prefix}bp_album" );
|
338 |
+
|
339 |
+
$bp_album_media_id = $wpdb->get_var( "SELECT activity.id from $activity_table as activity INNER JOIN $table as album ON ( activity.item_id = album.id ) WHERE activity.item_id = $bp_album_item->id AND activity.component = 'album' AND activity.type='bp_album_picture'" ); // @codingStandardsIgnoreLine
|
340 |
$wpdb->update( $table, array( 'old_activity_id' => $bp_album_media_id ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
341 |
+
$bp_new_activity_id = $wpdb->get_var( "SELECT id from $activity_table WHERE item_id = $imported_media_id AND component = 'activity' AND type='activity_update' AND secondary_item_id=0" ); // @codingStandardsIgnoreLine
|
342 |
$wpdb->update( $table, array( 'new_activity_id' => $bp_new_activity_id ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
343 |
+
if ( $wpdb->update( $activity_meta_table, array( 'activity_id' => $bp_new_activity_id ), array(
|
344 |
+
'activity_id' => $bp_album_media_id,
|
345 |
+
'meta_key' => 'favorite_count',
|
346 |
+
), array( '%d' ), array( '%d' ) )
|
347 |
+
) {
|
348 |
$wpdb->update( $table, array( 'favorites' => 1 ), array( 'id' => $bp_album_item->id ), array( '%d' ), array( '%d' ) );
|
349 |
}
|
350 |
}
|
352 |
|
353 |
$finished_users = BPMediaAlbumimporter::get_completed_users();
|
354 |
|
355 |
+
echo wp_json_encode( array( 'page' => $page, 'users' => $finished_users[0]->users, 'comments' => $comments ) );
|
356 |
die();
|
357 |
}
|
358 |
|
359 |
static function bpmedia_ajax_import_favorites() {
|
360 |
+
if ( ! check_ajax_referer( 'bpmedia-bpalbumimporter', 'rtm_wpnonce' ) ) {
|
361 |
+
wp_send_json( array( 'status' => false ) );
|
362 |
+
}
|
363 |
global $wpdb;
|
364 |
$table = $wpdb->base_prefix . 'bp_album';
|
365 |
$users = count_users();
|
366 |
+
echo wp_json_encode( array(
|
367 |
+
'favorites' => $wpdb->get_var( "SELECT COUNT(id) from $table WHERE favorites != 0" ), // @codingStandardsIgnoreLine
|
368 |
+
'users' => $users['total_users'],
|
369 |
+
'offset' => (int) get_site_option( 'bp_media_bp_album_favorite_import_status', 0 ),
|
370 |
+
) );
|
371 |
die();
|
372 |
}
|
373 |
|
374 |
static function bpmedia_ajax_import_step_favorites() {
|
375 |
+
if ( ! check_ajax_referer( 'bpmedia-bpalbumimporter', 'rtm_wpnonce' ) ) {
|
376 |
+
wp_send_json( array( 'status' => false ) );
|
377 |
+
}
|
378 |
+
$offset = filter_input( INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT );
|
379 |
+
$redirect = filter_input( INPUT_GET, 'redirect', FILTER_SANITIZE_URL );
|
380 |
+
$offset = isset( $offset ) ? $offset : 0;
|
381 |
+
$redirect = isset( $redirect ) ? $redirect : false;
|
382 |
global $wpdb;
|
383 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
384 |
$blogusers = get_users( array( 'meta_key' => 'bp_favorite_activities', 'offset' => $offset, 'number' => 1 ) );
|
385 |
if ( $blogusers ) {
|
386 |
foreach ( $blogusers as $user ) {
|
388 |
if ( $favorite_activities ) {
|
389 |
$new_favorite_activities = $favorite_activities;
|
390 |
foreach ( $favorite_activities as $key => $favorite ) {
|
391 |
+
if ( $new_act = $wpdb->get_var( $wpdb->prepare( "SELECT new_activity_id from $table WHERE old_activity_id = %d limit 1", $favorite ) ) ) { // @codingStandardsIgnoreLine
|
392 |
$new_favorite_activities[ $key ] = $new_act;
|
393 |
}
|
394 |
}
|
395 |
update_user_meta( $user->ID, 'bp_favorite_activities', $new_favorite_activities );
|
396 |
}
|
397 |
+
$completed_users_favorites = (int) get_site_option( 'bp_media_bp_album_favorite_import_status', 0 ) + 1;
|
398 |
update_site_option( 'bp_media_bp_album_favorite_import_status', $completed_users_favorites );
|
399 |
}
|
400 |
}
|
401 |
+
echo esc_url( $redirect );
|
402 |
die();
|
403 |
}
|
404 |
|
405 |
static function cleanup_after_install() {
|
406 |
global $wpdb;
|
407 |
+
if ( ! check_ajax_referer( 'bpmedia-bpalbumimporter', 'rtm_wpnonce' ) ) {
|
408 |
+
wp_send_json( array( 'status' => false ) );
|
409 |
+
}
|
410 |
$table = $wpdb->base_prefix . 'bp_album';
|
411 |
+
$dir = get_site_option( 'bp_media_bp_album_importer_base_path' );
|
412 |
BPMediaImporter::cleanup( $table, $dir );
|
413 |
die();
|
414 |
}
|
425 |
}
|
426 |
$activity_id = get_post_meta( $media->get_id(), 'bp_media_child_activity', true );
|
427 |
if ( $activity_id ) {
|
428 |
+
$date_uploaded = $wpdb->get_var( $wpdb->prepare( "SELECT date_uploaded from $table WHERE id = %d", $bp_album_id ) ); // @codingStandardsIgnoreLine
|
429 |
+
$old_activity_id = $wpdb->get_var( $wpdb->prepare( "SELECT id from {$wpdb->base_prefix}bp_activity WHERE component = 'album' AND type = 'bp_album_picture' AND item_id = %d", $bp_album_id ) );
|
430 |
if ( $old_activity_id ) {
|
431 |
+
$comments = $wpdb->get_results( $wpdb->prepare( "SELECT id,secondary_item_id from {$wpdb->base_prefix}bp_activity WHERE component = 'activity' AND type = 'activity_comment' AND item_id = %d", $old_activity_id ) );
|
432 |
foreach ( $comments as $comment ) {
|
433 |
$update = array( 'item_id' => $activity_id );
|
434 |
+
if ( $comment->secondary_item_id === $old_activity_id ) {
|
435 |
+
$update['secondary_item_id'] = $activity_id;
|
436 |
}
|
437 |
$wpdb->update( $wpdb->base_prefix . 'bp_activity', $update, array( 'id' => $comment->id ) );
|
438 |
BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
|
448 |
}
|
449 |
|
450 |
static function bp_album_deactivate() {
|
451 |
+
if ( ! check_ajax_referer( 'bpmedia-bpalbumimporter', 'rtm_wpnonce' ) ) {
|
452 |
+
deactivate_plugins( 'bp-album/loader.php' );
|
453 |
+
}
|
454 |
die( true );
|
455 |
}
|
|
|
456 |
}
|
app/importers/BPMediaBPActivityPlusImporter.php
CHANGED
@@ -19,5 +19,4 @@ class BPMediaBPActivityPlusImporter extends BPMediaImporter {
|
|
19 |
parent::__construct();
|
20 |
|
21 |
}
|
22 |
-
|
23 |
}
|
19 |
parent::__construct();
|
20 |
|
21 |
}
|
|
|
22 |
}
|
app/importers/BPMediaImporter.php
CHANGED
@@ -18,39 +18,39 @@ class BPMediaImporter {
|
|
18 |
var $active;
|
19 |
var $import_steps;
|
20 |
|
21 |
-
function __construct(){
|
22 |
|
23 |
}
|
24 |
|
25 |
-
static function table_exists( $table ){
|
26 |
global $wpdb;
|
27 |
|
28 |
-
if ( 1
|
29 |
return true;
|
30 |
}
|
31 |
|
32 |
return false;
|
33 |
}
|
34 |
|
35 |
-
static function _active( $path ){
|
36 |
-
if ( ! function_exists( 'is_plugin_inactive' ) ){
|
37 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
38 |
}
|
39 |
-
if ( is_plugin_active( $path ) ){
|
40 |
return 1;
|
41 |
}
|
42 |
$plugins = get_plugins();
|
43 |
-
if ( array_key_exists( $path, $plugins ) ){
|
44 |
return 0;
|
45 |
} else {
|
46 |
return - 1;
|
47 |
}
|
48 |
}
|
49 |
|
50 |
-
static function file_array( $filepath ){
|
51 |
|
52 |
-
$path_info
|
53 |
-
$filetype
|
54 |
$file['error'] = '';
|
55 |
$file['name'] = $path_info['basename'];
|
56 |
$file['type'] = $filetype['type'];
|
@@ -60,16 +60,16 @@ class BPMediaImporter {
|
|
60 |
return $file;
|
61 |
}
|
62 |
|
63 |
-
static function make_copy( $filepath ){
|
64 |
$upload_dir = wp_upload_dir();
|
65 |
$path_info = pathinfo( $filepath );
|
66 |
$tmp_dir = trailingslashit( $upload_dir['basedir'] ) . 'bp-album-importer';
|
67 |
$newpath = trailingslashit( $tmp_dir ) . $path_info['basename'];
|
68 |
-
if ( ! is_dir( $tmp_dir ) ){
|
69 |
wp_mkdir_p( $tmp_dir );
|
70 |
}
|
71 |
-
if ( file_exists( $filepath ) ){
|
72 |
-
if ( copy( $filepath, $newpath ) ){
|
73 |
return BPMediaImporter::file_array( $newpath );
|
74 |
}
|
75 |
}
|
@@ -77,18 +77,18 @@ class BPMediaImporter {
|
|
77 |
return 0;
|
78 |
}
|
79 |
|
80 |
-
function create_album( $album_name = '', $author_id = 1 ){
|
81 |
|
82 |
global $bp_media;
|
83 |
|
84 |
-
if ( array_key_exists( 'bp_album_import_name', $bp_media->options ) ){
|
85 |
-
if ( ''
|
86 |
$album_name = $bp_media->options['bp_album_import_name'];
|
87 |
}
|
88 |
}
|
89 |
$found_album = BuddyPressMedia::get_wall_album();
|
90 |
|
91 |
-
if ( count( $found_album ) < 1 ){
|
92 |
$album = new BPMediaAlbum();
|
93 |
$album->add_album( $album_name, $author_id );
|
94 |
$album_id = $album->get_id();
|
@@ -99,19 +99,17 @@ class BPMediaImporter {
|
|
99 |
return $album_id;
|
100 |
}
|
101 |
|
102 |
-
static function add_media( $album_id, $title = '', $description = '', $filepath = '', $privacy = 0, $author_id = false, $album_name = false ){
|
103 |
|
104 |
$files = BPMediaImporter::make_copy( $filepath );
|
105 |
-
if ( $files ){
|
106 |
-
global $wpdb;
|
107 |
$bp_imported_media = new BPMediaHostWordpress();
|
108 |
-
// add_filter('bp_media_force_hide_activity', create_function('', 'return true;'));
|
109 |
$imported_media_id = $bp_imported_media->insertmedia( $title, $description, $album_id, 0, false, false, $files, $author_id, $album_name );
|
110 |
|
111 |
wp_update_post( $args = array( 'ID' => $imported_media_id, 'post_author' => $author_id ) );
|
112 |
|
113 |
$bp_album_privacy = $privacy;
|
114 |
-
if ( $bp_album_privacy
|
115 |
$bp_album_privacy = 6;
|
116 |
}
|
117 |
|
@@ -124,20 +122,17 @@ class BPMediaImporter {
|
|
124 |
return 0;
|
125 |
}
|
126 |
|
127 |
-
static function cleanup( $table, $directory ){
|
128 |
global $wpdb;
|
129 |
-
$wpdb->query( "DROP TABLE IF EXISTS $table" );
|
130 |
-
$wpdb->query( $wpdb->prepare( "
|
131 |
-
|
132 |
-
WHERE component = %s
|
133 |
-
", 'album' ) );
|
134 |
-
if ( is_dir( $directory ) ){
|
135 |
BPMediaImporter::delete( $directory );
|
136 |
}
|
137 |
}
|
138 |
|
139 |
-
static function delete( $path ){
|
140 |
-
if ( true === is_dir( $path ) ){
|
141 |
$files = array_diff( scandir( $path ), array( '.', '..' ) );
|
142 |
|
143 |
foreach ( $files as $file ) {
|
@@ -146,12 +141,11 @@ class BPMediaImporter {
|
|
146 |
|
147 |
return rmdir( $path );
|
148 |
} else {
|
149 |
-
if ( true === is_file( $path ) ){
|
150 |
return unlink( $path );
|
151 |
}
|
152 |
}
|
153 |
|
154 |
return false;
|
155 |
}
|
156 |
-
|
157 |
}
|
18 |
var $active;
|
19 |
var $import_steps;
|
20 |
|
21 |
+
function __construct() {
|
22 |
|
23 |
}
|
24 |
|
25 |
+
static function table_exists( $table ) {
|
26 |
global $wpdb;
|
27 |
|
28 |
+
if ( 1 === intval( $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ) ) ) { // @codingStandardsIgnoreLine
|
29 |
return true;
|
30 |
}
|
31 |
|
32 |
return false;
|
33 |
}
|
34 |
|
35 |
+
static function _active( $path ) {
|
36 |
+
if ( ! function_exists( 'is_plugin_inactive' ) ) {
|
37 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
38 |
}
|
39 |
+
if ( is_plugin_active( $path ) ) {
|
40 |
return 1;
|
41 |
}
|
42 |
$plugins = get_plugins();
|
43 |
+
if ( array_key_exists( $path, $plugins ) ) {
|
44 |
return 0;
|
45 |
} else {
|
46 |
return - 1;
|
47 |
}
|
48 |
}
|
49 |
|
50 |
+
static function file_array( $filepath ) {
|
51 |
|
52 |
+
$path_info = pathinfo( $filepath );
|
53 |
+
$filetype = wp_check_filetype( $filepath );
|
54 |
$file['error'] = '';
|
55 |
$file['name'] = $path_info['basename'];
|
56 |
$file['type'] = $filetype['type'];
|
60 |
return $file;
|
61 |
}
|
62 |
|
63 |
+
static function make_copy( $filepath ) {
|
64 |
$upload_dir = wp_upload_dir();
|
65 |
$path_info = pathinfo( $filepath );
|
66 |
$tmp_dir = trailingslashit( $upload_dir['basedir'] ) . 'bp-album-importer';
|
67 |
$newpath = trailingslashit( $tmp_dir ) . $path_info['basename'];
|
68 |
+
if ( ! is_dir( $tmp_dir ) ) {
|
69 |
wp_mkdir_p( $tmp_dir );
|
70 |
}
|
71 |
+
if ( file_exists( $filepath ) ) {
|
72 |
+
if ( copy( $filepath, $newpath ) ) {
|
73 |
return BPMediaImporter::file_array( $newpath );
|
74 |
}
|
75 |
}
|
77 |
return 0;
|
78 |
}
|
79 |
|
80 |
+
function create_album( $album_name = '', $author_id = 1 ) {
|
81 |
|
82 |
global $bp_media;
|
83 |
|
84 |
+
if ( array_key_exists( 'bp_album_import_name', $bp_media->options ) ) {
|
85 |
+
if ( '' !== $bp_media->options['bp_album_import_name'] ) {
|
86 |
$album_name = $bp_media->options['bp_album_import_name'];
|
87 |
}
|
88 |
}
|
89 |
$found_album = BuddyPressMedia::get_wall_album();
|
90 |
|
91 |
+
if ( count( $found_album ) < 1 ) {
|
92 |
$album = new BPMediaAlbum();
|
93 |
$album->add_album( $album_name, $author_id );
|
94 |
$album_id = $album->get_id();
|
99 |
return $album_id;
|
100 |
}
|
101 |
|
102 |
+
static function add_media( $album_id, $title = '', $description = '', $filepath = '', $privacy = 0, $author_id = false, $album_name = false ) {
|
103 |
|
104 |
$files = BPMediaImporter::make_copy( $filepath );
|
105 |
+
if ( $files ) {
|
|
|
106 |
$bp_imported_media = new BPMediaHostWordpress();
|
|
|
107 |
$imported_media_id = $bp_imported_media->insertmedia( $title, $description, $album_id, 0, false, false, $files, $author_id, $album_name );
|
108 |
|
109 |
wp_update_post( $args = array( 'ID' => $imported_media_id, 'post_author' => $author_id ) );
|
110 |
|
111 |
$bp_album_privacy = $privacy;
|
112 |
+
if ( 10 === intval( $bp_album_privacy ) ) {
|
113 |
$bp_album_privacy = 6;
|
114 |
}
|
115 |
|
122 |
return 0;
|
123 |
}
|
124 |
|
125 |
+
static function cleanup( $table, $directory ) {
|
126 |
global $wpdb;
|
127 |
+
$wpdb->query( "DROP TABLE IF EXISTS $table" ); // @codingStandardsIgnoreLine
|
128 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}bp_activity WHERE component = %s", 'album' ) );
|
129 |
+
if ( is_dir( $directory ) ) {
|
|
|
|
|
|
|
130 |
BPMediaImporter::delete( $directory );
|
131 |
}
|
132 |
}
|
133 |
|
134 |
+
static function delete( $path ) {
|
135 |
+
if ( true === is_dir( $path ) ) {
|
136 |
$files = array_diff( scandir( $path ), array( '.', '..' ) );
|
137 |
|
138 |
foreach ( $files as $file ) {
|
141 |
|
142 |
return rmdir( $path );
|
143 |
} else {
|
144 |
+
if ( true === is_file( $path ) ) {
|
145 |
return unlink( $path );
|
146 |
}
|
147 |
}
|
148 |
|
149 |
return false;
|
150 |
}
|
|
|
151 |
}
|
app/importers/RTMediaActivityUpgrade.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
*/
|
9 |
class RTMediaActivityUpgrade {
|
10 |
|
11 |
-
function __construct(){
|
12 |
add_filter( 'rtmedia_filter_admin_pages_array', array( $this, 'rtmedia_add_admin_page_array' ), 11, 1 );
|
13 |
add_action( 'admin_init', array( $this, 'add_admin_notice' ) );
|
14 |
add_action( 'admin_menu', array( $this, 'menu' ), 10 );
|
@@ -16,35 +16,39 @@ class RTMediaActivityUpgrade {
|
|
16 |
add_action( 'wp_ajax_rtmedia_activity_done_upgrade', array( $this, 'rtmedia_activity_done_upgrade' ) );
|
17 |
}
|
18 |
|
19 |
-
function menu(){
|
20 |
-
add_submenu_page( 'rtmedia-setting',
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
-
function rtmedia_add_admin_page_array( $admin_pages ){
|
24 |
$admin_pages[] = 'rtmedia_page_rtmedia-activity-upgrade';
|
25 |
|
26 |
return $admin_pages;
|
27 |
}
|
28 |
|
29 |
-
function rtmedia_activity_done_upgrade(){
|
30 |
rtmedia_update_site_option( 'rtmedia_activity_done_upgrade', true );
|
31 |
die();
|
32 |
}
|
33 |
|
34 |
-
function add_admin_notice(){
|
35 |
$pending = $this->get_pending_count();
|
36 |
$upgrade_done = rtmedia_get_site_option( 'rtmedia_activity_done_upgrade' );
|
37 |
-
if ( $upgrade_done ){
|
38 |
return;
|
39 |
}
|
40 |
-
if ( $pending < 0 ){
|
41 |
$pending = 0;
|
42 |
}
|
43 |
rtmedia_update_site_option( 'rtmedia_media_activity_upgrade_pending', $pending );
|
44 |
-
|
45 |
-
|
|
|
46 |
$site_option = get_site_option( 'rtmedia_activity_upgrade_notice' );
|
47 |
-
if ( ! $site_option || 'hide'
|
48 |
rtmedia_update_site_option( 'rtmedia_activity_upgrade_notice', 'show' );
|
49 |
add_action( 'admin_notices', array( &$this, 'add_rtmedia_media_activity_upgrade_notice' ) );
|
50 |
}
|
@@ -54,21 +58,24 @@ class RTMediaActivityUpgrade {
|
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
function rtmedia_activity_upgrade( $lastid = 0, $limit = 1 ){
|
58 |
global $wpdb;
|
59 |
-
if(
|
60 |
$rtmedia_model = new RTMediaModel();
|
61 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
62 |
-
$activity_sql = " SELECT *, max(privacy) as max_privacy FROM {$rtmedia_model->table_name} WHERE activity_id is NOT NULL GROUP BY activity_id ORDER BY id limit "
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
$activity_sql = " SELECT *, max(privacy) as max_privacy FROM {$rtmedia_model->table_name} WHERE activity_id > " . $lastid . ' AND activity_id is NOT NULL GROUP BY activity_id ORDER BY id limit ' . $limit;
|
68 |
}
|
69 |
-
$activity_data = $wpdb->get_results( $activity_sql );
|
70 |
-
if ( is_array( $activity_data ) && ! empty( $activity_data ) ){
|
71 |
-
$rtmedia_activity_model->insert( array(
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
$this->return_upgrade( $activity_data[0] );
|
74 |
} else {
|
@@ -78,71 +85,86 @@ class RTMediaActivityUpgrade {
|
|
78 |
|
79 |
}
|
80 |
|
81 |
-
function return_upgrade( $activity_data, $upgrade = true ){
|
82 |
$total = $this->get_total_count();
|
83 |
$pending = $this->get_pending_count( $activity_data->activity_id );
|
84 |
$done = $total - $pending;
|
85 |
-
if ( $pending < 0 ){
|
86 |
$pending = 0;
|
87 |
$done = $total;
|
88 |
}
|
89 |
-
if ( $done > $total ){
|
90 |
$done = $total;
|
91 |
}
|
92 |
rtmedia_update_site_option( 'rtmedia_media_activity_upgrade_pending', $pending );
|
93 |
$pending_time = rtmedia_migrate_formatseconds( $pending ) . ' (estimated)';
|
94 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
die();
|
96 |
}
|
97 |
|
98 |
-
function add_rtmedia_media_activity_upgrade_notice(){
|
99 |
-
if ( current_user_can( 'manage_options' ) ){
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
}
|
103 |
|
104 |
-
function get_pending_count( $activity_id = false ){
|
105 |
global $wpdb;
|
106 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
107 |
$rtmedia_model = new RTMediaModel();
|
108 |
-
$query_pending = " SELECT count( DISTINCT activity_id) as pending from {$rtmedia_model->table_name} where activity_id NOT IN( SELECT activity_id from {$rtmedia_activity_model->table_name} ) AND activity_id >
|
109 |
$last_imported = $this->get_last_imported();
|
110 |
-
if ( $last_imported ){
|
111 |
-
$query_pending .=
|
112 |
}
|
113 |
-
$pending_count = $wpdb->get_results( $query_pending );
|
114 |
-
if ( $pending_count &&
|
115 |
return $pending_count[0]->pending;
|
116 |
}
|
117 |
|
118 |
return 0;
|
119 |
}
|
120 |
|
121 |
-
function get_total_count(){
|
122 |
global $wpdb;
|
123 |
$rtmedia_model = new RTMediaModel();
|
124 |
-
$query_total = " SELECT count( DISTINCT activity_id) as total FROM {$rtmedia_model->table_name} WHERE activity_id > 0
|
125 |
-
$total_count = $wpdb->get_results( $query_total );
|
126 |
-
if ( $total_count &&
|
127 |
return $total_count[0]->total;
|
128 |
}
|
129 |
|
130 |
return 0;
|
131 |
}
|
132 |
|
133 |
-
function get_last_imported(){
|
134 |
global $wpdb;
|
135 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
136 |
-
$last_query = " SELECT activity_id from {$rtmedia_activity_model->table_name} ORDER BY activity_id DESC limit 1
|
137 |
-
$last_imported = $wpdb->get_results( $last_query );
|
138 |
-
if ( $last_imported &&
|
139 |
return $last_imported[0]->activity_id;
|
140 |
}
|
141 |
|
142 |
return 0;
|
143 |
}
|
144 |
|
145 |
-
function init(){
|
146 |
$prog = new rtProgress();
|
147 |
$pending = $this->get_pending_count();
|
148 |
$total = $this->get_total_count();
|
@@ -151,11 +173,11 @@ class RTMediaActivityUpgrade {
|
|
151 |
$admin_ajax = admin_url( 'admin-ajax.php' );
|
152 |
?>
|
153 |
<div class="wrap">
|
154 |
-
<h2
|
155 |
<?php
|
156 |
wp_nonce_field( 'rtmedia_media_activity_upgrade_nonce', 'rtmedia_media_activity_upgrade_nonce' );
|
157 |
-
echo '<span class="pending">' . rtmedia_migrate_formatseconds( $total - $done ) . '
|
158 |
-
echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
|
159 |
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
160 |
|
161 |
$temp = $prog->progress( $done, $total );
|
@@ -179,93 +201,91 @@ class RTMediaActivityUpgrade {
|
|
179 |
<script type="text/javascript">
|
180 |
var fail_id = new Array();
|
181 |
var ajax_data;
|
182 |
-
jQuery(
|
183 |
-
jQuery(
|
184 |
-
jQuery(
|
185 |
-
jQuery(
|
186 |
-
jQuery(
|
187 |
-
jQuery(
|
188 |
-
if (
|
189 |
-
jQuery(
|
190 |
-
}
|
191 |
-
function db_start_migration(
|
192 |
|
193 |
-
if (
|
194 |
-
jQuery(
|
195 |
ajax_data = {
|
196 |
"action": "rtmedia_activity_upgrade",
|
197 |
"done": db_done,
|
198 |
"last_id": last_id,
|
199 |
-
"nonce"
|
200 |
-
}
|
201 |
-
jQuery.ajax(
|
202 |
-
url: '<?php echo $admin_ajax; ?>',
|
203 |
type: 'post',
|
204 |
data: ajax_data,
|
205 |
-
success: function (
|
206 |
|
207 |
try {
|
208 |
-
data = JSON.parse(
|
209 |
-
} catch (
|
210 |
-
jQuery(
|
211 |
}
|
212 |
-
if (
|
213 |
-
done = parseInt(
|
214 |
-
total = parseInt(
|
215 |
-
var progw = Math.ceil(
|
216 |
-
if (
|
217 |
progw = 100;
|
218 |
}
|
219 |
-
;
|
220 |
-
jQuery(
|
221 |
-
jQuery(
|
222 |
-
jQuery(
|
223 |
-
|
224 |
-
|
225 |
-
fail_id.push( data.activity_id );
|
226 |
}
|
227 |
-
db_start_migration(
|
228 |
} else {
|
229 |
-
alert(
|
230 |
-
jQuery(
|
231 |
}
|
232 |
},
|
233 |
error: function () {
|
234 |
-
alert(
|
235 |
-
jQuery(
|
236 |
}
|
237 |
-
}
|
238 |
} else {
|
239 |
data = {
|
240 |
action: 'rtmedia_activity_done_upgrade'
|
241 |
-
}
|
242 |
-
jQuery.post(
|
243 |
-
alert(
|
244 |
-
}
|
245 |
-
if (
|
246 |
rtm_show_file_error();
|
247 |
}
|
248 |
-
jQuery(
|
249 |
}
|
250 |
}
|
251 |
function rtm_show_file_error() {
|
252 |
-
jQuery(
|
253 |
}
|
254 |
-
var db_done = <?php echo $done; ?>;
|
255 |
-
var db_total = <?php echo $total; ?>;
|
256 |
-
var last_id = <?php echo $last_id; ?>;
|
257 |
-
jQuery(
|
258 |
e.preventDefault();
|
259 |
-
db_start_migration(
|
260 |
-
jQuery(
|
261 |
-
}
|
262 |
</script>
|
263 |
<hr/>
|
264 |
-
<?php if ( ! ( isset( $rtmedia_error ) && true === $rtmedia_error ) ){ ?>
|
265 |
<input type="button" id="submit" value="start" class="button button-primary"/>
|
266 |
<?php } ?>
|
267 |
</div>
|
268 |
-
|
269 |
}
|
270 |
-
|
271 |
-
}
|
8 |
*/
|
9 |
class RTMediaActivityUpgrade {
|
10 |
|
11 |
+
function __construct() {
|
12 |
add_filter( 'rtmedia_filter_admin_pages_array', array( $this, 'rtmedia_add_admin_page_array' ), 11, 1 );
|
13 |
add_action( 'admin_init', array( $this, 'add_admin_notice' ) );
|
14 |
add_action( 'admin_menu', array( $this, 'menu' ), 10 );
|
16 |
add_action( 'wp_ajax_rtmedia_activity_done_upgrade', array( $this, 'rtmedia_activity_done_upgrade' ) );
|
17 |
}
|
18 |
|
19 |
+
function menu() {
|
20 |
+
add_submenu_page( 'rtmedia-setting', esc_html__( 'Media activity upgrade', 'buddypress-media' ), esc_html__( 'Media activity upgrade', 'buddypress-media' ), 'manage_options', 'rtmedia-activity-upgrade', array(
|
21 |
+
$this,
|
22 |
+
'init',
|
23 |
+
) );
|
24 |
}
|
25 |
|
26 |
+
function rtmedia_add_admin_page_array( $admin_pages ) {
|
27 |
$admin_pages[] = 'rtmedia_page_rtmedia-activity-upgrade';
|
28 |
|
29 |
return $admin_pages;
|
30 |
}
|
31 |
|
32 |
+
function rtmedia_activity_done_upgrade() {
|
33 |
rtmedia_update_site_option( 'rtmedia_activity_done_upgrade', true );
|
34 |
die();
|
35 |
}
|
36 |
|
37 |
+
function add_admin_notice() {
|
38 |
$pending = $this->get_pending_count();
|
39 |
$upgrade_done = rtmedia_get_site_option( 'rtmedia_activity_done_upgrade' );
|
40 |
+
if ( $upgrade_done ) {
|
41 |
return;
|
42 |
}
|
43 |
+
if ( $pending < 0 ) {
|
44 |
$pending = 0;
|
45 |
}
|
46 |
rtmedia_update_site_option( 'rtmedia_media_activity_upgrade_pending', $pending );
|
47 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
48 |
+
if ( $pending > 0 ) {
|
49 |
+
if ( ! ( isset( $page ) && 'rtmedia-activity-upgrade' === $page ) ) {
|
50 |
$site_option = get_site_option( 'rtmedia_activity_upgrade_notice' );
|
51 |
+
if ( ! $site_option || 'hide' !== $site_option ) {
|
52 |
rtmedia_update_site_option( 'rtmedia_activity_upgrade_notice', 'show' );
|
53 |
add_action( 'admin_notices', array( &$this, 'add_rtmedia_media_activity_upgrade_notice' ) );
|
54 |
}
|
58 |
}
|
59 |
}
|
60 |
|
61 |
+
function rtmedia_activity_upgrade( $lastid = 0, $limit = 1 ) {
|
62 |
global $wpdb;
|
63 |
+
if ( check_ajax_referer( 'rtmedia_media_activity_upgrade_nonce', 'nonce' ) ) {
|
64 |
$rtmedia_model = new RTMediaModel();
|
65 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
66 |
+
$activity_sql = $wpdb->prepare( " SELECT *, max(privacy) as max_privacy FROM {$rtmedia_model->table_name} WHERE activity_id is NOT NULL GROUP BY activity_id ORDER BY id limit %d", $limit ); // @codingStandardsIgnoreLine
|
67 |
+
|
68 |
+
$lastid = filter_input( INPUT_POST, 'last_id', FILTER_SANITIZE_NUMBER_INT );
|
69 |
+
if ( ! empty( $lastid ) ) {
|
70 |
+
$activity_sql = $wpdb->prepare( " SELECT *, max(privacy) as max_privacy FROM {$rtmedia_model->table_name} WHERE activity_id > %d AND activity_id is NOT NULL GROUP BY activity_id ORDER BY id limit %d", $lastid, $limit ); // @codingStandardsIgnoreLine
|
|
|
71 |
}
|
72 |
+
$activity_data = $wpdb->get_results( $activity_sql ); // @codingStandardsIgnoreLine
|
73 |
+
if ( is_array( $activity_data ) && ! empty( $activity_data ) ) {
|
74 |
+
$rtmedia_activity_model->insert( array(
|
75 |
+
'activity_id' => $activity_data[0]->activity_id,
|
76 |
+
'user_id' => $activity_data[0]->media_author,
|
77 |
+
'privacy' => $activity_data[0]->max_privacy,
|
78 |
+
) );
|
79 |
}
|
80 |
$this->return_upgrade( $activity_data[0] );
|
81 |
} else {
|
85 |
|
86 |
}
|
87 |
|
88 |
+
function return_upgrade( $activity_data, $upgrade = true ) {
|
89 |
$total = $this->get_total_count();
|
90 |
$pending = $this->get_pending_count( $activity_data->activity_id );
|
91 |
$done = $total - $pending;
|
92 |
+
if ( $pending < 0 ) {
|
93 |
$pending = 0;
|
94 |
$done = $total;
|
95 |
}
|
96 |
+
if ( $done > $total ) {
|
97 |
$done = $total;
|
98 |
}
|
99 |
rtmedia_update_site_option( 'rtmedia_media_activity_upgrade_pending', $pending );
|
100 |
$pending_time = rtmedia_migrate_formatseconds( $pending ) . ' (estimated)';
|
101 |
+
echo wp_json_encode( array(
|
102 |
+
'status' => true,
|
103 |
+
'done' => $done,
|
104 |
+
'total' => $total,
|
105 |
+
'pending' => $pending_time,
|
106 |
+
'activity_id' => $activity_data->activity_id,
|
107 |
+
'imported' => $upgrade,
|
108 |
+
) );
|
109 |
die();
|
110 |
}
|
111 |
|
112 |
+
function add_rtmedia_media_activity_upgrade_notice() {
|
113 |
+
if ( current_user_can( 'manage_options' ) ) {
|
114 |
+
?>
|
115 |
+
<div class='error rtmedia-activity-upgrade-notice'>
|
116 |
+
<p><strong><?php esc_html_e( 'rtMedia', 'buddypress-media' ); ?></strong>
|
117 |
+
<?php esc_html_e( ': Database table structure for rtMedia has been updated. Please ', 'buddypress-media' ); ?>
|
118 |
+
<a href='<?php echo esc_url( admin_url( 'admin.php?page=rtmedia-activity-upgrade' ) ); ?>'><?php esc_html_e( 'Click Here', 'buddypress-media' ) ?></a>
|
119 |
+
<?php esc_html_e( ' to upgrade rtMedia activities.', 'buddypress-media' ); ?>
|
120 |
+
</p>
|
121 |
+
</div>
|
122 |
+
<?php
|
123 |
}
|
124 |
}
|
125 |
|
126 |
+
function get_pending_count( $activity_id = false ) {
|
127 |
global $wpdb;
|
128 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
129 |
$rtmedia_model = new RTMediaModel();
|
130 |
+
$query_pending = $wpdb->prepare( " SELECT count( DISTINCT activity_id) as pending from {$rtmedia_model->table_name} where activity_id NOT IN( SELECT activity_id from {$rtmedia_activity_model->table_name} ) AND activity_id > %d ", 0 ); // @codingStandardsIgnoreLine
|
131 |
$last_imported = $this->get_last_imported();
|
132 |
+
if ( $last_imported ) {
|
133 |
+
$query_pending .= $wpdb->prepare( ' AND activity_id > %d', intval( $last_imported ) );
|
134 |
}
|
135 |
+
$pending_count = $wpdb->get_results( $query_pending ); // @codingStandardsIgnoreLine
|
136 |
+
if ( $pending_count && count( $pending_count ) > 0 ) {
|
137 |
return $pending_count[0]->pending;
|
138 |
}
|
139 |
|
140 |
return 0;
|
141 |
}
|
142 |
|
143 |
+
function get_total_count() {
|
144 |
global $wpdb;
|
145 |
$rtmedia_model = new RTMediaModel();
|
146 |
+
$query_total = $wpdb->prepare( " SELECT count( DISTINCT activity_id) as total FROM {$rtmedia_model->table_name} WHERE activity_id > %d ", 0 ); // @codingStandardsIgnoreLine
|
147 |
+
$total_count = $wpdb->get_results( $query_total ); // @codingStandardsIgnoreLine
|
148 |
+
if ( $total_count && count( $total_count ) > 0 ) {
|
149 |
return $total_count[0]->total;
|
150 |
}
|
151 |
|
152 |
return 0;
|
153 |
}
|
154 |
|
155 |
+
function get_last_imported() {
|
156 |
global $wpdb;
|
157 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
158 |
+
$last_query = $wpdb->prepare( " SELECT activity_id from {$rtmedia_activity_model->table_name} ORDER BY activity_id DESC limit %d ", 1 ); // @codingStandardsIgnoreLine
|
159 |
+
$last_imported = $wpdb->get_results( $last_query ); // @codingStandardsIgnoreLine
|
160 |
+
if ( $last_imported && count( $last_imported ) > 0 && isset( $last_imported[0] ) && isset( $last_imported[0]->activity_id ) ) {
|
161 |
return $last_imported[0]->activity_id;
|
162 |
}
|
163 |
|
164 |
return 0;
|
165 |
}
|
166 |
|
167 |
+
function init() {
|
168 |
$prog = new rtProgress();
|
169 |
$pending = $this->get_pending_count();
|
170 |
$total = $this->get_total_count();
|
173 |
$admin_ajax = admin_url( 'admin-ajax.php' );
|
174 |
?>
|
175 |
<div class="wrap">
|
176 |
+
<h2><?php esc_html_e( 'rtMedia: Upgrade rtMedia activity', 'buddypress-media' ); ?></h2>
|
177 |
<?php
|
178 |
wp_nonce_field( 'rtmedia_media_activity_upgrade_nonce', 'rtmedia_media_activity_upgrade_nonce' );
|
179 |
+
echo '<span class="pending">' . sprintf( esc_html__( '%s (estimated)', 'buddypress-media' ), esc_html( rtmedia_migrate_formatseconds( $total - $done ) ) ) . '</span><br />';
|
180 |
+
echo '<span class="finished">' . esc_html( $done ) . '</span>/<span class="total">' . esc_html( $total ) . '</span>';
|
181 |
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
182 |
|
183 |
$temp = $prog->progress( $done, $total );
|
201 |
<script type="text/javascript">
|
202 |
var fail_id = new Array();
|
203 |
var ajax_data;
|
204 |
+
jQuery(document).ready(function (e) {
|
205 |
+
jQuery("#toplevel_page_rtmedia-settings").addClass("wp-has-current-submenu")
|
206 |
+
jQuery("#toplevel_page_rtmedia-settings").removeClass("wp-not-current-submenu")
|
207 |
+
jQuery("#toplevel_page_rtmedia-settings").addClass("wp-menu-open")
|
208 |
+
jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-menu-open")
|
209 |
+
jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-has-current-submenu")
|
210 |
+
if (db_total < 1)
|
211 |
+
jQuery("#submit").attr('disabled', "disabled");
|
212 |
+
});
|
213 |
+
function db_start_migration(db_done, db_total, last_id) {
|
214 |
|
215 |
+
if (db_done < db_total) {
|
216 |
+
jQuery("#rtMediaSyncing").show();
|
217 |
ajax_data = {
|
218 |
"action": "rtmedia_activity_upgrade",
|
219 |
"done": db_done,
|
220 |
"last_id": last_id,
|
221 |
+
"nonce": jQuery.trim(jQuery('#rtmedia_media_activity_upgrade_nonce').val())
|
222 |
+
};
|
223 |
+
jQuery.ajax({
|
224 |
+
url: '<?php echo esc_url( $admin_ajax ); ?>',
|
225 |
type: 'post',
|
226 |
data: ajax_data,
|
227 |
+
success: function (sdata) {
|
228 |
|
229 |
try {
|
230 |
+
data = JSON.parse(sdata);
|
231 |
+
} catch (e) {
|
232 |
+
jQuery("#submit").attr('disabled', "");
|
233 |
}
|
234 |
+
if (data.status) {
|
235 |
+
done = parseInt(data.done);
|
236 |
+
total = parseInt(data.total);
|
237 |
+
var progw = Math.ceil((done / total) * 100);
|
238 |
+
if (progw > 100) {
|
239 |
progw = 100;
|
240 |
}
|
241 |
+
jQuery('#rtprogressbar>div').css('width', progw + '%');
|
242 |
+
jQuery('span.finished').html(done);
|
243 |
+
jQuery('span.total').html(total);
|
244 |
+
jQuery('span.pending').html(data.pending);
|
245 |
+
if (data.imported === false) {
|
246 |
+
fail_id.push(data.activity_id);
|
|
|
247 |
}
|
248 |
+
db_start_migration(done, total, parseInt(data.activity_id));
|
249 |
} else {
|
250 |
+
alert("Migration completed.");
|
251 |
+
jQuery("#rtMediaSyncing").hide();
|
252 |
}
|
253 |
},
|
254 |
error: function () {
|
255 |
+
alert("Error During Migration, Please Refresh Page then try again");
|
256 |
+
jQuery("#submit").removeAttr('disabled');
|
257 |
}
|
258 |
+
});
|
259 |
} else {
|
260 |
data = {
|
261 |
action: 'rtmedia_activity_done_upgrade'
|
262 |
+
};
|
263 |
+
jQuery.post('<?php echo esc_sql( $admin_ajax ); ?>', data, function () {
|
264 |
+
alert("Database upgrade completed.");
|
265 |
+
});
|
266 |
+
if (fail_id.length > 0) {
|
267 |
rtm_show_file_error();
|
268 |
}
|
269 |
+
jQuery("#rtMediaSyncing").hide();
|
270 |
}
|
271 |
}
|
272 |
function rtm_show_file_error() {
|
273 |
+
jQuery('span.pending').html("Some activities are failed to upgrade, Don't worry about that.");
|
274 |
}
|
275 |
+
var db_done = <?php echo esc_js( $done ); ?>;
|
276 |
+
var db_total = <?php echo esc_js( $total ); ?>;
|
277 |
+
var last_id = <?php echo esc_js( $last_id ); ?>;
|
278 |
+
jQuery(document).on('click', '#submit', function (e) {
|
279 |
e.preventDefault();
|
280 |
+
db_start_migration(db_done, db_total, last_id);
|
281 |
+
jQuery(this).attr('disabled', 'disabled');
|
282 |
+
});
|
283 |
</script>
|
284 |
<hr/>
|
285 |
+
<?php if ( ! ( isset( $rtmedia_error ) && true === $rtmedia_error ) ) { ?>
|
286 |
<input type="button" id="submit" value="start" class="button button-primary"/>
|
287 |
<?php } ?>
|
288 |
</div>
|
289 |
+
<?php
|
290 |
}
|
291 |
+
}
|
|
app/importers/RTMediaMediaSizeImporter.php
CHANGED
@@ -13,26 +13,32 @@
|
|
13 |
*/
|
14 |
class RTMediaMediaSizeImporter {
|
15 |
|
16 |
-
function __construct(){
|
17 |
add_filter( 'rtmedia_filter_admin_pages_array', array( $this, 'rtmedia_add_admin_page_array' ), 11, 1 );
|
18 |
add_action( 'wp_ajax_rtmedia_media_size_import', array( $this, 'rtmedia_media_size_import' ) );
|
19 |
add_action( 'admin_init', array( $this, 'add_admin_notice' ) );
|
20 |
add_action( 'admin_menu', array( $this, 'menu' ), 10 );
|
21 |
-
add_action( 'wp_ajax_rtmedia_hide_media_size_import_notice', array(
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
-
function menu(){
|
25 |
-
add_submenu_page( 'rtmedia-setting',
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
-
function rtmedia_add_admin_page_array( $admin_pages ){
|
29 |
$admin_pages[] = 'rtmedia_page_rtmedia-media-size-import';
|
30 |
|
31 |
return $admin_pages;
|
32 |
}
|
33 |
|
34 |
-
function rtmedia_hide_media_size_import_notice(){
|
35 |
-
if ( rtmedia_update_site_option( 'rtmedia_hide_media_size_import_notice', true ) ){
|
36 |
echo '1';
|
37 |
} else {
|
38 |
echo '0';
|
@@ -40,20 +46,21 @@ class RTMediaMediaSizeImporter {
|
|
40 |
wp_die();
|
41 |
}
|
42 |
|
43 |
-
function add_admin_notice(){
|
44 |
$pending = $this->get_pending_count();
|
45 |
-
if ( $pending < 0 ){
|
46 |
$pending = 0;
|
47 |
}
|
48 |
rtmedia_update_site_option( 'rtmedia_media_size_import_pending_count', $pending );
|
49 |
$hide_admin_option = rtmedia_get_site_option( 'rtmedia_hide_media_size_import_notice' );
|
50 |
-
if ( $hide_admin_option ){
|
51 |
return;
|
52 |
}
|
53 |
-
if ( $pending > 0 ){
|
54 |
-
|
|
|
55 |
$site_option = get_site_option( 'rtmedia_media_size_import_notice' );
|
56 |
-
if ( ! $site_option || 'hide'
|
57 |
rtmedia_update_site_option( 'rtmedia_media_size_import_notice', 'show' );
|
58 |
add_action( 'admin_notices', array( &$this, 'add_rtmedia_media_size_import_notice' ) );
|
59 |
}
|
@@ -61,40 +68,45 @@ class RTMediaMediaSizeImporter {
|
|
61 |
}
|
62 |
}
|
63 |
|
64 |
-
function add_rtmedia_media_size_import_notice(){
|
65 |
-
if ( current_user_can( 'manage_options' ) ){
|
66 |
-
$this->create_notice(
|
67 |
?>
|
68 |
<script type="text/javascript">
|
69 |
function rtmedia_hide_media_size_import_notice() {
|
70 |
var data = {action: 'rtmedia_hide_media_size_import_notice'};
|
71 |
-
jQuery.post(
|
72 |
response = response.trim();
|
73 |
-
if (
|
74 |
-
jQuery(
|
75 |
-
}
|
76 |
}
|
77 |
</script>
|
78 |
-
|
79 |
}
|
80 |
}
|
81 |
|
82 |
-
function create_notice( $message, $type = 'error' ){
|
83 |
-
echo '<div class="' . $type . ' rtmedia-media-size-import-error">'
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
-
function init(){
|
87 |
$prog = new rtProgress();
|
88 |
$pending = $this->get_pending_count();
|
89 |
$total = $this->get_total_count();
|
90 |
$done = $total - $pending;
|
91 |
?>
|
92 |
<div class="wrap">
|
93 |
-
<h2
|
94 |
<?php
|
95 |
wp_nonce_field( 'rtmedia_media_size_import_nonce', 'rtmedia_media_size_import_nonce' );
|
96 |
-
echo '<span class="pending">' . rtmedia_migrate_formatseconds( $total - $done ) . '
|
97 |
-
echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
|
98 |
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
99 |
|
100 |
$temp = $prog->progress( $done, $total );
|
@@ -103,133 +115,127 @@ class RTMediaMediaSizeImporter {
|
|
103 |
<script type="text/javascript">
|
104 |
var fail_id = new Array();
|
105 |
var ajax_data;
|
106 |
-
jQuery(
|
107 |
-
jQuery(
|
108 |
-
jQuery(
|
109 |
-
jQuery(
|
110 |
-
jQuery(
|
111 |
-
jQuery(
|
112 |
-
if (
|
113 |
-
jQuery(
|
114 |
-
}
|
115 |
-
function db_start_migration(
|
116 |
|
117 |
-
if (
|
118 |
-
jQuery(
|
119 |
ajax_data = {
|
120 |
"action": "rtmedia_media_size_import",
|
121 |
"done": db_done,
|
122 |
"last_id": last_id,
|
123 |
-
"nonce"
|
124 |
-
}
|
125 |
-
jQuery.ajax(
|
126 |
url: rtmedia_admin_ajax,
|
127 |
type: 'post',
|
128 |
data: ajax_data,
|
129 |
-
success: function (
|
130 |
|
131 |
try {
|
132 |
-
data = JSON.parse(
|
133 |
-
} catch (
|
134 |
-
jQuery(
|
135 |
}
|
136 |
-
if (
|
137 |
-
done = parseInt(
|
138 |
-
total = parseInt(
|
139 |
-
var progw = Math.ceil(
|
140 |
-
if (
|
141 |
progw = 100;
|
142 |
}
|
143 |
-
;
|
144 |
-
jQuery(
|
145 |
-
jQuery(
|
146 |
-
jQuery(
|
147 |
-
|
148 |
-
|
149 |
-
fail_id.push( data.media_id );
|
150 |
}
|
151 |
-
db_start_migration(
|
152 |
} else {
|
153 |
-
alert(
|
154 |
-
jQuery(
|
155 |
}
|
156 |
},
|
157 |
error: function () {
|
158 |
-
alert(
|
159 |
-
jQuery(
|
160 |
}
|
161 |
-
}
|
162 |
} else {
|
163 |
-
alert(
|
164 |
-
if (
|
165 |
rtm_show_file_error();
|
166 |
}
|
167 |
-
jQuery(
|
168 |
}
|
169 |
}
|
170 |
function rtm_show_file_error() {
|
171 |
-
jQuery(
|
172 |
-
// var data = {action: 'rtmedia_hide_media_size_import_notice'};
|
173 |
-
// jQuery.post( ajaxurl, data, function ( response ) { } );
|
174 |
-
// jQuery( "#rtMediaSyncing" ).hide();
|
175 |
}
|
176 |
-
var db_done = <?php echo $done; ?>;
|
177 |
-
var db_total = <?php echo $total; ?>;
|
178 |
-
jQuery(
|
179 |
e.preventDefault();
|
180 |
-
db_start_migration(
|
181 |
-
jQuery(
|
182 |
-
}
|
183 |
</script>
|
184 |
<hr/>
|
185 |
-
<?php if ( ! ( isset( $rtmedia_error ) && true === $rtmedia_error ) ){ ?>
|
186 |
<input type="button" id="submit" value="start" class="button button-primary"/>
|
187 |
<?php } ?>
|
188 |
</div>
|
189 |
-
|
190 |
}
|
191 |
|
192 |
-
function get_pending_count( $media_id = false ){
|
193 |
global $wpdb;
|
194 |
$rtmedia_model = new RTMediaModel();
|
195 |
$query_pending = "SELECT COUNT(*) as pending from {$rtmedia_model->table_name} where file_size IS NULL AND media_type in ('photo','video','document','music','other')";
|
196 |
-
if ( $media_id ){
|
197 |
-
$media_id
|
198 |
-
$query_pending = "SELECT COUNT(*) as pending from {$rtmedia_model->table_name} where file_size IS NULL AND media_type in ('photo','video','document','music','other') AND id >
|
199 |
}
|
200 |
-
$pending_count = $wpdb->get_results( $query_pending );
|
201 |
-
if ( $pending_count &&
|
202 |
return $pending_count[0]->pending;
|
203 |
}
|
204 |
|
205 |
return 0;
|
206 |
}
|
207 |
|
208 |
-
function get_total_count(){
|
209 |
global $wpdb;
|
210 |
$rtmedia_model = new RTMediaModel();
|
211 |
-
$query_total = "SELECT COUNT(*) as total from {$rtmedia_model->table_name} where media_type in ('photo','video','document','music','other') ";
|
212 |
-
$total_count = $wpdb->get_results( $query_total );
|
213 |
-
if ( $total_count &&
|
214 |
return $total_count[0]->total;
|
215 |
}
|
216 |
|
217 |
return 0;
|
218 |
}
|
219 |
|
220 |
-
function rtmedia_media_size_import( $lastid = 0, $limit = 1 ){
|
221 |
global $wpdb;
|
222 |
-
if(
|
223 |
$rtmedia_model = new RTMediaModel();
|
224 |
-
$get_media_sql = "SELECT * from {$rtmedia_model->table_name} where file_size is NULL and media_type in ('photo','video','document','music','other') order by id limit "
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
if ( $lastid ){
|
229 |
-
$get_media_sql = "SELECT * from {$rtmedia_model->table_name} where id > '" . $lastid . "' AND file_size is NULL and media_type in ('photo','video','document','music','other') order by id limit " . $limit;
|
230 |
}
|
231 |
-
$result = $wpdb->get_results( $get_media_sql );
|
232 |
-
if ( $result &&
|
233 |
$migrate = $this->migrate_single_media( $result[0] );
|
234 |
}
|
235 |
$this->return_migration( $result[0], $migrate );
|
@@ -240,41 +246,48 @@ class RTMediaMediaSizeImporter {
|
|
240 |
|
241 |
}
|
242 |
|
243 |
-
function migrate_single_media( $result ){
|
244 |
global $wpdb;
|
245 |
$rtmedia_model = new RTMediaModel();
|
246 |
$attached_file = get_attached_file( $result->media_id );
|
247 |
$return = true;
|
248 |
-
if ( file_exists( $attached_file ) ){
|
249 |
$file_size = filesize( $attached_file );
|
250 |
} else {
|
251 |
-
$
|
252 |
-
error_log( 'rtMedia size importer: file not exist. Media ID: ' . $result->id . ', File: ' . $attached_file );
|
253 |
-
$return = false;
|
254 |
-
|
255 |
return false;
|
256 |
}
|
257 |
$post = get_post( $result->media_id );
|
258 |
$post_date = $post->post_date;
|
259 |
-
$rtmedia_model->update( array(
|
|
|
|
|
|
|
260 |
|
261 |
return $return;
|
262 |
}
|
263 |
|
264 |
-
function return_migration( $media = false, $migrate = true ){
|
265 |
$total = $this->get_total_count();
|
266 |
$pending = $this->get_pending_count( $media->id );
|
267 |
$done = $total - $pending;
|
268 |
-
if ( $pending < 0 ){
|
269 |
$pending = 0;
|
270 |
$done = $total;
|
271 |
}
|
272 |
-
if ( $done > $total ){
|
273 |
$done = $total;
|
274 |
}
|
275 |
rtmedia_update_site_option( 'rtmedia_media_size_import_pending_count', $pending );
|
276 |
$pending_time = rtmedia_migrate_formatseconds( $pending ) . ' (estimated)';
|
277 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
die();
|
279 |
}
|
280 |
}
|
13 |
*/
|
14 |
class RTMediaMediaSizeImporter {
|
15 |
|
16 |
+
function __construct() {
|
17 |
add_filter( 'rtmedia_filter_admin_pages_array', array( $this, 'rtmedia_add_admin_page_array' ), 11, 1 );
|
18 |
add_action( 'wp_ajax_rtmedia_media_size_import', array( $this, 'rtmedia_media_size_import' ) );
|
19 |
add_action( 'admin_init', array( $this, 'add_admin_notice' ) );
|
20 |
add_action( 'admin_menu', array( $this, 'menu' ), 10 );
|
21 |
+
add_action( 'wp_ajax_rtmedia_hide_media_size_import_notice', array(
|
22 |
+
$this,
|
23 |
+
'rtmedia_hide_media_size_import_notice',
|
24 |
+
) );
|
25 |
}
|
26 |
|
27 |
+
function menu() {
|
28 |
+
add_submenu_page( 'rtmedia-setting', esc_html__( 'Media Size Import', 'buddypress-media' ), esc_html__( 'Media Size Import', 'buddypress-media' ), 'manage_options', 'rtmedia-migration-media-size-import', array(
|
29 |
+
$this,
|
30 |
+
'init',
|
31 |
+
) );
|
32 |
}
|
33 |
|
34 |
+
function rtmedia_add_admin_page_array( $admin_pages ) {
|
35 |
$admin_pages[] = 'rtmedia_page_rtmedia-media-size-import';
|
36 |
|
37 |
return $admin_pages;
|
38 |
}
|
39 |
|
40 |
+
function rtmedia_hide_media_size_import_notice() {
|
41 |
+
if ( rtmedia_update_site_option( 'rtmedia_hide_media_size_import_notice', true ) ) {
|
42 |
echo '1';
|
43 |
} else {
|
44 |
echo '0';
|
46 |
wp_die();
|
47 |
}
|
48 |
|
49 |
+
function add_admin_notice() {
|
50 |
$pending = $this->get_pending_count();
|
51 |
+
if ( $pending < 0 ) {
|
52 |
$pending = 0;
|
53 |
}
|
54 |
rtmedia_update_site_option( 'rtmedia_media_size_import_pending_count', $pending );
|
55 |
$hide_admin_option = rtmedia_get_site_option( 'rtmedia_hide_media_size_import_notice' );
|
56 |
+
if ( $hide_admin_option ) {
|
57 |
return;
|
58 |
}
|
59 |
+
if ( $pending > 0 ) {
|
60 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
61 |
+
if ( ! ( isset( $page ) && 'rtmedia-migration-media-size-import' === $page ) ) {
|
62 |
$site_option = get_site_option( 'rtmedia_media_size_import_notice' );
|
63 |
+
if ( ! $site_option || 'hide' !== $site_option ) {
|
64 |
rtmedia_update_site_option( 'rtmedia_media_size_import_notice', 'show' );
|
65 |
add_action( 'admin_notices', array( &$this, 'add_rtmedia_media_size_import_notice' ) );
|
66 |
}
|
68 |
}
|
69 |
}
|
70 |
|
71 |
+
function add_rtmedia_media_size_import_notice() {
|
72 |
+
if ( current_user_can( 'manage_options' ) ) {
|
73 |
+
$this->create_notice( '<p><strong>rtMedia</strong>' . esc_html__( ': Database table structure for rtMedia has been updated. Please ', 'buddypress-media' ) . "<a href='" . esc_url( admin_url( 'admin.php?page=rtmedia-migration-media-size-import&force=true' ) ) . "'>" . esc_html__( 'Click Here', 'buddypress-media' ) . '</a>' . esc_html__( 'to import media sizes. ', 'buddypress-media' ) . "<a href='#' onclick='rtmedia_hide_media_size_import_notice()' style='float:right'>" . esc_html__( 'Hide', 'buddypress-media' ) . '</a> </p>' );
|
74 |
?>
|
75 |
<script type="text/javascript">
|
76 |
function rtmedia_hide_media_size_import_notice() {
|
77 |
var data = {action: 'rtmedia_hide_media_size_import_notice'};
|
78 |
+
jQuery.post(ajaxurl, data, function (response) {
|
79 |
response = response.trim();
|
80 |
+
if (response === '1')
|
81 |
+
jQuery('.rtmedia-media-size-import-error').remove();
|
82 |
+
});
|
83 |
}
|
84 |
</script>
|
85 |
+
<?php
|
86 |
}
|
87 |
}
|
88 |
|
89 |
+
function create_notice( $message, $type = 'error' ) {
|
90 |
+
echo '<div class="' . esc_attr( $type ) . ' rtmedia-media-size-import-error">'
|
91 |
+
. wp_kses( $message, array(
|
92 |
+
'p' => array(),
|
93 |
+
'strong' => array()
|
94 |
+
) )
|
95 |
+
. '</div>'; // @codingStandardsIgnoreLine
|
96 |
}
|
97 |
|
98 |
+
function init() {
|
99 |
$prog = new rtProgress();
|
100 |
$pending = $this->get_pending_count();
|
101 |
$total = $this->get_total_count();
|
102 |
$done = $total - $pending;
|
103 |
?>
|
104 |
<div class="wrap">
|
105 |
+
<h2><?php esc_html_e( 'rtMedia: Import Media Size', 'buddypress-media' ) ?></h2>
|
106 |
<?php
|
107 |
wp_nonce_field( 'rtmedia_media_size_import_nonce', 'rtmedia_media_size_import_nonce' );
|
108 |
+
echo '<span class="pending">' . sprintf( esc_html__( '%s (estimated)', 'buddypress-media' ), esc_html( rtmedia_migrate_formatseconds( $total - $done ) ) ) . '</span><br />';
|
109 |
+
echo '<span class="finished">' . esc_html( $done ) . '</span>/<span class="total">' . esc_html( $total ) . '</span>';
|
110 |
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
111 |
|
112 |
$temp = $prog->progress( $done, $total );
|
115 |
<script type="text/javascript">
|
116 |
var fail_id = new Array();
|
117 |
var ajax_data;
|
118 |
+
jQuery(document).ready(function (e) {
|
119 |
+
jQuery("#toplevel_page_rtmedia-settings").addClass("wp-has-current-submenu")
|
120 |
+
jQuery("#toplevel_page_rtmedia-settings").removeClass("wp-not-current-submenu")
|
121 |
+
jQuery("#toplevel_page_rtmedia-settings").addClass("wp-menu-open")
|
122 |
+
jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-menu-open")
|
123 |
+
jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-has-current-submenu")
|
124 |
+
if (db_total < 1)
|
125 |
+
jQuery("#submit").attr('disabled', "disabled");
|
126 |
+
});
|
127 |
+
function db_start_migration(db_done, db_total, last_id) {
|
128 |
|
129 |
+
if (db_done < db_total) {
|
130 |
+
jQuery("#rtMediaSyncing").show();
|
131 |
ajax_data = {
|
132 |
"action": "rtmedia_media_size_import",
|
133 |
"done": db_done,
|
134 |
"last_id": last_id,
|
135 |
+
"nonce": jQuery.trim(jQuery('#rtmedia_media_size_import_nonce').val())
|
136 |
+
};
|
137 |
+
jQuery.ajax({
|
138 |
url: rtmedia_admin_ajax,
|
139 |
type: 'post',
|
140 |
data: ajax_data,
|
141 |
+
success: function (sdata) {
|
142 |
|
143 |
try {
|
144 |
+
data = JSON.parse(sdata);
|
145 |
+
} catch (e) {
|
146 |
+
jQuery("#submit").attr('disabled', "");
|
147 |
}
|
148 |
+
if (data.status) {
|
149 |
+
done = parseInt(data.done);
|
150 |
+
total = parseInt(data.total);
|
151 |
+
var progw = Math.ceil((done / total) * 100);
|
152 |
+
if (progw > 100) {
|
153 |
progw = 100;
|
154 |
}
|
155 |
+
jQuery('#rtprogressbar>div').css('width', progw + '%');
|
156 |
+
jQuery('span.finished').html(done);
|
157 |
+
jQuery('span.total').html(total);
|
158 |
+
jQuery('span.pending').html(data.pending);
|
159 |
+
if (data.imported === false) {
|
160 |
+
fail_id.push(data.media_id);
|
|
|
161 |
}
|
162 |
+
db_start_migration(done, total, parseInt(data.media_id));
|
163 |
} else {
|
164 |
+
alert("Migration completed.");
|
165 |
+
jQuery("#rtMediaSyncing").hide();
|
166 |
}
|
167 |
},
|
168 |
error: function () {
|
169 |
+
alert("Error During Migration, Please Refresh Page then try again");
|
170 |
+
jQuery("#submit").removeAttr('disabled');
|
171 |
}
|
172 |
+
});
|
173 |
} else {
|
174 |
+
alert("Migration completed.");
|
175 |
+
if (fail_id.length > 0) {
|
176 |
rtm_show_file_error();
|
177 |
}
|
178 |
+
jQuery("#rtMediaSyncing").hide();
|
179 |
}
|
180 |
}
|
181 |
function rtm_show_file_error() {
|
182 |
+
jQuery('span.pending').text("Media with ID: " + fail_id.join(', ') + " can not be imported. Please check your server error log for more details. Don't worry, you can end importing media size now :)");
|
|
|
|
|
|
|
183 |
}
|
184 |
+
var db_done = <?php echo esc_js( $done ); ?>;
|
185 |
+
var db_total = <?php echo esc_js( $total ); ?>;
|
186 |
+
jQuery(document).on('click', '#submit', function (e) {
|
187 |
e.preventDefault();
|
188 |
+
db_start_migration(db_done, db_total, 0);
|
189 |
+
jQuery(this).attr('disabled', 'disabled');
|
190 |
+
});
|
191 |
</script>
|
192 |
<hr/>
|
193 |
+
<?php if ( ! ( isset( $rtmedia_error ) && true === $rtmedia_error ) ) { ?>
|
194 |
<input type="button" id="submit" value="start" class="button button-primary"/>
|
195 |
<?php } ?>
|
196 |
</div>
|
197 |
+
<?php
|
198 |
}
|
199 |
|
200 |
+
function get_pending_count( $media_id = false ) {
|
201 |
global $wpdb;
|
202 |
$rtmedia_model = new RTMediaModel();
|
203 |
$query_pending = "SELECT COUNT(*) as pending from {$rtmedia_model->table_name} where file_size IS NULL AND media_type in ('photo','video','document','music','other')";
|
204 |
+
if ( $media_id ) {
|
205 |
+
$media_id = intval( $media_id );
|
206 |
+
$query_pending = $wpdb->prepare( "SELECT COUNT(*) as pending from {$rtmedia_model->table_name} where file_size IS NULL AND media_type in ('photo','video','document','music','other') AND id > %d", $media_id ); // @codingStandardsIgnoreLine
|
207 |
}
|
208 |
+
$pending_count = $wpdb->get_results( $query_pending ); // @codingStandardsIgnoreLine
|
209 |
+
if ( $pending_count && count( $pending_count ) > 0 ) {
|
210 |
return $pending_count[0]->pending;
|
211 |
}
|
212 |
|
213 |
return 0;
|
214 |
}
|
215 |
|
216 |
+
function get_total_count() {
|
217 |
global $wpdb;
|
218 |
$rtmedia_model = new RTMediaModel();
|
219 |
+
$query_total = "SELECT COUNT(*) as total from {$rtmedia_model->table_name} where media_type in ('photo','video','document','music','other') "; // @codingStandardsIgnoreLine
|
220 |
+
$total_count = $wpdb->get_results( $query_total ); // @codingStandardsIgnoreLine
|
221 |
+
if ( $total_count && count( $total_count ) > 0 ) {
|
222 |
return $total_count[0]->total;
|
223 |
}
|
224 |
|
225 |
return 0;
|
226 |
}
|
227 |
|
228 |
+
function rtmedia_media_size_import( $lastid = 0, $limit = 1 ) {
|
229 |
global $wpdb;
|
230 |
+
if ( check_ajax_referer( 'rtmedia_media_size_import_nonce', 'nonce' ) ) {
|
231 |
$rtmedia_model = new RTMediaModel();
|
232 |
+
$get_media_sql = $wpdb->prepare( "SELECT * from {$rtmedia_model->table_name} where file_size is NULL and media_type in ('photo','video','document','music','other') order by id limit %d", $limit ); // @codingStandardsIgnoreLine
|
233 |
+
$lastid = filter_input( INPUT_POST, 'last_id', FILTER_SANITIZE_NUMBER_INT );
|
234 |
+
if ( ! empty( $lastid ) ) {
|
235 |
+
$get_media_sql = $wpdb->prepare( "SELECT * from {$rtmedia_model->table_name} where id > %d AND file_size is NULL and media_type in ('photo','video','document','music','other') order by id limit %d", $lastid, $limit ); // @codingStandardsIgnoreLine
|
|
|
|
|
236 |
}
|
237 |
+
$result = $wpdb->get_results( $get_media_sql ); // @codingStandardsIgnoreLine
|
238 |
+
if ( $result && count( $result ) > 0 ) {
|
239 |
$migrate = $this->migrate_single_media( $result[0] );
|
240 |
}
|
241 |
$this->return_migration( $result[0], $migrate );
|
246 |
|
247 |
}
|
248 |
|
249 |
+
function migrate_single_media( $result ) {
|
250 |
global $wpdb;
|
251 |
$rtmedia_model = new RTMediaModel();
|
252 |
$attached_file = get_attached_file( $result->media_id );
|
253 |
$return = true;
|
254 |
+
if ( file_exists( $attached_file ) ) {
|
255 |
$file_size = filesize( $attached_file );
|
256 |
} else {
|
257 |
+
error_log( 'rtMedia size importer: file not exist. Media ID: ' . esc_html( $result->id ) . ', File: ' . esc_html( $attached_file ) );
|
|
|
|
|
|
|
258 |
return false;
|
259 |
}
|
260 |
$post = get_post( $result->media_id );
|
261 |
$post_date = $post->post_date;
|
262 |
+
$rtmedia_model->update( array(
|
263 |
+
'upload_date' => $post_date,
|
264 |
+
'file_size' => $file_size,
|
265 |
+
), array( 'id' => $result->id ) );
|
266 |
|
267 |
return $return;
|
268 |
}
|
269 |
|
270 |
+
function return_migration( $media = false, $migrate = true ) {
|
271 |
$total = $this->get_total_count();
|
272 |
$pending = $this->get_pending_count( $media->id );
|
273 |
$done = $total - $pending;
|
274 |
+
if ( $pending < 0 ) {
|
275 |
$pending = 0;
|
276 |
$done = $total;
|
277 |
}
|
278 |
+
if ( $done > $total ) {
|
279 |
$done = $total;
|
280 |
}
|
281 |
rtmedia_update_site_option( 'rtmedia_media_size_import_pending_count', $pending );
|
282 |
$pending_time = rtmedia_migrate_formatseconds( $pending ) . ' (estimated)';
|
283 |
+
echo wp_json_encode( array(
|
284 |
+
'status' => true,
|
285 |
+
'done' => $done,
|
286 |
+
'total' => $total,
|
287 |
+
'pending' => $pending_time,
|
288 |
+
'media_id' => $media->id,
|
289 |
+
'imported' => $migrate,
|
290 |
+
) );
|
291 |
die();
|
292 |
}
|
293 |
}
|
app/importers/RTMediaMigration.php
CHANGED
@@ -9,99 +9,105 @@ class RTMediaMigration {
|
|
9 |
|
10 |
public $bmp_table = '';
|
11 |
|
12 |
-
function __construct(){
|
13 |
global $wpdb;
|
14 |
$this->bmp_table = $wpdb->base_prefix . 'rt_rtm_media';
|
15 |
|
16 |
add_action( 'admin_menu', array( $this, 'menu' ) );
|
17 |
add_action( 'wp_ajax_bp_media_rt_db_migration', array( $this, 'migrate_to_new_db' ) );
|
18 |
|
19 |
-
|
|
|
|
|
20 |
$this->hide_migration_notice();
|
21 |
-
|
|
|
22 |
}
|
23 |
-
if ( false !== rtmedia_get_site_option( 'rt_migration_hide_notice' ) ){
|
24 |
return true;
|
25 |
}
|
26 |
|
27 |
-
|
|
|
28 |
$pending = false;
|
29 |
} else {
|
30 |
$pending = rtmedia_get_site_option( 'rtMigration-pending-count' );
|
31 |
}
|
32 |
|
33 |
-
if ( false === $pending ){
|
34 |
$total = $this->get_total_count();
|
35 |
$done = $this->get_done_count();
|
36 |
$pending = $total - $done;
|
37 |
-
if ( $pending < 0 ){
|
38 |
$pending = 0;
|
39 |
}
|
40 |
rtmedia_update_site_option( 'rtMigration-pending-count', $pending );
|
41 |
}
|
42 |
-
if ( $pending > 0 ){
|
43 |
-
if ( ! ( isset( $
|
44 |
add_action( 'admin_notices', array( &$this, 'add_migration_notice' ) );
|
45 |
}
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
function hide_migration_notice(){
|
50 |
rtmedia_update_site_option( 'rt_migration_hide_notice', true );
|
51 |
}
|
52 |
|
53 |
-
function migrate_image_size_fix(){
|
54 |
-
if ( ''
|
55 |
global $wpdb;
|
56 |
$sql = $wpdb->prepare( "update $wpdb->postmeta set meta_value=replace(meta_value ,%s,%s) where meta_key = '_wp_attachment_metadata';", 'bp_media', 'rt_media' );
|
57 |
-
$wpdb->get_row( $sql );
|
58 |
update_option( 'rt_image_size_migration_fix', 'fix' );
|
59 |
}
|
60 |
}
|
61 |
|
62 |
-
function add_migration_notice(){
|
63 |
-
if ( current_user_can( 'manage_options' ) ){
|
64 |
-
$this->create_notice( '<p><strong>rtMedia</strong>: ' .
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
function create_notice( $message, $type = 'error' ){
|
69 |
-
echo '<div class="' . $type . '">' . $message . '</div>';
|
70 |
}
|
71 |
|
72 |
-
static function table_exists( $table ){
|
73 |
global $wpdb;
|
74 |
|
75 |
-
if ( 1
|
76 |
return true;
|
77 |
}
|
78 |
|
79 |
return false;
|
80 |
}
|
81 |
|
82 |
-
function menu(){
|
83 |
-
add_submenu_page( 'rtmedia-setting',
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
-
function get_total_count(){
|
87 |
global $wpdb;
|
88 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
89 |
$bp_prefix = bp_core_get_table_prefix();
|
90 |
} else {
|
91 |
$bp_prefix = '';
|
92 |
}
|
93 |
$sql_album_usercount = "select count(*) FROM $wpdb->usermeta where meta_key ='bp-media-default-album' ";
|
94 |
|
95 |
-
$_SESSION['migration_user_album'] = $wpdb->get_var( $sql_album_usercount );
|
96 |
-
$count
|
97 |
|
98 |
-
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ){
|
99 |
-
$sql_album_groupcount
|
100 |
-
$_SESSION['migration_group_album'] = $wpdb->get_var( $sql_album_groupcount );
|
101 |
$count += intval( $_SESSION['migration_group_album'] );
|
102 |
}
|
103 |
-
if ( $this->table_exists( $bp_prefix . 'bp_activity' ) ){
|
104 |
-
//$sql_bpm_comment_count = "select count(*) from {$bp_prefix}bp_activity where component='activity' and type='activity_comment' and is_spam <> 1 and ;";
|
105 |
$sql_bpm_comment_count = "SELECT
|
106 |
count(id)
|
107 |
FROM
|
@@ -120,9 +126,7 @@ class RTMediaMigration {
|
|
120 |
and is_spam <>1 and
|
121 |
not p.meta_value is NULL";
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
$_SESSION['migration_activity'] = $wpdb->get_var( $sql_bpm_comment_count );
|
126 |
$count += intval( $_SESSION['migration_activity'] );
|
127 |
}
|
128 |
|
@@ -141,14 +145,13 @@ class RTMediaMigration {
|
|
141 |
a.post_id > 0 and (NOT p.ID IS NULL)
|
142 |
and a.meta_key = 'bp-media-key'";
|
143 |
|
144 |
-
$_SESSION['migration_media'] = $wpdb->get_var( $sql );
|
145 |
$count += intval( $_SESSION['migration_media'] );
|
146 |
|
147 |
-
// var_dump($_SESSION);
|
148 |
return $count;
|
149 |
}
|
150 |
|
151 |
-
function get_last_imported(){
|
152 |
$album = rtmedia_get_site_option( 'rtmedia-global-albums' );
|
153 |
$album_id = $album[0];
|
154 |
|
@@ -160,16 +163,16 @@ class RTMediaMigration {
|
|
160 |
where
|
161 |
a.meta_key = 'bp-media-key' and (NOT p.ID IS NULL) and a.post_id not in (select media_id
|
162 |
from {$this->bmp_table} where blog_id = %d and media_id <> %d ) order by a.post_ID";
|
163 |
-
$sql = $wpdb->prepare( $sql, get_current_blog_id(), $album_id );
|
164 |
-
$row = $wpdb->get_row( $sql );
|
165 |
-
if ( $row ){
|
166 |
return $row->post_ID;
|
167 |
} else {
|
168 |
return false;
|
169 |
}
|
170 |
}
|
171 |
|
172 |
-
function get_done_count( $flag = false ){
|
173 |
global $wpdb;
|
174 |
$sql = "select count(*)
|
175 |
from {$this->bmp_table} where blog_id = %d and media_id in (select a.post_id
|
@@ -187,27 +190,27 @@ class RTMediaMigration {
|
|
187 |
a.post_id > 0 and (NOT p.ID IS NULL)
|
188 |
and a.meta_key = 'bp-media-key')";
|
189 |
|
190 |
-
$media_count = $wpdb->get_var( $wpdb->prepare( $sql, get_current_blog_id() ) );
|
191 |
-
if ( $flag ){
|
192 |
return $media_count - 1;
|
193 |
}
|
194 |
$state = intval( rtmedia_get_site_option( 'rtmedia-migration', '0' ) );
|
195 |
-
if ( 5 == $state ){
|
196 |
$album_count = intval( $_SESSION['migration_user_album'] );
|
197 |
$album_count += ( isset( $_SESSION['migration_group_album'] ) ) ? intval( $_SESSION['migration_group_album'] ) : 0;
|
198 |
} else {
|
199 |
-
if ( $state > 0 ){
|
200 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
201 |
$bp_prefix = bp_core_get_table_prefix();
|
202 |
} else {
|
203 |
$bp_prefix = '';
|
204 |
}
|
205 |
$pending_count = "select count(*) from $wpdb->posts where post_type='bp_media_album' and ( ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
206 |
-
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ){
|
207 |
$pending_count .= " or ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
208 |
}
|
209 |
$pending_count .= ')';
|
210 |
-
$pending_count = $wpdb->get_var( $pending_count );
|
211 |
|
212 |
$album_count = intval( $_SESSION['migration_user_album'] );
|
213 |
$album_count += ( isset( $_SESSION['migration_group_album'] ) ) ? intval( $_SESSION['migration_group_album'] ) : 0;
|
@@ -216,43 +219,44 @@ class RTMediaMigration {
|
|
216 |
$album_count = 0;
|
217 |
}
|
218 |
}
|
219 |
-
if ( isset( $_SESSION['migration_activity'] ) && intval( $_SESSION['migration_media'] ) == intval( $media_count ) ){
|
220 |
$comment_sql = $_SESSION['migration_activity'];
|
221 |
} else {
|
|
|
222 |
$comment_sql = $wpdb->get_var( "select count(*)
|
223 |
from $wpdb->comments a
|
224 |
where a.comment_post_ID in (select b.media_id from $this->bmp_table b left join
|
225 |
{$wpdb->posts} p ON (b.media_id = p.ID) where (NOT p.ID IS NULL) ) and a.comment_agent=''" );
|
|
|
226 |
}
|
227 |
|
228 |
-
//echo $media_count . "--" . $album_count . "--" . $comment_sql;
|
229 |
return $media_count + $album_count + $comment_sql;
|
230 |
}
|
231 |
|
232 |
-
function return_migration(){
|
233 |
$total = $this->get_total_count();
|
234 |
$done = $this->get_done_count();
|
235 |
$pending = $total - $done;
|
236 |
-
if ( $pending < 0 ){
|
237 |
$pending = 0;
|
238 |
$done = $total;
|
239 |
}
|
240 |
-
if ( $done > $total ){
|
241 |
$done = $total;
|
242 |
}
|
243 |
-
if ( $done
|
244 |
global $wp_rewrite;
|
245 |
//Call flush_rules() as a method of the $wp_rewrite object
|
246 |
$wp_rewrite->flush_rules( true );
|
247 |
}
|
248 |
rtmedia_update_site_option( 'rtMigration-pending-count', $pending );
|
249 |
-
$pending_time = $this->
|
250 |
|
251 |
-
echo
|
252 |
die();
|
253 |
}
|
254 |
|
255 |
-
function manage_album(){
|
256 |
$album = rtmedia_get_site_option( 'rtmedia-global-albums' );
|
257 |
$stage = intval( rtmedia_get_site_option( 'rtmedia-migration', '0' ) );
|
258 |
|
@@ -262,38 +266,38 @@ class RTMediaMigration {
|
|
262 |
|
263 |
global $wpdb;
|
264 |
|
265 |
-
$album_id = $wpdb->get_var( $wpdb->prepare( "select media_id from $this->bmp_table where id = %d", $album_rt_id ) );
|
266 |
|
267 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
268 |
$bp_prefix = bp_core_get_table_prefix();
|
269 |
} else {
|
270 |
$bp_prefix = '';
|
271 |
}
|
272 |
|
273 |
-
if ( $stage < 1 ){
|
274 |
global $wpdb;
|
275 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
276 |
$bp_prefix = bp_core_get_table_prefix();
|
277 |
} else {
|
278 |
$bp_prefix = '';
|
279 |
}
|
280 |
-
$sql = $wpdb->prepare( "update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;", '<ul class="bp-media-list-media">', '<div class="rtmedia-activity-container"><ul class="rtmedia-list large-block-grid-3">' );
|
281 |
$wpdb->get_row( $sql );
|
282 |
-
$sql = $wpdb->prepare( "update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;", '</ul>', '</ul></div>' );
|
283 |
$wpdb->get_row( $sql );
|
284 |
|
285 |
$sql_group = "update $wpdb->posts set post_parent='{$album_id}' where post_parent in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
286 |
-
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ){
|
287 |
$sql_group .= " or post_parent in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
288 |
}
|
289 |
-
$wpdb->query( $sql_group );
|
290 |
$stage = 1;
|
291 |
rtmedia_update_site_option( 'rtmedia-migration', $stage );
|
292 |
$this->return_migration();
|
293 |
}
|
294 |
-
if ( $stage < 2 ){
|
295 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') limit 10";
|
296 |
-
$results = $wpdb->get_results( $sql_delete );
|
297 |
$delete_ids = '';
|
298 |
$sep = '';
|
299 |
foreach ( $results as $result ) {
|
@@ -301,32 +305,34 @@ class RTMediaMigration {
|
|
301 |
$delete_ids .= $sep . $result->ID;
|
302 |
$sep = ',';
|
303 |
}
|
304 |
-
if ( ''
|
305 |
-
|
|
|
306 |
}
|
307 |
-
if ( count( $results ) < 10 ){
|
308 |
$stage = 2;
|
309 |
}
|
310 |
rtmedia_update_site_option( 'rtmedia-migration', $stage );
|
311 |
$this->return_migration();
|
312 |
}
|
313 |
-
if ( $stage < 3 ){
|
314 |
-
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ){
|
315 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album') limit 10";
|
316 |
-
$results = $wpdb->get_results( $sql_delete );
|
317 |
$delete_ids = '';
|
318 |
$sep = '';
|
319 |
-
if ( $results ){
|
320 |
foreach ( $results as $result ) {
|
321 |
$group_id = abs( intval( get_post_meta( $result->ID, 'bp-media-key', true ) ) );
|
322 |
$this->search_and_replace( trailingslashit( get_rtmedia_group_link( $group_id ) ) . 'albums/' . $result->ID, trailingslashit( get_rtmedia_group_link( $group_id ) ) . RTMEDIA_MEDIA_SLUG . '/' . $album_rt_id );
|
323 |
$delete_ids .= $sep . $result->ID;
|
324 |
$sep = ',';
|
325 |
}
|
326 |
-
if ( ''
|
327 |
-
|
|
|
328 |
}
|
329 |
-
if ( count( $results ) < 10 ){
|
330 |
$stage = 3;
|
331 |
}
|
332 |
} else {
|
@@ -342,7 +348,7 @@ class RTMediaMigration {
|
|
342 |
}
|
343 |
|
344 |
$sql = "update $wpdb->posts set post_type='{$album_post_type}' where post_type='bp_media_album'";
|
345 |
-
if ( false !== $wpdb->query( $sql ) ){
|
346 |
rtmedia_update_site_option( 'rtmedia-migration', '5' );
|
347 |
|
348 |
return true;
|
@@ -351,152 +357,161 @@ class RTMediaMigration {
|
|
351 |
return false;
|
352 |
}
|
353 |
|
354 |
-
function test(){
|
355 |
-
if ( ! $this->table_exists( $this->bmp_table ) ){
|
356 |
$obj = new RTDBUpdate( false, RTMEDIA_PATH . 'index.php', RTMEDIA_PATH . 'app/schema/', true );
|
357 |
$obj->install_db_version = '0';
|
358 |
$obj->do_upgrade( true );
|
359 |
}
|
360 |
global $rtmedia_error;
|
361 |
-
if ( isset( $rtmedia_error ) && true === $rtmedia_error ){
|
362 |
?>
|
363 |
<div class="error"><p> Please Resolve create database error before migration.</p></div>
|
364 |
-
|
365 |
}
|
366 |
|
367 |
$prog = new rtProgress();
|
368 |
$total = $this->get_total_count();
|
369 |
$done = $this->get_done_count();
|
370 |
-
if ( $done >= $total ){
|
371 |
$done = $total;
|
372 |
} else {
|
373 |
?>
|
374 |
<div class="error">
|
375 |
-
<p
|
|
|
|
|
|
|
|
|
|
|
376 |
</div>
|
377 |
-
|
378 |
}
|
379 |
?>
|
380 |
|
381 |
<div class="wrap">
|
382 |
|
383 |
-
<h2><?php
|
384 |
-
|
385 |
-
<h3><?php
|
386 |
-
User Albums :
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
<?php
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
393 |
<?php } ?>
|
394 |
<hr/>
|
395 |
|
396 |
<?php
|
397 |
-
echo '<span class="pending">' . $this->
|
398 |
-
echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
|
399 |
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
400 |
|
401 |
$temp = $prog->progress( $done, $total );
|
402 |
$prog->progress_ui( $temp, true );
|
403 |
?>
|
404 |
<script type="text/javascript">
|
405 |
-
jQuery(
|
406 |
-
jQuery(
|
407 |
-
jQuery(
|
408 |
-
jQuery(
|
409 |
-
jQuery(
|
410 |
-
jQuery(
|
411 |
-
|
412 |
-
if (
|
413 |
-
jQuery(
|
414 |
-
}
|
415 |
-
function db_start_migration(
|
416 |
-
|
417 |
-
|
418 |
-
if (
|
419 |
-
jQuery(
|
420 |
-
jQuery.ajax(
|
421 |
url: rtmedia_admin_ajax,
|
422 |
type: 'post',
|
423 |
data: {
|
424 |
"action": "bp_media_rt_db_migration",
|
425 |
"done": db_done
|
426 |
},
|
427 |
-
success: function (
|
428 |
|
429 |
try {
|
430 |
-
data = JSON.parse(
|
431 |
-
} catch (
|
432 |
-
jQuery(
|
433 |
}
|
434 |
-
if (
|
435 |
-
done = parseInt(
|
436 |
-
total = parseInt(
|
437 |
-
var progw = Math.ceil(
|
438 |
-
if (
|
439 |
progw = 100;
|
440 |
}
|
441 |
-
;
|
442 |
-
jQuery(
|
443 |
-
jQuery(
|
444 |
-
jQuery(
|
445 |
-
|
446 |
-
db_start_migration( done, total );
|
447 |
} else {
|
448 |
-
alert(
|
449 |
-
jQuery(
|
450 |
}
|
451 |
},
|
452 |
error: function () {
|
453 |
-
alert(
|
454 |
-
jQuery(
|
455 |
}
|
456 |
-
}
|
457 |
} else {
|
458 |
-
alert(
|
459 |
-
jQuery(
|
460 |
}
|
461 |
}
|
462 |
-
var db_done = <?php echo $done; ?>;
|
463 |
-
var db_total = <?php echo $total; ?>;
|
464 |
-
jQuery(
|
465 |
e.preventDefault();
|
466 |
|
467 |
-
db_start_migration(
|
468 |
-
jQuery(
|
469 |
-
}
|
470 |
</script>
|
471 |
<hr/>
|
472 |
-
<?php if ( ! ( isset( $rtmedia_error ) && true === $rtmedia_error ) ){ ?>
|
473 |
<input type="button" id="submit" value="<?php esc_attr_e( 'Start', 'buddypress-media' ); ?>"
|
474 |
-
|
475 |
<?php } ?>
|
476 |
|
477 |
</div>
|
478 |
-
|
479 |
}
|
480 |
|
481 |
-
function migrate_to_new_db( $lastid = 0, $limit = 1 ){
|
482 |
|
483 |
-
if ( ! isset( $_SESSION['migration_media'] ) ){
|
484 |
$this->get_total_count();
|
485 |
}
|
486 |
|
487 |
$state = intval( rtmedia_get_site_option( 'rtmedia-migration' ) );
|
488 |
-
if ( $state < 5 ){
|
489 |
-
if ( $this->manage_album() ){
|
490 |
$this->migrate_encoding_options();
|
491 |
$this->return_migration();
|
492 |
}
|
493 |
}
|
494 |
|
495 |
-
if ( intval( $_SESSION['migration_media'] ) >= $this->get_done_count( true ) ){
|
496 |
|
497 |
-
if ( ! $lastid ){
|
498 |
$lastid = $this->get_last_imported();
|
499 |
-
if ( ! $lastid ){
|
500 |
$this->return_migration();
|
501 |
}
|
502 |
}
|
@@ -527,14 +542,14 @@ class RTMediaMigration {
|
|
527 |
order by a.post_id
|
528 |
limit %d";
|
529 |
|
530 |
-
$results = $wpdb->get_results( $wpdb->prepare( $sql, $lastid, $limit ) );
|
531 |
|
532 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
533 |
$bp_prefix = bp_core_get_table_prefix();
|
534 |
} else {
|
535 |
$bp_prefix = '';
|
536 |
}
|
537 |
-
if ( $results ){
|
538 |
|
539 |
foreach ( $results as $result ) {
|
540 |
$this->migrate_single_media( $result );
|
@@ -544,36 +559,40 @@ class RTMediaMigration {
|
|
544 |
global $wp_rewrite;
|
545 |
//Call flush_rules() as a method of the $wp_rewrite object
|
546 |
$wp_rewrite->flush_rules( true );
|
547 |
-
// echo json_encode(array("status" => false, "done" => $done, "total" => $this->get_total_count()));
|
548 |
-
// die();
|
549 |
}
|
550 |
$this->return_migration();
|
551 |
}
|
552 |
|
553 |
-
function migrate_encoding_options(){
|
554 |
$encoding_mnigration_array = array(
|
555 |
-
'bp-media-encoding-api-key'
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
);
|
557 |
foreach ( $encoding_mnigration_array as $key => $ma ) {
|
558 |
-
if ( false !== ( $value = rtmedia_get_site_option( $key ) ) ){
|
559 |
rtmedia_update_site_option( $ma, $value );
|
560 |
}
|
561 |
}
|
562 |
}
|
563 |
|
564 |
-
function migrate_single_media( $result, $album = false ){
|
565 |
$blog_id = get_current_blog_id();
|
566 |
$old = $result;
|
567 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
568 |
$bp_prefix = bp_core_get_table_prefix();
|
569 |
} else {
|
570 |
$bp_prefix = '';
|
571 |
}
|
572 |
global $wpdb;
|
573 |
|
574 |
-
if ( false !== $album && ! ( is_object( $result ) ) ){
|
575 |
-
$id = $wpdb->get_var( $wpdb->prepare( "select ID from $this->bmp_table where media_id = %d", $result ) );
|
576 |
-
if ( null == $id ){
|
577 |
$sql = "select
|
578 |
a.post_id as 'post_id',
|
579 |
a.meta_value as 'privacy',
|
@@ -597,17 +616,17 @@ class RTMediaMigration {
|
|
597 |
where
|
598 |
a.post_id = %d and (NOT p.ID IS NULL)
|
599 |
and a.meta_key = 'bp_media_privacy'";
|
600 |
-
$result = $wpdb->get_row( $wpdb->prepare( $sql, $result ) );
|
601 |
} else {
|
602 |
return $id;
|
603 |
}
|
604 |
}
|
605 |
-
if ( ! isset( $result ) || ! isset( $result->post_id ) ){
|
606 |
return $old;
|
607 |
}
|
608 |
$media_id = $result->post_id;
|
609 |
|
610 |
-
if ( intval( $result->context_id ) > 0 ){
|
611 |
$media_context = 'profile';
|
612 |
$prefix = 'users/' . abs( intval( $result->context_id ) );
|
613 |
} else {
|
@@ -616,20 +635,20 @@ class RTMediaMigration {
|
|
616 |
}
|
617 |
|
618 |
$old_type = '';
|
619 |
-
if ( 'attachment' != $result->post_type ){
|
620 |
$media_type = 'album';
|
621 |
} else {
|
622 |
$mime_type = strtolower( $result->post_mime_type );
|
623 |
$old_type = '';
|
624 |
-
if ( 0 === strpos( $mime_type, 'image' ) ){
|
625 |
$media_type = 'photo';
|
626 |
$old_type = 'photos';
|
627 |
} else {
|
628 |
-
if ( 0 === strpos( $mime_type, 'audio' ) ){
|
629 |
$media_type = 'music';
|
630 |
$old_type = 'music';
|
631 |
} else {
|
632 |
-
if ( 0 === strpos( $mime_type, 'video' ) ){
|
633 |
$media_type = 'video';
|
634 |
$old_type = 'videos';
|
635 |
} else {
|
@@ -639,13 +658,14 @@ class RTMediaMigration {
|
|
639 |
}
|
640 |
}
|
641 |
|
642 |
-
$activity_data = $wpdb->get_row( $wpdb->prepare( "select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id ) );
|
643 |
-
if ( 'album' != $media_type ){
|
644 |
$this->importmedia( $media_id, $prefix );
|
645 |
}
|
646 |
|
647 |
-
if ( $this->table_exists( $bp_prefix . 'bp_activity' ) && class_exists( 'BP_Activity_Activity' ) ){
|
648 |
$bp_activity = new BP_Activity_Activity();
|
|
|
649 |
$activity_sql = $wpdb->prepare( "SELECT
|
650 |
*
|
651 |
FROM
|
@@ -661,55 +681,47 @@ class RTMediaMigration {
|
|
661 |
(NOT p.ID IS NULL) and p.ID = %d
|
662 |
and a.meta_key = 'bp_media_child_activity')", $media_id );
|
663 |
$all_activity = $wpdb->get_results( $activity_sql );
|
|
|
664 |
remove_all_actions( 'wp_insert_comment' );
|
665 |
foreach ( $all_activity as $activity ) {
|
666 |
$comments = $bp_activity->get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right );
|
667 |
$exclude = get_post_meta( $media_id, 'rtmedia_imported_activity', true );
|
668 |
-
if ( ! is_array( $exclude ) ){
|
669 |
$exclude = array();
|
670 |
}
|
671 |
-
if ( $comments ){
|
672 |
$this->insert_comment( $media_id, $comments, $exclude );
|
673 |
}
|
674 |
}
|
675 |
}
|
676 |
-
if ( 0 !== intval( $result->parent ) ){
|
677 |
$album_id = $this->migrate_single_media( $result->parent, true );
|
678 |
} else {
|
679 |
$album_id = 0;
|
680 |
}
|
681 |
-
if ( function_exists( 'bp_activity_get_meta' ) ){
|
682 |
$likes = bp_activity_get_meta( $result->activity_id, 'favorite_count' );
|
683 |
} else {
|
684 |
$likes = 0;
|
685 |
}
|
686 |
|
687 |
$wpdb->insert( $this->bmp_table, array(
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
$last_id = $wpdb->insert_id;
|
701 |
|
702 |
-
|
703 |
-
|
704 |
-
// if($photo_tag_meta && !empty($photo_tag_meta)){
|
705 |
-
// $wpdb->insert(
|
706 |
-
// $wpdb->prefix . "rt_rtm_media_meta", array(
|
707 |
-
// 'media_id' => $media_id,
|
708 |
-
// 'meta_key' => "user-tags",
|
709 |
-
// "meta_value" => maybe_serialize($photo_tag_meta)), array('%d', '%s', '%s'));
|
710 |
-
// }
|
711 |
-
if ( 'album' != $media_type && function_exists( 'bp_core_get_user_domain' ) && $activity_data ){
|
712 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
713 |
$bp_prefix = bp_core_get_table_prefix();
|
714 |
} else {
|
715 |
$bp_prefix = '';
|
@@ -723,16 +735,18 @@ class RTMediaMigration {
|
|
723 |
$activity_data->content = str_replace( $activity_data->old_primary_link, $activity_data->primary_link, $activity_data->content );
|
724 |
global $last_baseurl, $last_newurl;
|
725 |
|
726 |
-
$replace_img = $last_newurl;
|
727 |
-
if ( false === strpos( $activity_data->content, $replace_img ) ){
|
728 |
$activity_data->content = str_replace( $last_baseurl, $replace_img, $activity_data->content );
|
729 |
}
|
730 |
global $wpdb;
|
731 |
$wpdb->update( $bp_prefix . 'bp_activity', array(
|
732 |
-
'primary_link' => $activity_data->primary_link,
|
|
|
|
|
733 |
), array( 'id' => $activity_data->id ) );
|
734 |
} else {
|
735 |
-
if ( 'group' == $media_context ){
|
736 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
737 |
$parent_link = get_rtmedia_group_link( abs( intval( $result->context_id ) ) );
|
738 |
$parent_link = trailingslashit( $parent_link );
|
@@ -746,8 +760,8 @@ class RTMediaMigration {
|
|
746 |
$this->search_and_replace( $activity_data->old_primary_link, $activity_data->primary_link );
|
747 |
}
|
748 |
}
|
749 |
-
if ( '' != $old_type ){
|
750 |
-
if ( 'group' == $media_context ){
|
751 |
$parent_link = get_rtmedia_group_link( abs( intval( $result->context_id ) ) );
|
752 |
$parent_link = trailingslashit( $parent_link );
|
753 |
$this->search_and_replace( trailingslashit( $parent_link . $old_type . '/' . $media_id ), trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id ) );
|
@@ -761,7 +775,11 @@ class RTMediaMigration {
|
|
761 |
return $last_id;
|
762 |
}
|
763 |
|
764 |
-
|
|
|
|
|
|
|
|
|
765 |
|
766 |
$delete = false;
|
767 |
$attached_file = get_attached_file( $id );
|
@@ -772,7 +790,7 @@ class RTMediaMigration {
|
|
772 |
$siteurl = get_option( 'siteurl' );
|
773 |
$upload_path = trim( get_option( 'upload_path' ) );
|
774 |
|
775 |
-
if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ){
|
776 |
$dir = WP_CONTENT_DIR . '/uploads';
|
777 |
} elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
|
778 |
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
@@ -781,8 +799,8 @@ class RTMediaMigration {
|
|
781 |
$dir = $upload_path;
|
782 |
}
|
783 |
|
784 |
-
if ( ! $url = get_option( 'upload_url_path' ) ){
|
785 |
-
if ( empty( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ){
|
786 |
$url = WP_CONTENT_URL . '/uploads';
|
787 |
} else {
|
788 |
$url = trailingslashit( $siteurl ) . $upload_path;
|
@@ -791,22 +809,22 @@ class RTMediaMigration {
|
|
791 |
|
792 |
// Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
|
793 |
// We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
|
794 |
-
if ( defined( 'UPLOADS' ) && ! ( is_multisite() && rtmedia_get_site_option( 'ms_files_rewriting' ) ) ){
|
795 |
$dir = ABSPATH . UPLOADS;
|
796 |
$url = trailingslashit( $siteurl ) . UPLOADS;
|
797 |
}
|
798 |
|
799 |
// If multisite (and if not the main site in a post-MU network)
|
800 |
-
if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ){
|
801 |
|
802 |
-
if ( ! rtmedia_get_site_option( 'ms_files_rewriting' ) ){
|
803 |
// If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
|
804 |
// Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory
|
805 |
// prevents a four-digit ID from conflicting with a year-based directory for the main site.
|
806 |
// But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra
|
807 |
// directory, as they never had wp-content/uploads for the main site.)
|
808 |
|
809 |
-
if ( defined( 'MULTISITE' ) ){
|
810 |
$ms_dir = '/sites/' . get_current_blog_id();
|
811 |
} else {
|
812 |
$ms_dir = '/' . get_current_blog_id();
|
@@ -827,7 +845,7 @@ class RTMediaMigration {
|
|
827 |
// as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
|
828 |
// rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
|
829 |
|
830 |
-
if ( defined( 'BLOGUPLOADDIR' ) ){
|
831 |
$dir = untrailingslashit( BLOGUPLOADDIR );
|
832 |
} else {
|
833 |
$dir = ABSPATH . UPLOADS;
|
@@ -854,13 +872,13 @@ class RTMediaMigration {
|
|
854 |
$ffmpeg_remote_id = get_post_meta( $id, 'bp_media_ffmpeg_remote_id', true );
|
855 |
$kaltura_remote_id = get_post_meta( $id, 'bp_media_kaltura_remote_id', true );
|
856 |
|
857 |
-
if ( wp_mkdir_p( $basedir . "rtMedia/$prefix/" . $year_month ) ){
|
858 |
-
if ( copy( $attached_file, str_replace( $basedir, $basedir . "rtMedia/$prefix/", $attached_file ) ) ){
|
859 |
$delete = true;
|
860 |
|
861 |
-
if ( isset( $metadata['sizes'] ) ){
|
862 |
foreach ( $metadata['sizes'] as $size ) {
|
863 |
-
if ( ! copy( $file_folder_path . $size['file'], $new_file_folder_path . $size['file'] ) ){
|
864 |
$delete = false;
|
865 |
} else {
|
866 |
$delete_sizes[] = $file_folder_path . $size['file'];
|
@@ -868,9 +886,9 @@ class RTMediaMigration {
|
|
868 |
}
|
869 |
}
|
870 |
}
|
871 |
-
if ( $backup_metadata ){
|
872 |
foreach ( $backup_metadata as $backup_images ) {
|
873 |
-
if ( ! copy( $file_folder_path . $backup_images['file'], $new_file_folder_path . $backup_images['file'] ) ){
|
874 |
$delete = false;
|
875 |
} else {
|
876 |
$delete_sizes[] = $file_folder_path . $backup_images['file'];
|
@@ -879,46 +897,46 @@ class RTMediaMigration {
|
|
879 |
}
|
880 |
}
|
881 |
|
882 |
-
if ( $instagram_thumbs ){
|
883 |
foreach ( $instagram_thumbs as $key => $insta_thumb ) {
|
884 |
try {
|
885 |
-
if ( ! copy( str_replace( $baseurl, $basedir, $insta_thumb ), str_replace( $baseurl, $basedir . "rtMedia/$prefix/", $insta_thumb ) ) ){
|
886 |
$delete = false;
|
887 |
} else {
|
888 |
-
$delete_sizes[]
|
889 |
$instagram_thumbs_new[ $key ] = str_replace( $baseurl, $baseurl . "rtMedia/$prefix/", $insta_thumb );
|
890 |
$this->search_and_replace( trailingslashit( $baseurl . $year_month ) . $insta_thumb, trailingslashit( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_thumb );
|
891 |
}
|
892 |
-
} catch (
|
893 |
$delete = false;
|
894 |
}
|
895 |
}
|
896 |
}
|
897 |
|
898 |
-
if ( $instagram_full_images ){
|
899 |
foreach ( $instagram_full_images as $key => $insta_full_image ) {
|
900 |
-
if ( ! copy( $insta_full_image, str_replace( $basedir, $basedir . "rtMedia/$prefix/", $insta_full_image ) ) ){
|
901 |
$delete = false;
|
902 |
} else {
|
903 |
-
$delete_sizes[]
|
904 |
$instagram_full_images_new[ $key ] = str_replace( $basedir, $basedir . "rtMedia/$prefix", $insta_full_image );
|
905 |
$this->search_and_replace( trailingslashit( $baseurl . $year_month ) . $insta_full_image, trailingslashit( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_full_image );
|
906 |
}
|
907 |
}
|
908 |
}
|
909 |
|
910 |
-
if ( $instagram_metadata ){
|
911 |
$instagram_metadata_new = $instagram_metadata;
|
912 |
foreach ( $instagram_metadata as $wp_size => $insta_metadata ) {
|
913 |
-
if ( isset( $insta_metadata['file'] ) ){
|
914 |
-
if ( ! copy( $basedir . $insta_metadata['file'], $basedir . "rtMedia/$prefix/" . $insta_metadata['file'] ) ){
|
915 |
$delete = false;
|
916 |
} else {
|
917 |
-
$delete_sizes[]
|
918 |
$instagram_metadata_new[ $wp_size ]['file'] = "rtMedia/$prefix/" . $insta_metadata['file'];
|
919 |
-
if ( isset( $insta_metadata['sizes'] ) ){
|
920 |
foreach ( $insta_metadata['sizes'] as $key => $insta_size ) {
|
921 |
-
if ( ! copy( $file_folder_path . $insta_size['file'], $new_file_folder_path . $insta_size['file'] ) ){
|
922 |
$delete = false;
|
923 |
} else {
|
924 |
$delete_sizes[] = $file_folder_path . $insta_size['file'];
|
@@ -931,52 +949,52 @@ class RTMediaMigration {
|
|
931 |
}
|
932 |
}
|
933 |
|
934 |
-
if ( $delete ){
|
935 |
-
if ( file_exists( $attached_file ) ){
|
936 |
unlink( $attached_file );
|
937 |
}
|
938 |
|
939 |
-
if ( isset( $delete_sizes ) ){
|
940 |
foreach ( $delete_sizes as $delete_size ) {
|
941 |
-
if ( file_exists( $delete_size ) ){
|
942 |
unlink( $delete_size );
|
943 |
}
|
944 |
}
|
945 |
}
|
946 |
update_post_meta( $id, '_wp_attached_file', "rtMedia/$prefix/" . $attached_file_option );
|
947 |
-
if ( isset( $metadata['file'] ) ){
|
948 |
$metadata['file'] = "rtMedia/$prefix/" . $metadata['file'];
|
949 |
wp_update_attachment_metadata( $id, $metadata );
|
950 |
}
|
951 |
-
if ( $instagram_thumbs ){
|
952 |
update_rtmedia_meta( $id, '_instagram_thumbs', $instagram_thumbs_new );
|
953 |
}
|
954 |
-
if ( $instagram_full_images ){
|
955 |
update_rtmedia_meta( $id, '_instagram_full_images', $instagram_full_images_new );
|
956 |
}
|
957 |
-
if ( $instagram_metadata ){
|
958 |
update_rtmedia_meta( $id, '_instagram_metadata', $instagram_metadata_new );
|
959 |
}
|
960 |
-
if ( $encoding_job_id ){
|
961 |
update_rtmedia_meta( $id, 'rtmedia-encoding-job-id', $encoding_job_id );
|
962 |
}
|
963 |
-
if ( $ffmpeg_thumbnail_ids ){
|
964 |
update_rtmedia_meta( $id, 'rtmedia-thumbnail-ids', $ffmpeg_thumbnail_ids );
|
965 |
}
|
966 |
-
if ( $ffmpeg_thumbnail ){
|
967 |
$model = new RTMediaModel();
|
968 |
$model->update( array( 'cover_art' => $ffmpeg_thumbnail ), array( 'id' => $id ) );
|
969 |
}
|
970 |
-
if ( $ffmpeg_remote_id ){
|
971 |
update_rtmedia_meta( $id, 'rtmedia-ffmpeg-remote-id', $ffmpeg_remote_id );
|
972 |
}
|
973 |
-
if ( $kaltura_remote_id ){
|
974 |
update_rtmedia_meta( $id, 'rtmedia-kaltura-remote-id', $kaltura_remote_id );
|
975 |
}
|
976 |
|
977 |
-
$attachment
|
978 |
$attachment['ID'] = $id;
|
979 |
-
$old_guid
|
980 |
$attachment['guid'] = str_replace( $baseurl, $baseurl . "rtMedia/$prefix/", $old_guid );
|
981 |
/**
|
982 |
* For Activity
|
@@ -991,74 +1009,74 @@ class RTMediaMigration {
|
|
991 |
}
|
992 |
}
|
993 |
|
994 |
-
function search_and_replace( $old, $new ){
|
995 |
global $wpdb;
|
996 |
-
if ( function_exists( 'bp_core_get_table_prefix' ) ){
|
997 |
$bp_prefix = bp_core_get_table_prefix();
|
998 |
} else {
|
999 |
$bp_prefix = $wpdb->prefix;
|
1000 |
}
|
1001 |
-
$sql = $wpdb->prepare( "update {$bp_prefix}bp_activity set action=replace(action,%s,%s) ,content=replace(content,%s,%s), primary_link=replace(primary_link,%s,%s) where id > 0;", $old, $new, $old, $new, $old, $new );
|
1002 |
-
$wpdb->get_row( $sql )
|
1003 |
}
|
1004 |
|
1005 |
-
function
|
1006 |
|
1007 |
-
$
|
1008 |
-
$
|
1009 |
-
$
|
1010 |
|
1011 |
-
$days
|
1012 |
-
$
|
1013 |
|
1014 |
-
$hours
|
1015 |
-
$
|
1016 |
|
1017 |
-
$minutes = floor( $
|
1018 |
|
1019 |
-
$seconds = $
|
1020 |
|
1021 |
-
$
|
1022 |
|
1023 |
-
if ( $days > 0 ){
|
1024 |
-
$
|
1025 |
}
|
1026 |
|
1027 |
-
if ( $hours > 0 ){
|
1028 |
-
$
|
1029 |
}
|
1030 |
|
1031 |
-
if ( $minutes > 0 ){
|
1032 |
-
$
|
1033 |
}
|
1034 |
|
1035 |
-
if ( $seconds > 0 ){
|
1036 |
-
$
|
1037 |
}
|
1038 |
-
if ( count( $
|
1039 |
-
$
|
1040 |
-
$
|
1041 |
} else {
|
1042 |
-
$
|
1043 |
}
|
1044 |
|
1045 |
-
return $
|
1046 |
}
|
1047 |
|
1048 |
-
function insert_comment( $media_id, $data, $exclude, $parent_commnet_id = 0 ){
|
1049 |
foreach ( $data as $cmnt ) {
|
1050 |
$comment_id = 0;
|
1051 |
-
if ( ! key_exists( strval( $cmnt->id ), $exclude ) ){
|
1052 |
$commentdata = array(
|
1053 |
-
'comment_date'
|
1054 |
-
'comment_parent'
|
1055 |
-
'user_id'
|
1056 |
-
'comment_content'
|
1057 |
'comment_author_email' => $cmnt->user_email,
|
1058 |
-
'comment_post_ID'
|
1059 |
-
'comment_author'
|
1060 |
-
'comment_author_url'
|
1061 |
-
'comment_author_IP'
|
1062 |
);
|
1063 |
$comment_id = wp_insert_comment( $commentdata );
|
1064 |
$exclude[ strval( $cmnt->id ) ] = $comment_id;
|
@@ -1068,10 +1086,9 @@ class RTMediaMigration {
|
|
1068 |
|
1069 |
update_post_meta( $media_id, 'rtmedia_imported_activity', $exclude );
|
1070 |
|
1071 |
-
if ( is_array( $cmnt->children ) ){
|
1072 |
$this->insert_comment( $media_id, $cmnt->children, $exclude, $comment_id );
|
1073 |
}
|
1074 |
}
|
1075 |
}
|
1076 |
-
|
1077 |
}
|
9 |
|
10 |
public $bmp_table = '';
|
11 |
|
12 |
+
function __construct() {
|
13 |
global $wpdb;
|
14 |
$this->bmp_table = $wpdb->base_prefix . 'rt_rtm_media';
|
15 |
|
16 |
add_action( 'admin_menu', array( $this, 'menu' ) );
|
17 |
add_action( 'wp_ajax_bp_media_rt_db_migration', array( $this, 'migrate_to_new_db' ) );
|
18 |
|
19 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
20 |
+
$hide = filter_input( INPUT_GET, 'hide', FILTER_SANITIZE_STRING );
|
21 |
+
if ( isset( $page ) && 'rtmedia-migration' === $page && isset( $hide ) && 'true' === $hide ) {
|
22 |
$this->hide_migration_notice();
|
23 |
+
$http_referer = filter_input( INPUT_SERVER, 'HTTP_REFERER', FILTER_SANITIZE_URL );
|
24 |
+
wp_safe_redirect( esc_url_raw( $http_referer ) );
|
25 |
}
|
26 |
+
if ( false !== rtmedia_get_site_option( 'rt_migration_hide_notice' ) ) {
|
27 |
return true;
|
28 |
}
|
29 |
|
30 |
+
$force = filter_input( INPUT_GET, 'force', FILTER_SANITIZE_STRING );
|
31 |
+
if ( isset( $force ) && 'true' === $force ) {
|
32 |
$pending = false;
|
33 |
} else {
|
34 |
$pending = rtmedia_get_site_option( 'rtMigration-pending-count' );
|
35 |
}
|
36 |
|
37 |
+
if ( false === $pending ) {
|
38 |
$total = $this->get_total_count();
|
39 |
$done = $this->get_done_count();
|
40 |
$pending = $total - $done;
|
41 |
+
if ( $pending < 0 ) {
|
42 |
$pending = 0;
|
43 |
}
|
44 |
rtmedia_update_site_option( 'rtMigration-pending-count', $pending );
|
45 |
}
|
46 |
+
if ( $pending > 0 ) {
|
47 |
+
if ( ! ( isset( $page ) && 'rtmedia-migration' === $page ) ) {
|
48 |
add_action( 'admin_notices', array( &$this, 'add_migration_notice' ) );
|
49 |
}
|
50 |
}
|
51 |
}
|
52 |
|
53 |
+
function hide_migration_notice() {
|
54 |
rtmedia_update_site_option( 'rt_migration_hide_notice', true );
|
55 |
}
|
56 |
|
57 |
+
function migrate_image_size_fix() {
|
58 |
+
if ( '' === rtmedia_get_site_option( 'rt_image_size_migration_fix', '' ) ) {
|
59 |
global $wpdb;
|
60 |
$sql = $wpdb->prepare( "update $wpdb->postmeta set meta_value=replace(meta_value ,%s,%s) where meta_key = '_wp_attachment_metadata';", 'bp_media', 'rt_media' );
|
61 |
+
$wpdb->get_row( $sql ); // @codingStandardsIgnoreLine
|
62 |
update_option( 'rt_image_size_migration_fix', 'fix' );
|
63 |
}
|
64 |
}
|
65 |
|
66 |
+
function add_migration_notice() {
|
67 |
+
if ( current_user_can( 'manage_options' ) ) {
|
68 |
+
$this->create_notice( '<p><strong>' . esc_html__( 'rtMedia', 'buddypress-media' ) . '</strong>: ' . esc_html__( 'Please Migrate your Database', 'buddypress-media' ) . " <a href='" . esc_url( admin_url( 'admin.php?page=rtmedia-migration&force=true' ) ) . "'>" . esc_html__( 'Click Here', 'buddypress-media' ) . "</a>. <a href='" . esc_url( admin_url( 'admin.php?page=rtmedia-migration&hide=true' ) ) . "' style='float:right'>" . esc_html__( 'Hide', 'buddypress-media' ) . '</a> </p>' );
|
69 |
}
|
70 |
}
|
71 |
|
72 |
+
function create_notice( $message, $type = 'error' ) {
|
73 |
+
echo '<div class="' . esc_attr( $type ) . '">' . $message . '</div>'; // @codingStandardsIgnoreLine
|
74 |
}
|
75 |
|
76 |
+
static function table_exists( $table ) {
|
77 |
global $wpdb;
|
78 |
|
79 |
+
if ( 1 === intval( $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ) ) ) {
|
80 |
return true;
|
81 |
}
|
82 |
|
83 |
return false;
|
84 |
}
|
85 |
|
86 |
+
function menu() {
|
87 |
+
add_submenu_page( 'rtmedia-setting', esc_html__( 'Migration', 'buddypress-media' ), esc_html__( 'Migration', 'buddypress-media' ), 'manage_options', 'rtmedia-migration', array(
|
88 |
+
$this,
|
89 |
+
'test',
|
90 |
+
) );
|
91 |
}
|
92 |
|
93 |
+
function get_total_count() {
|
94 |
global $wpdb;
|
95 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
96 |
$bp_prefix = bp_core_get_table_prefix();
|
97 |
} else {
|
98 |
$bp_prefix = '';
|
99 |
}
|
100 |
$sql_album_usercount = "select count(*) FROM $wpdb->usermeta where meta_key ='bp-media-default-album' ";
|
101 |
|
102 |
+
$_SESSION['migration_user_album'] = $wpdb->get_var( $sql_album_usercount ); // @codingStandardsIgnoreLine
|
103 |
+
$count = intval( $_SESSION['migration_user_album'] );
|
104 |
|
105 |
+
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ) {
|
106 |
+
$sql_album_groupcount = $wpdb->prepare( "select count(*) FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album'" ); // @codingStandardsIgnoreLine
|
107 |
+
$_SESSION['migration_group_album'] = $wpdb->get_var( $sql_album_groupcount ); // @codingStandardsIgnoreLine
|
108 |
$count += intval( $_SESSION['migration_group_album'] );
|
109 |
}
|
110 |
+
if ( $this->table_exists( $bp_prefix . 'bp_activity' ) ) {
|
|
|
111 |
$sql_bpm_comment_count = "SELECT
|
112 |
count(id)
|
113 |
FROM
|
126 |
and is_spam <>1 and
|
127 |
not p.meta_value is NULL";
|
128 |
|
129 |
+
$_SESSION['migration_activity'] = $wpdb->get_var( $sql_bpm_comment_count ); // @codingStandardsIgnoreLine
|
|
|
|
|
130 |
$count += intval( $_SESSION['migration_activity'] );
|
131 |
}
|
132 |
|
145 |
a.post_id > 0 and (NOT p.ID IS NULL)
|
146 |
and a.meta_key = 'bp-media-key'";
|
147 |
|
148 |
+
$_SESSION['migration_media'] = $wpdb->get_var( $sql ); // @codingStandardsIgnoreLine
|
149 |
$count += intval( $_SESSION['migration_media'] );
|
150 |
|
|
|
151 |
return $count;
|
152 |
}
|
153 |
|
154 |
+
function get_last_imported() {
|
155 |
$album = rtmedia_get_site_option( 'rtmedia-global-albums' );
|
156 |
$album_id = $album[0];
|
157 |
|
163 |
where
|
164 |
a.meta_key = 'bp-media-key' and (NOT p.ID IS NULL) and a.post_id not in (select media_id
|
165 |
from {$this->bmp_table} where blog_id = %d and media_id <> %d ) order by a.post_ID";
|
166 |
+
$sql = $wpdb->prepare( $sql, get_current_blog_id(), $album_id ); // @codingStandardsIgnoreLine
|
167 |
+
$row = $wpdb->get_row( $sql ); // @codingStandardsIgnoreLine
|
168 |
+
if ( $row ) {
|
169 |
return $row->post_ID;
|
170 |
} else {
|
171 |
return false;
|
172 |
}
|
173 |
}
|
174 |
|
175 |
+
function get_done_count( $flag = false ) {
|
176 |
global $wpdb;
|
177 |
$sql = "select count(*)
|
178 |
from {$this->bmp_table} where blog_id = %d and media_id in (select a.post_id
|
190 |
a.post_id > 0 and (NOT p.ID IS NULL)
|
191 |
and a.meta_key = 'bp-media-key')";
|
192 |
|
193 |
+
$media_count = $wpdb->get_var( $wpdb->prepare( $sql, get_current_blog_id() ) ); // @codingStandardsIgnoreLine
|
194 |
+
if ( $flag ) {
|
195 |
return $media_count - 1;
|
196 |
}
|
197 |
$state = intval( rtmedia_get_site_option( 'rtmedia-migration', '0' ) );
|
198 |
+
if ( 5 == $state ) {
|
199 |
$album_count = intval( $_SESSION['migration_user_album'] );
|
200 |
$album_count += ( isset( $_SESSION['migration_group_album'] ) ) ? intval( $_SESSION['migration_group_album'] ) : 0;
|
201 |
} else {
|
202 |
+
if ( $state > 0 ) {
|
203 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
204 |
$bp_prefix = bp_core_get_table_prefix();
|
205 |
} else {
|
206 |
$bp_prefix = '';
|
207 |
}
|
208 |
$pending_count = "select count(*) from $wpdb->posts where post_type='bp_media_album' and ( ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
209 |
+
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ) {
|
210 |
$pending_count .= " or ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
211 |
}
|
212 |
$pending_count .= ')';
|
213 |
+
$pending_count = $wpdb->get_var( $pending_count ); // @codingStandardsIgnoreLine
|
214 |
|
215 |
$album_count = intval( $_SESSION['migration_user_album'] );
|
216 |
$album_count += ( isset( $_SESSION['migration_group_album'] ) ) ? intval( $_SESSION['migration_group_album'] ) : 0;
|
219 |
$album_count = 0;
|
220 |
}
|
221 |
}
|
222 |
+
if ( isset( $_SESSION['migration_activity'] ) && intval( $_SESSION['migration_media'] ) == intval( $media_count ) ) {
|
223 |
$comment_sql = $_SESSION['migration_activity'];
|
224 |
} else {
|
225 |
+
// @codingStandardsIgnoreStart
|
226 |
$comment_sql = $wpdb->get_var( "select count(*)
|
227 |
from $wpdb->comments a
|
228 |
where a.comment_post_ID in (select b.media_id from $this->bmp_table b left join
|
229 |
{$wpdb->posts} p ON (b.media_id = p.ID) where (NOT p.ID IS NULL) ) and a.comment_agent=''" );
|
230 |
+
// @codingStandardsIgnoreEnd
|
231 |
}
|
232 |
|
|
|
233 |
return $media_count + $album_count + $comment_sql;
|
234 |
}
|
235 |
|
236 |
+
function return_migration() {
|
237 |
$total = $this->get_total_count();
|
238 |
$done = $this->get_done_count();
|
239 |
$pending = $total - $done;
|
240 |
+
if ( $pending < 0 ) {
|
241 |
$pending = 0;
|
242 |
$done = $total;
|
243 |
}
|
244 |
+
if ( $done > $total ) {
|
245 |
$done = $total;
|
246 |
}
|
247 |
+
if ( $done === $total ) {
|
248 |
global $wp_rewrite;
|
249 |
//Call flush_rules() as a method of the $wp_rewrite object
|
250 |
$wp_rewrite->flush_rules( true );
|
251 |
}
|
252 |
rtmedia_update_site_option( 'rtMigration-pending-count', $pending );
|
253 |
+
$pending_time = $this->format_seconds( $pending );
|
254 |
|
255 |
+
echo wp_json_encode( array( 'status' => true, 'done' => $done, 'total' => $total, 'pending' => $pending_time ) );
|
256 |
die();
|
257 |
}
|
258 |
|
259 |
+
function manage_album() {
|
260 |
$album = rtmedia_get_site_option( 'rtmedia-global-albums' );
|
261 |
$stage = intval( rtmedia_get_site_option( 'rtmedia-migration', '0' ) );
|
262 |
|
266 |
|
267 |
global $wpdb;
|
268 |
|
269 |
+
$album_id = $wpdb->get_var( $wpdb->prepare( "select media_id from $this->bmp_table where id = %d", $album_rt_id ) ); // @codingStandardsIgnoreLine
|
270 |
|
271 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
272 |
$bp_prefix = bp_core_get_table_prefix();
|
273 |
} else {
|
274 |
$bp_prefix = '';
|
275 |
}
|
276 |
|
277 |
+
if ( $stage < 1 ) {
|
278 |
global $wpdb;
|
279 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
280 |
$bp_prefix = bp_core_get_table_prefix();
|
281 |
} else {
|
282 |
$bp_prefix = '';
|
283 |
}
|
284 |
+
$sql = $wpdb->prepare( "update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;", '<ul class="bp-media-list-media">', '<div class="rtmedia-activity-container"><ul class="rtmedia-list large-block-grid-3">' ); // @codingStandardsIgnoreLine
|
285 |
$wpdb->get_row( $sql );
|
286 |
+
$sql = $wpdb->prepare( "update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;", '</ul>', '</ul></div>' ); // @codingStandardsIgnoreLine
|
287 |
$wpdb->get_row( $sql );
|
288 |
|
289 |
$sql_group = "update $wpdb->posts set post_parent='{$album_id}' where post_parent in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
290 |
+
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ) {
|
291 |
$sql_group .= " or post_parent in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
292 |
}
|
293 |
+
$wpdb->query( $sql_group ); // @codingStandardsIgnoreLine
|
294 |
$stage = 1;
|
295 |
rtmedia_update_site_option( 'rtmedia-migration', $stage );
|
296 |
$this->return_migration();
|
297 |
}
|
298 |
+
if ( $stage < 2 ) {
|
299 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') limit 10";
|
300 |
+
$results = $wpdb->get_results( $sql_delete ); // @codingStandardsIgnoreLine
|
301 |
$delete_ids = '';
|
302 |
$sep = '';
|
303 |
foreach ( $results as $result ) {
|
305 |
$delete_ids .= $sep . $result->ID;
|
306 |
$sep = ',';
|
307 |
}
|
308 |
+
if ( '' !== $delete_ids ) {
|
309 |
+
//@todo missing prepare
|
310 |
+
$wpdb->query( "delete from $wpdb->posts where ID in ({$delete_ids})" ); // @codingStandardsIgnoreLine
|
311 |
}
|
312 |
+
if ( count( $results ) < 10 ) {
|
313 |
$stage = 2;
|
314 |
}
|
315 |
rtmedia_update_site_option( 'rtmedia-migration', $stage );
|
316 |
$this->return_migration();
|
317 |
}
|
318 |
+
if ( $stage < 3 ) {
|
319 |
+
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ) {
|
320 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album') limit 10";
|
321 |
+
$results = $wpdb->get_results( $sql_delete ); // @codingStandardsIgnoreLine
|
322 |
$delete_ids = '';
|
323 |
$sep = '';
|
324 |
+
if ( $results ) {
|
325 |
foreach ( $results as $result ) {
|
326 |
$group_id = abs( intval( get_post_meta( $result->ID, 'bp-media-key', true ) ) );
|
327 |
$this->search_and_replace( trailingslashit( get_rtmedia_group_link( $group_id ) ) . 'albums/' . $result->ID, trailingslashit( get_rtmedia_group_link( $group_id ) ) . RTMEDIA_MEDIA_SLUG . '/' . $album_rt_id );
|
328 |
$delete_ids .= $sep . $result->ID;
|
329 |
$sep = ',';
|
330 |
}
|
331 |
+
if ( '' !== $delete_ids ) {
|
332 |
+
//@todo prepare
|
333 |
+
$wpdb->query( "delete from $wpdb->posts where ID in ({$delete_ids})" ); // @codingStandardsIgnoreLine
|
334 |
}
|
335 |
+
if ( count( $results ) < 10 ) {
|
336 |
$stage = 3;
|
337 |
}
|
338 |
} else {
|
348 |
}
|
349 |
|
350 |
$sql = "update $wpdb->posts set post_type='{$album_post_type}' where post_type='bp_media_album'";
|
351 |
+
if ( false !== $wpdb->query( $sql ) ) { // @codingStandardsIgnoreLine
|
352 |
rtmedia_update_site_option( 'rtmedia-migration', '5' );
|
353 |
|
354 |
return true;
|
357 |
return false;
|
358 |
}
|
359 |
|
360 |
+
function test() {
|
361 |
+
if ( ! $this->table_exists( $this->bmp_table ) ) {
|
362 |
$obj = new RTDBUpdate( false, RTMEDIA_PATH . 'index.php', RTMEDIA_PATH . 'app/schema/', true );
|
363 |
$obj->install_db_version = '0';
|
364 |
$obj->do_upgrade( true );
|
365 |
}
|
366 |
global $rtmedia_error;
|
367 |
+
if ( isset( $rtmedia_error ) && true === $rtmedia_error ) {
|
368 |
?>
|
369 |
<div class="error"><p> Please Resolve create database error before migration.</p></div>
|
370 |
+
<?php
|
371 |
}
|
372 |
|
373 |
$prog = new rtProgress();
|
374 |
$total = $this->get_total_count();
|
375 |
$done = $this->get_done_count();
|
376 |
+
if ( $done >= $total ) {
|
377 |
$done = $total;
|
378 |
} else {
|
379 |
?>
|
380 |
<div class="error">
|
381 |
+
<p> <?php esc_html_e( 'Please Backup your ', 'buddypress-media' ); ?>
|
382 |
+
<strong><?php esc_html_e( 'DATABASE', 'buddypress-media' ); ?></strong>
|
383 |
+
<?php esc_html_e( ' and ', 'buddypress-media' ); ?>
|
384 |
+
<strong><?php esc_html_e( 'UPLOAD', 'buddypress-media' ); ?></strong>
|
385 |
+
<?php esc_html_e( ' folder before Migration.', 'buddypress-media' ); ?>
|
386 |
+
</p>
|
387 |
</div>
|
388 |
+
<?php
|
389 |
}
|
390 |
?>
|
391 |
|
392 |
<div class="wrap">
|
393 |
|
394 |
+
<h2><?php esc_html_e( 'rtMedia Migration', 'buddypress-media' ); ?></h2>
|
395 |
+
|
396 |
+
<h3><?php esc_html_e( 'It will migrate following things', 'buddypress-media' ); ?> </h3>
|
397 |
+
<?php esc_html_e( 'User Albums : ', 'buddypress-media' );
|
398 |
+
echo esc_html( $_SESSION['migration_user_album'] ); ?><br/>
|
399 |
+
<?php if ( isset( $_SESSION['migration_group_album'] ) ) {
|
400 |
+
esc_html_e( 'Groups Albums : ', 'buddypress-media' );
|
401 |
+
echo esc_html( $_SESSION['migration_group_album'] ); ?><br/>
|
402 |
+
<?php }
|
403 |
+
esc_html_e( 'Media : ', 'buddypress-media' );
|
404 |
+
echo esc_html( $_SESSION['migration_media'] ); ?><br/>
|
405 |
+
?>
|
406 |
+
<?php if ( isset( $_SESSION['migration_activity'] ) ) {
|
407 |
+
esc_html_e( 'Comments : ', 'buddypress-media' );
|
408 |
+
echo esc_html( $_SESSION['migration_activity'] ); ?><br/>
|
409 |
<?php } ?>
|
410 |
<hr/>
|
411 |
|
412 |
<?php
|
413 |
+
echo '<span class="pending">' . esc_html( $this->format_seconds( $total - $done ) ) . '</span><br />';
|
414 |
+
echo '<span class="finished">' . esc_html( $done ) . '</span>/<span class="total">' . esc_html( $total ) . '</span>';
|
415 |
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
416 |
|
417 |
$temp = $prog->progress( $done, $total );
|
418 |
$prog->progress_ui( $temp, true );
|
419 |
?>
|
420 |
<script type="text/javascript">
|
421 |
+
jQuery(document).ready(function (e) {
|
422 |
+
jQuery("#toplevel_page_rtmedia-settings").addClass("wp-has-current-submenu")
|
423 |
+
jQuery("#toplevel_page_rtmedia-settings").removeClass("wp-not-current-submenu")
|
424 |
+
jQuery("#toplevel_page_rtmedia-settings").addClass("wp-menu-open")
|
425 |
+
jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-menu-open")
|
426 |
+
jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-has-current-submenu")
|
427 |
+
|
428 |
+
if (db_total < 1)
|
429 |
+
jQuery("#submit").attr('disabled', "disabled");
|
430 |
+
});
|
431 |
+
function db_start_migration(db_done, db_total) {
|
432 |
+
|
433 |
+
|
434 |
+
if (db_done < db_total) {
|
435 |
+
jQuery("#rtMediaSyncing").show();
|
436 |
+
jQuery.ajax({
|
437 |
url: rtmedia_admin_ajax,
|
438 |
type: 'post',
|
439 |
data: {
|
440 |
"action": "bp_media_rt_db_migration",
|
441 |
"done": db_done
|
442 |
},
|
443 |
+
success: function (sdata) {
|
444 |
|
445 |
try {
|
446 |
+
data = JSON.parse(sdata);
|
447 |
+
} catch (e) {
|
448 |
+
jQuery("#submit").attr('disabled', "");
|
449 |
}
|
450 |
+
if (data.status) {
|
451 |
+
done = parseInt(data.done);
|
452 |
+
total = parseInt(data.total);
|
453 |
+
var progw = Math.ceil((done / total) * 100);
|
454 |
+
if (progw > 100) {
|
455 |
progw = 100;
|
456 |
}
|
457 |
+
jQuery('#rtprogressbar>div').css('width', progw + '%');
|
458 |
+
jQuery('span.finished').html(done);
|
459 |
+
jQuery('span.total').html(total);
|
460 |
+
jQuery('span.pending').html(data.pending);
|
461 |
+
db_start_migration(done, total);
|
|
|
462 |
} else {
|
463 |
+
alert("Migration completed.");
|
464 |
+
jQuery("#rtMediaSyncing").hide();
|
465 |
}
|
466 |
},
|
467 |
error: function () {
|
468 |
+
alert("<?php esc_html_e( 'Error During Migration, Please Refresh Page then try again', 'buddypress-media' ); ?>");
|
469 |
+
jQuery("#submit").removeAttr('disabled');
|
470 |
}
|
471 |
+
});
|
472 |
} else {
|
473 |
+
alert("Migration completed.");
|
474 |
+
jQuery("#rtMediaSyncing").hide();
|
475 |
}
|
476 |
}
|
477 |
+
var db_done = <?php echo esc_js( $done ); ?>;
|
478 |
+
var db_total = <?php echo esc_js( $total ); ?>;
|
479 |
+
jQuery(document).on('click', '#submit', function (e) {
|
480 |
e.preventDefault();
|
481 |
|
482 |
+
db_start_migration(db_done, db_total);
|
483 |
+
jQuery(this).attr('disabled', 'disabled');
|
484 |
+
});
|
485 |
</script>
|
486 |
<hr/>
|
487 |
+
<?php if ( ! ( isset( $rtmedia_error ) && true === $rtmedia_error ) ) { ?>
|
488 |
<input type="button" id="submit" value="<?php esc_attr_e( 'Start', 'buddypress-media' ); ?>"
|
489 |
+
class="button button-primary"/>
|
490 |
<?php } ?>
|
491 |
|
492 |
</div>
|
493 |
+
<?php
|
494 |
}
|
495 |
|
496 |
+
function migrate_to_new_db( $lastid = 0, $limit = 1 ) {
|
497 |
|
498 |
+
if ( ! isset( $_SESSION['migration_media'] ) ) {
|
499 |
$this->get_total_count();
|
500 |
}
|
501 |
|
502 |
$state = intval( rtmedia_get_site_option( 'rtmedia-migration' ) );
|
503 |
+
if ( $state < 5 ) {
|
504 |
+
if ( $this->manage_album() ) {
|
505 |
$this->migrate_encoding_options();
|
506 |
$this->return_migration();
|
507 |
}
|
508 |
}
|
509 |
|
510 |
+
if ( intval( $_SESSION['migration_media'] ) >= $this->get_done_count( true ) ) {
|
511 |
|
512 |
+
if ( ! $lastid ) {
|
513 |
$lastid = $this->get_last_imported();
|
514 |
+
if ( ! $lastid ) {
|
515 |
$this->return_migration();
|
516 |
}
|
517 |
}
|
542 |
order by a.post_id
|
543 |
limit %d";
|
544 |
|
545 |
+
$results = $wpdb->get_results( $wpdb->prepare( $sql, $lastid, $limit ) ); // @codingStandardsIgnoreLine
|
546 |
|
547 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
548 |
$bp_prefix = bp_core_get_table_prefix();
|
549 |
} else {
|
550 |
$bp_prefix = '';
|
551 |
}
|
552 |
+
if ( $results ) {
|
553 |
|
554 |
foreach ( $results as $result ) {
|
555 |
$this->migrate_single_media( $result );
|
559 |
global $wp_rewrite;
|
560 |
//Call flush_rules() as a method of the $wp_rewrite object
|
561 |
$wp_rewrite->flush_rules( true );
|
|
|
|
|
562 |
}
|
563 |
$this->return_migration();
|
564 |
}
|
565 |
|
566 |
+
function migrate_encoding_options() {
|
567 |
$encoding_mnigration_array = array(
|
568 |
+
'bp-media-encoding-api-key' => 'rtmedia-encoding-api-key',
|
569 |
+
'bp-media-encoding-usage-limit-mail' => 'rtmedia-encoding-usage-limit-mail',
|
570 |
+
'bp-media-encoding-usage' => 'rtmedia-encoding-usage',
|
571 |
+
'bpmedia_encoding_service_notice' => 'rtmedia-encoding-service-notice',
|
572 |
+
'bpmedia_encoding_expansion_notice' => 'rtmedia-encoding-expansion-notice',
|
573 |
+
'bp_media_ffmpeg_options' => 'rtmedia-ffmpeg-options',
|
574 |
+
'bp_media_kaltura_options' => 'rtmedia-kaltura-options',
|
575 |
);
|
576 |
foreach ( $encoding_mnigration_array as $key => $ma ) {
|
577 |
+
if ( false !== ( $value = rtmedia_get_site_option( $key ) ) ) {
|
578 |
rtmedia_update_site_option( $ma, $value );
|
579 |
}
|
580 |
}
|
581 |
}
|
582 |
|
583 |
+
function migrate_single_media( $result, $album = false ) {
|
584 |
$blog_id = get_current_blog_id();
|
585 |
$old = $result;
|
586 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
587 |
$bp_prefix = bp_core_get_table_prefix();
|
588 |
} else {
|
589 |
$bp_prefix = '';
|
590 |
}
|
591 |
global $wpdb;
|
592 |
|
593 |
+
if ( false !== $album && ! ( is_object( $result ) ) ) {
|
594 |
+
$id = $wpdb->get_var( $wpdb->prepare( "select ID from {$this->bmp_table} where media_id = %d", $result ) ); // @codingStandardsIgnoreLine
|
595 |
+
if ( null == $id ) {
|
596 |
$sql = "select
|
597 |
a.post_id as 'post_id',
|
598 |
a.meta_value as 'privacy',
|
616 |
where
|
617 |
a.post_id = %d and (NOT p.ID IS NULL)
|
618 |
and a.meta_key = 'bp_media_privacy'";
|
619 |
+
$result = $wpdb->get_row( $wpdb->prepare( $sql, $result ) ); // @codingStandardsIgnoreLine
|
620 |
} else {
|
621 |
return $id;
|
622 |
}
|
623 |
}
|
624 |
+
if ( ! isset( $result ) || ! isset( $result->post_id ) ) {
|
625 |
return $old;
|
626 |
}
|
627 |
$media_id = $result->post_id;
|
628 |
|
629 |
+
if ( intval( $result->context_id ) > 0 ) {
|
630 |
$media_context = 'profile';
|
631 |
$prefix = 'users/' . abs( intval( $result->context_id ) );
|
632 |
} else {
|
635 |
}
|
636 |
|
637 |
$old_type = '';
|
638 |
+
if ( 'attachment' != $result->post_type ) {
|
639 |
$media_type = 'album';
|
640 |
} else {
|
641 |
$mime_type = strtolower( $result->post_mime_type );
|
642 |
$old_type = '';
|
643 |
+
if ( 0 === strpos( $mime_type, 'image' ) ) {
|
644 |
$media_type = 'photo';
|
645 |
$old_type = 'photos';
|
646 |
} else {
|
647 |
+
if ( 0 === strpos( $mime_type, 'audio' ) ) {
|
648 |
$media_type = 'music';
|
649 |
$old_type = 'music';
|
650 |
} else {
|
651 |
+
if ( 0 === strpos( $mime_type, 'video' ) ) {
|
652 |
$media_type = 'video';
|
653 |
$old_type = 'videos';
|
654 |
} else {
|
658 |
}
|
659 |
}
|
660 |
|
661 |
+
$activity_data = $wpdb->get_row( $wpdb->prepare( "select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id ) ); // @codingStandardsIgnoreLine
|
662 |
+
if ( 'album' != $media_type ) {
|
663 |
$this->importmedia( $media_id, $prefix );
|
664 |
}
|
665 |
|
666 |
+
if ( $this->table_exists( $bp_prefix . 'bp_activity' ) && class_exists( 'BP_Activity_Activity' ) ) {
|
667 |
$bp_activity = new BP_Activity_Activity();
|
668 |
+
// @codingStandardsIgnoreStart
|
669 |
$activity_sql = $wpdb->prepare( "SELECT
|
670 |
*
|
671 |
FROM
|
681 |
(NOT p.ID IS NULL) and p.ID = %d
|
682 |
and a.meta_key = 'bp_media_child_activity')", $media_id );
|
683 |
$all_activity = $wpdb->get_results( $activity_sql );
|
684 |
+
// @codingStandardsIgnoreEnd
|
685 |
remove_all_actions( 'wp_insert_comment' );
|
686 |
foreach ( $all_activity as $activity ) {
|
687 |
$comments = $bp_activity->get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right );
|
688 |
$exclude = get_post_meta( $media_id, 'rtmedia_imported_activity', true );
|
689 |
+
if ( ! is_array( $exclude ) ) {
|
690 |
$exclude = array();
|
691 |
}
|
692 |
+
if ( $comments ) {
|
693 |
$this->insert_comment( $media_id, $comments, $exclude );
|
694 |
}
|
695 |
}
|
696 |
}
|
697 |
+
if ( 0 !== intval( $result->parent ) ) {
|
698 |
$album_id = $this->migrate_single_media( $result->parent, true );
|
699 |
} else {
|
700 |
$album_id = 0;
|
701 |
}
|
702 |
+
if ( function_exists( 'bp_activity_get_meta' ) ) {
|
703 |
$likes = bp_activity_get_meta( $result->activity_id, 'favorite_count' );
|
704 |
} else {
|
705 |
$likes = 0;
|
706 |
}
|
707 |
|
708 |
$wpdb->insert( $this->bmp_table, array(
|
709 |
+
'blog_id' => $blog_id,
|
710 |
+
'media_id' => $media_id,
|
711 |
+
'media_type' => $media_type,
|
712 |
+
'context' => $media_context,
|
713 |
+
'context_id' => abs( intval( $result->context_id ) ),
|
714 |
+
'activity_id' => $result->activity_id,
|
715 |
+
'privacy' => intval( $result->privacy ) * 10,
|
716 |
+
'media_author' => $result->media_author,
|
717 |
+
'media_title' => $result->media_title,
|
718 |
+
'album_id' => $album_id,
|
719 |
+
'likes' => $likes,
|
720 |
+
), array( '%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d' ) );
|
721 |
$last_id = $wpdb->insert_id;
|
722 |
|
723 |
+
if ( 'album' != $media_type && function_exists( 'bp_core_get_user_domain' ) && $activity_data ) {
|
724 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
$bp_prefix = bp_core_get_table_prefix();
|
726 |
} else {
|
727 |
$bp_prefix = '';
|
735 |
$activity_data->content = str_replace( $activity_data->old_primary_link, $activity_data->primary_link, $activity_data->content );
|
736 |
global $last_baseurl, $last_newurl;
|
737 |
|
738 |
+
$replace_img = $last_newurl;
|
739 |
+
if ( false === strpos( $activity_data->content, $replace_img ) ) {
|
740 |
$activity_data->content = str_replace( $last_baseurl, $replace_img, $activity_data->content );
|
741 |
}
|
742 |
global $wpdb;
|
743 |
$wpdb->update( $bp_prefix . 'bp_activity', array(
|
744 |
+
'primary_link' => $activity_data->primary_link,
|
745 |
+
'action' => $activity_data->action,
|
746 |
+
'content' => $activity_data->content,
|
747 |
), array( 'id' => $activity_data->id ) );
|
748 |
} else {
|
749 |
+
if ( 'group' == $media_context ) {
|
750 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
751 |
$parent_link = get_rtmedia_group_link( abs( intval( $result->context_id ) ) );
|
752 |
$parent_link = trailingslashit( $parent_link );
|
760 |
$this->search_and_replace( $activity_data->old_primary_link, $activity_data->primary_link );
|
761 |
}
|
762 |
}
|
763 |
+
if ( '' != $old_type ) {
|
764 |
+
if ( 'group' == $media_context ) {
|
765 |
$parent_link = get_rtmedia_group_link( abs( intval( $result->context_id ) ) );
|
766 |
$parent_link = trailingslashit( $parent_link );
|
767 |
$this->search_and_replace( trailingslashit( $parent_link . $old_type . '/' . $media_id ), trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id ) );
|
775 |
return $last_id;
|
776 |
}
|
777 |
|
778 |
+
/**
|
779 |
+
* @param $id
|
780 |
+
* @param $prefix
|
781 |
+
*/
|
782 |
+
function importmedia( $id, $prefix ) {
|
783 |
|
784 |
$delete = false;
|
785 |
$attached_file = get_attached_file( $id );
|
790 |
$siteurl = get_option( 'siteurl' );
|
791 |
$upload_path = trim( get_option( 'upload_path' ) );
|
792 |
|
793 |
+
if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
|
794 |
$dir = WP_CONTENT_DIR . '/uploads';
|
795 |
} elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
|
796 |
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
799 |
$dir = $upload_path;
|
800 |
}
|
801 |
|
802 |
+
if ( ! $url = get_option( 'upload_url_path' ) ) {
|
803 |
+
if ( empty( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) {
|
804 |
$url = WP_CONTENT_URL . '/uploads';
|
805 |
} else {
|
806 |
$url = trailingslashit( $siteurl ) . $upload_path;
|
809 |
|
810 |
// Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
|
811 |
// We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
|
812 |
+
if ( defined( 'UPLOADS' ) && ! ( is_multisite() && rtmedia_get_site_option( 'ms_files_rewriting' ) ) ) {
|
813 |
$dir = ABSPATH . UPLOADS;
|
814 |
$url = trailingslashit( $siteurl ) . UPLOADS;
|
815 |
}
|
816 |
|
817 |
// If multisite (and if not the main site in a post-MU network)
|
818 |
+
if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
|
819 |
|
820 |
+
if ( ! rtmedia_get_site_option( 'ms_files_rewriting' ) ) {
|
821 |
// If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
|
822 |
// Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory
|
823 |
// prevents a four-digit ID from conflicting with a year-based directory for the main site.
|
824 |
// But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra
|
825 |
// directory, as they never had wp-content/uploads for the main site.)
|
826 |
|
827 |
+
if ( defined( 'MULTISITE' ) ) {
|
828 |
$ms_dir = '/sites/' . get_current_blog_id();
|
829 |
} else {
|
830 |
$ms_dir = '/' . get_current_blog_id();
|
845 |
// as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
|
846 |
// rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
|
847 |
|
848 |
+
if ( defined( 'BLOGUPLOADDIR' ) ) {
|
849 |
$dir = untrailingslashit( BLOGUPLOADDIR );
|
850 |
} else {
|
851 |
$dir = ABSPATH . UPLOADS;
|
872 |
$ffmpeg_remote_id = get_post_meta( $id, 'bp_media_ffmpeg_remote_id', true );
|
873 |
$kaltura_remote_id = get_post_meta( $id, 'bp_media_kaltura_remote_id', true );
|
874 |
|
875 |
+
if ( wp_mkdir_p( $basedir . "rtMedia/$prefix/" . $year_month ) ) {
|
876 |
+
if ( copy( $attached_file, str_replace( $basedir, $basedir . "rtMedia/$prefix/", $attached_file ) ) ) {
|
877 |
$delete = true;
|
878 |
|
879 |
+
if ( isset( $metadata['sizes'] ) ) {
|
880 |
foreach ( $metadata['sizes'] as $size ) {
|
881 |
+
if ( ! copy( $file_folder_path . $size['file'], $new_file_folder_path . $size['file'] ) ) {
|
882 |
$delete = false;
|
883 |
} else {
|
884 |
$delete_sizes[] = $file_folder_path . $size['file'];
|
886 |
}
|
887 |
}
|
888 |
}
|
889 |
+
if ( $backup_metadata ) {
|
890 |
foreach ( $backup_metadata as $backup_images ) {
|
891 |
+
if ( ! copy( $file_folder_path . $backup_images['file'], $new_file_folder_path . $backup_images['file'] ) ) {
|
892 |
$delete = false;
|
893 |
} else {
|
894 |
$delete_sizes[] = $file_folder_path . $backup_images['file'];
|
897 |
}
|
898 |
}
|
899 |
|
900 |
+
if ( $instagram_thumbs ) {
|
901 |
foreach ( $instagram_thumbs as $key => $insta_thumb ) {
|
902 |
try {
|
903 |
+
if ( ! copy( str_replace( $baseurl, $basedir, $insta_thumb ), str_replace( $baseurl, $basedir . "rtMedia/$prefix/", $insta_thumb ) ) ) {
|
904 |
$delete = false;
|
905 |
} else {
|
906 |
+
$delete_sizes[] = str_replace( $baseurl, $basedir, $insta_thumb );
|
907 |
$instagram_thumbs_new[ $key ] = str_replace( $baseurl, $baseurl . "rtMedia/$prefix/", $insta_thumb );
|
908 |
$this->search_and_replace( trailingslashit( $baseurl . $year_month ) . $insta_thumb, trailingslashit( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_thumb );
|
909 |
}
|
910 |
+
} catch ( Exception $e ) {
|
911 |
$delete = false;
|
912 |
}
|
913 |
}
|
914 |
}
|
915 |
|
916 |
+
if ( $instagram_full_images ) {
|
917 |
foreach ( $instagram_full_images as $key => $insta_full_image ) {
|
918 |
+
if ( ! copy( $insta_full_image, str_replace( $basedir, $basedir . "rtMedia/$prefix/", $insta_full_image ) ) ) {
|
919 |
$delete = false;
|
920 |
} else {
|
921 |
+
$delete_sizes[] = $insta_full_image;
|
922 |
$instagram_full_images_new[ $key ] = str_replace( $basedir, $basedir . "rtMedia/$prefix", $insta_full_image );
|
923 |
$this->search_and_replace( trailingslashit( $baseurl . $year_month ) . $insta_full_image, trailingslashit( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_full_image );
|
924 |
}
|
925 |
}
|
926 |
}
|
927 |
|
928 |
+
if ( $instagram_metadata ) {
|
929 |
$instagram_metadata_new = $instagram_metadata;
|
930 |
foreach ( $instagram_metadata as $wp_size => $insta_metadata ) {
|
931 |
+
if ( isset( $insta_metadata['file'] ) ) {
|
932 |
+
if ( ! copy( $basedir . $insta_metadata['file'], $basedir . "rtMedia/$prefix/" . $insta_metadata['file'] ) ) {
|
933 |
$delete = false;
|
934 |
} else {
|
935 |
+
$delete_sizes[] = $basedir . $insta_metadata['file'];
|
936 |
$instagram_metadata_new[ $wp_size ]['file'] = "rtMedia/$prefix/" . $insta_metadata['file'];
|
937 |
+
if ( isset( $insta_metadata['sizes'] ) ) {
|
938 |
foreach ( $insta_metadata['sizes'] as $key => $insta_size ) {
|
939 |
+
if ( ! copy( $file_folder_path . $insta_size['file'], $new_file_folder_path . $insta_size['file'] ) ) {
|
940 |
$delete = false;
|
941 |
} else {
|
942 |
$delete_sizes[] = $file_folder_path . $insta_size['file'];
|
949 |
}
|
950 |
}
|
951 |
|
952 |
+
if ( $delete ) {
|
953 |
+
if ( file_exists( $attached_file ) ) {
|
954 |
unlink( $attached_file );
|
955 |
}
|
956 |
|
957 |
+
if ( isset( $delete_sizes ) ) {
|
958 |
foreach ( $delete_sizes as $delete_size ) {
|
959 |
+
if ( file_exists( $delete_size ) ) {
|
960 |
unlink( $delete_size );
|
961 |
}
|
962 |
}
|
963 |
}
|
964 |
update_post_meta( $id, '_wp_attached_file', "rtMedia/$prefix/" . $attached_file_option );
|
965 |
+
if ( isset( $metadata['file'] ) ) {
|
966 |
$metadata['file'] = "rtMedia/$prefix/" . $metadata['file'];
|
967 |
wp_update_attachment_metadata( $id, $metadata );
|
968 |
}
|
969 |
+
if ( $instagram_thumbs ) {
|
970 |
update_rtmedia_meta( $id, '_instagram_thumbs', $instagram_thumbs_new );
|
971 |
}
|
972 |
+
if ( $instagram_full_images ) {
|
973 |
update_rtmedia_meta( $id, '_instagram_full_images', $instagram_full_images_new );
|
974 |
}
|
975 |
+
if ( $instagram_metadata ) {
|
976 |
update_rtmedia_meta( $id, '_instagram_metadata', $instagram_metadata_new );
|
977 |
}
|
978 |
+
if ( $encoding_job_id ) {
|
979 |
update_rtmedia_meta( $id, 'rtmedia-encoding-job-id', $encoding_job_id );
|
980 |
}
|
981 |
+
if ( $ffmpeg_thumbnail_ids ) {
|
982 |
update_rtmedia_meta( $id, 'rtmedia-thumbnail-ids', $ffmpeg_thumbnail_ids );
|
983 |
}
|
984 |
+
if ( $ffmpeg_thumbnail ) {
|
985 |
$model = new RTMediaModel();
|
986 |
$model->update( array( 'cover_art' => $ffmpeg_thumbnail ), array( 'id' => $id ) );
|
987 |
}
|
988 |
+
if ( $ffmpeg_remote_id ) {
|
989 |
update_rtmedia_meta( $id, 'rtmedia-ffmpeg-remote-id', $ffmpeg_remote_id );
|
990 |
}
|
991 |
+
if ( $kaltura_remote_id ) {
|
992 |
update_rtmedia_meta( $id, 'rtmedia-kaltura-remote-id', $kaltura_remote_id );
|
993 |
}
|
994 |
|
995 |
+
$attachment = array();
|
996 |
$attachment['ID'] = $id;
|
997 |
+
$old_guid = get_post_field( 'guid', $id );
|
998 |
$attachment['guid'] = str_replace( $baseurl, $baseurl . "rtMedia/$prefix/", $old_guid );
|
999 |
/**
|
1000 |
* For Activity
|
1009 |
}
|
1010 |
}
|
1011 |
|
1012 |
+
function search_and_replace( $old, $new ) {
|
1013 |
global $wpdb;
|
1014 |
+
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
|
1015 |
$bp_prefix = bp_core_get_table_prefix();
|
1016 |
} else {
|
1017 |
$bp_prefix = $wpdb->prefix;
|
1018 |
}
|
1019 |
+
$sql = $wpdb->prepare( "update {$bp_prefix}bp_activity set action=replace(action,%s,%s) ,content=replace(content,%s,%s), primary_link=replace(primary_link,%s,%s) where id > 0;", $old, $new, $old, $new, $old, $new ); // @codingStandardsIgnoreLine
|
1020 |
+
$wpdb->get_row( $sql );// @codingStandardsIgnoreLine
|
1021 |
}
|
1022 |
|
1023 |
+
function format_seconds( $seconds_left ) {
|
1024 |
|
1025 |
+
$minute_in_seconds = 60;
|
1026 |
+
$hour_in_seconds = $minute_in_seconds * 60;
|
1027 |
+
$day_in_seconds = $hour_in_seconds * 24;
|
1028 |
|
1029 |
+
$days = floor( $seconds_left / $day_in_seconds );
|
1030 |
+
$seconds_left = $seconds_left % $day_in_seconds;
|
1031 |
|
1032 |
+
$hours = floor( $seconds_left / $hour_in_seconds );
|
1033 |
+
$seconds_left = $seconds_left % $hour_in_seconds;
|
1034 |
|
1035 |
+
$minutes = floor( $seconds_left / $minute_in_seconds );
|
1036 |
|
1037 |
+
$seconds = $seconds_left % $minute_in_seconds;
|
1038 |
|
1039 |
+
$time_components = array();
|
1040 |
|
1041 |
+
if ( $days > 0 ) {
|
1042 |
+
$time_components[] = $days .esc_html__( ' day', 'buddypress-media' ) . ( $days > 1 ? 's' : '' );
|
1043 |
}
|
1044 |
|
1045 |
+
if ( $hours > 0 ) {
|
1046 |
+
$time_components[] = $hours . esc_html__( ' hour', 'buddypress-media' ) . ( $hours > 1 ? 's' : '' );
|
1047 |
}
|
1048 |
|
1049 |
+
if ( $minutes > 0 ) {
|
1050 |
+
$time_components[] = $minutes . esc_html__( ' minute', 'buddypress-media' ) . ( $minutes > 1 ? 's' : '' );
|
1051 |
}
|
1052 |
|
1053 |
+
if ( $seconds > 0 ) {
|
1054 |
+
$time_components[] = $seconds . esc_html__( ' second', 'buddypress-media' ) . ( $seconds > 1 ? 's' : '' );
|
1055 |
}
|
1056 |
+
if ( count( $time_components ) > 0 ) {
|
1057 |
+
$formatted_time_remaining = implode( ', ', $time_components );
|
1058 |
+
$formatted_time_remaining = trim( $formatted_time_remaining );
|
1059 |
} else {
|
1060 |
+
$formatted_time_remaining = esc_html__( 'No time remaining.', 'buddypress-media' );
|
1061 |
}
|
1062 |
|
1063 |
+
return $formatted_time_remaining;
|
1064 |
}
|
1065 |
|
1066 |
+
function insert_comment( $media_id, $data, $exclude, $parent_commnet_id = 0 ) {
|
1067 |
foreach ( $data as $cmnt ) {
|
1068 |
$comment_id = 0;
|
1069 |
+
if ( ! key_exists( strval( $cmnt->id ), $exclude ) ) {
|
1070 |
$commentdata = array(
|
1071 |
+
'comment_date' => $cmnt->date_recorded,
|
1072 |
+
'comment_parent' => $parent_commnet_id,
|
1073 |
+
'user_id' => $cmnt->user_id,
|
1074 |
+
'comment_content' => $cmnt->content,
|
1075 |
'comment_author_email' => $cmnt->user_email,
|
1076 |
+
'comment_post_ID' => $media_id,
|
1077 |
+
'comment_author' => $cmnt->display_name,
|
1078 |
+
'comment_author_url' => '',
|
1079 |
+
'comment_author_IP' => '',
|
1080 |
);
|
1081 |
$comment_id = wp_insert_comment( $commentdata );
|
1082 |
$exclude[ strval( $cmnt->id ) ] = $comment_id;
|
1086 |
|
1087 |
update_post_meta( $media_id, 'rtmedia_imported_activity', $exclude );
|
1088 |
|
1089 |
+
if ( is_array( $cmnt->children ) ) {
|
1090 |
$this->insert_comment( $media_id, $cmnt->children, $exclude, $comment_id );
|
1091 |
}
|
1092 |
}
|
1093 |
}
|
|
|
1094 |
}
|
app/main/RTMedia.php
CHANGED
@@ -43,10 +43,10 @@ class RTMedia {
|
|
43 |
* @var object default application wide privacy levels
|
44 |
*/
|
45 |
public $default_privacy = array(
|
46 |
-
'0'
|
47 |
'20' => 'Users',
|
48 |
'40' => 'Friends',
|
49 |
-
'60' => 'Private'
|
50 |
);
|
51 |
|
52 |
/**
|
@@ -68,7 +68,7 @@ class RTMedia {
|
|
68 |
public $activity_types = array(
|
69 |
'media_upload',
|
70 |
'album_updated',
|
71 |
-
'album_created'
|
72 |
);
|
73 |
public $options;
|
74 |
public $render_options;
|
@@ -89,54 +89,62 @@ class RTMedia {
|
|
89 |
add_action( 'plugins_loaded', array( $this, 'init' ), 20 );
|
90 |
add_action( 'wp_enqueue_scripts', array( 'RTMediaGalleryShortcode', 'register_scripts' ) );
|
91 |
add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts_styles' ), 999 );
|
92 |
-
include(RTMEDIA_PATH . 'app/main/controllers/template/rt-template-functions.php');
|
93 |
add_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_details' ) );
|
94 |
add_filter( 'intermediate_image_sizes', array( $this, 'filter_image_sizes' ) );
|
95 |
-
add_filter(
|
96 |
add_filter( 'image_size_names_choose', array( $this, 'rtmedia_custom_image_sizes_choose' ) );
|
97 |
}
|
98 |
|
99 |
function filter_allow_mime_type_mu( $options ) {
|
100 |
-
$allowed_types
|
101 |
$this->allowed_types = apply_filters( 'rtmedia_allowed_types', $this->allowed_types );
|
102 |
foreach ( $this->allowed_types as $type ) {
|
103 |
-
if ( $type[
|
104 |
-
foreach ( $type[
|
105 |
$allowed_types[] = $extn;
|
106 |
}
|
107 |
}
|
108 |
}
|
109 |
-
$ext
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
111 |
$options = trim( $options );
|
112 |
foreach ( $ext_arr as $f_ext ) {
|
113 |
if ( $f_ext && strpos( $options, $f_ext ) === false ) {
|
114 |
-
$options .=
|
115 |
}
|
116 |
}
|
|
|
117 |
return $options;
|
118 |
}
|
119 |
|
120 |
function fix_parent_id() {
|
121 |
$site_global = rtmedia_get_site_option( 'rtmedia-global-albums' );
|
122 |
-
if ( $site_global && is_array( $site_global ) && isset( $site_global[
|
123 |
-
$model
|
124 |
-
$album_row = $model->get_by_id( $site_global[
|
125 |
-
if ( isset( $album_row[
|
126 |
global $wpdb;
|
127 |
-
$row = $album_row[
|
128 |
-
if ( isset( $row[
|
129 |
-
|
|
|
130 |
left join
|
131 |
-
$model->table_name r ON ( p.ID = r.media_id and blog_id =
|
132 |
set
|
133 |
-
post_parent =
|
134 |
where
|
135 |
-
p.guid like
|
136 |
and (p.post_parent = 0 or p.post_parent is NULL)
|
137 |
and not r.id is NULL
|
138 |
-
and r.media_type <> 'album'";
|
139 |
$wpdb->query( $sql );
|
|
|
140 |
}
|
141 |
}
|
142 |
}
|
@@ -144,9 +152,9 @@ class RTMedia {
|
|
144 |
|
145 |
function fix_privacy() {
|
146 |
global $wpdb;
|
147 |
-
$model
|
148 |
-
$update_sql = "UPDATE $model->table_name SET privacy = '80' where privacy = '-1' ";
|
149 |
-
$wpdb->query( $update_sql );
|
150 |
}
|
151 |
|
152 |
/*
|
@@ -158,36 +166,36 @@ class RTMedia {
|
|
158 |
//if buddypress is active and groups are enabled
|
159 |
global $wpdb;
|
160 |
$table_exist = false;
|
161 |
-
if( $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}bp_groups'" ) ){
|
162 |
$table_exist = true;
|
163 |
}
|
164 |
if ( class_exists( 'BuddyPress' ) && $table_exist ) {
|
165 |
-
$model
|
166 |
$sql_group = " UPDATE $model->table_name m join {$wpdb->prefix}bp_groups bp on m.context_id = bp.id SET m.privacy = 0 where m.context = 'group' and bp.status = 'public' and m.privacy <> 80 ";
|
167 |
-
$wpdb->query( $sql_group );
|
168 |
$sql_group = " UPDATE $model->table_name m join {$wpdb->prefix}bp_groups bp on m.context_id = bp.id SET m.privacy = 20 where m.context = 'group' and ( bp.status = 'private' OR bp.status = 'hidden' ) and m.privacy <> 80 ";
|
169 |
-
$wpdb->query( $sql_group );
|
170 |
}
|
171 |
}
|
172 |
|
173 |
function fix_db_collation() {
|
174 |
global $wpdb;
|
175 |
-
$model
|
176 |
$interaction_model = new RTMediaInteractionModel();
|
177 |
-
$update_media_sql
|
178 |
-
$wpdb->query( $update_media_sql );
|
179 |
-
$update_media_meta_sql =
|
180 |
-
$wpdb->query( $update_media_meta_sql );
|
181 |
-
$update_media_interaction_sql =
|
182 |
-
$wpdb->query( $update_media_interaction_sql );
|
183 |
}
|
184 |
|
185 |
function set_site_options() {
|
186 |
|
187 |
-
$rtmedia_options
|
188 |
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
189 |
|
190 |
-
if ( $rtmedia_options
|
191 |
$this->init_site_options();
|
192 |
} else {
|
193 |
/* if new options added via filter then it needs to be updated */
|
@@ -202,26 +210,43 @@ class RTMedia {
|
|
202 |
}
|
203 |
|
204 |
public function rtmedia_jpeg_quality( $quality ) {
|
205 |
-
$quality = isset( $this->options[
|
206 |
|
207 |
return $quality;
|
208 |
}
|
209 |
|
210 |
public function image_sizes() {
|
211 |
-
$image_sizes
|
212 |
-
$image_sizes[
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
return $image_sizes;
|
217 |
}
|
218 |
|
219 |
public function add_image_sizes() {
|
220 |
$bp_media_sizes = $this->image_sizes();
|
221 |
-
add_image_size(
|
222 |
-
add_image_size(
|
223 |
-
add_image_size(
|
224 |
-
add_image_size(
|
225 |
add_action( 'wp_head', array( &$this, 'custom_style_for_image_size' ) );
|
226 |
}
|
227 |
|
@@ -229,16 +254,16 @@ class RTMedia {
|
|
229 |
if ( apply_filters( 'rtmedia_custom_image_style', true ) ) {
|
230 |
?>
|
231 |
<style type="text/css">
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
</style>
|
243 |
<?php
|
244 |
}
|
@@ -247,13 +272,13 @@ class RTMedia {
|
|
247 |
function custom_style_for_activity_image_size() {
|
248 |
?>
|
249 |
.rtmedia-activity-container .media-type-photo .rtmedia-item-thumbnail {
|
250 |
-
max-width: <?php echo $this->options[
|
251 |
-
max-height: <?php echo $this->options[
|
252 |
overflow: hidden;
|
253 |
}
|
254 |
.rtmedia-activity-container .mejs-container.mejs-video{
|
255 |
-
min-height: <?php echo $this->options[
|
256 |
-
min-width: <?php echo $this->options[
|
257 |
}
|
258 |
<?php
|
259 |
}
|
@@ -261,32 +286,32 @@ class RTMedia {
|
|
261 |
function custom_style_for_gallery_image_size() {
|
262 |
?>
|
263 |
.rtmedia-container ul.rtmedia-list li.rtmedia-list-item div.rtmedia-item-thumbnail {
|
264 |
-
width: <?php echo $this->options[
|
265 |
-
height: <?php echo $this->options[
|
266 |
-
line-height: <?php echo $this->options[
|
267 |
}
|
268 |
.rtmedia-container ul.rtmedia-list li.rtmedia-list-item div.rtmedia-item-thumbnail img {
|
269 |
-
max-width: <?php echo $this->options[
|
270 |
-
max-height: <?php echo $this->options[
|
271 |
}
|
272 |
.rtmedia-container .rtmedia-list .rtmedia-list-item {
|
273 |
-
width: <?php echo intval( $this->options[
|
274 |
}
|
275 |
<?php
|
276 |
}
|
277 |
|
278 |
function custom_style_for_gallery_image_size_masonry() {
|
279 |
-
if ( intval( $this->options[
|
280 |
?>
|
281 |
.rtmedia-container .rtmedia-list .rtmedia-list-item .rtmedia-item-thumbnail {
|
282 |
-
max-height: <?php echo intval( $this->options[
|
283 |
}
|
284 |
<?php
|
285 |
}
|
286 |
-
if ( intval( $this->options[
|
287 |
?>
|
288 |
.rtmedia-container .rtmedia-list .rtmedia-list-item .rtmedia-item-thumbnail {
|
289 |
-
max-width: <?php echo intval( $this->options[
|
290 |
}
|
291 |
<?php
|
292 |
}
|
@@ -298,32 +323,32 @@ class RTMedia {
|
|
298 |
function set_allowed_types() {
|
299 |
$allowed_types = array(
|
300 |
'photo' => array(
|
301 |
-
'name'
|
302 |
-
'plural'
|
303 |
-
'label'
|
304 |
-
'plural_label'
|
305 |
-
'extn'
|
306 |
-
'thumbnail'
|
307 |
-
'settings_visibility' => true
|
308 |
),
|
309 |
'video' => array(
|
310 |
-
'name'
|
311 |
-
'plural'
|
312 |
-
'label'
|
313 |
-
'plural_label'
|
314 |
-
'extn'
|
315 |
-
'thumbnail'
|
316 |
-
'settings_visibility' => true
|
317 |
),
|
318 |
'music' => array(
|
319 |
-
'name'
|
320 |
-
'plural'
|
321 |
-
'label'
|
322 |
-
'plural_label'
|
323 |
-
'extn'
|
324 |
-
'thumbnail'
|
325 |
-
'settings_visibility' => true
|
326 |
-
)
|
327 |
);
|
328 |
|
329 |
// filter for hooking additional media types
|
@@ -340,36 +365,40 @@ class RTMedia {
|
|
340 |
* Sanitize all media sizes after hooking custom media types
|
341 |
*
|
342 |
* @param array $allowed_types allowed media types after hooking custom types
|
|
|
343 |
* @return array $allowed_types sanitized media types
|
344 |
*/
|
345 |
function sanitize_allowed_types( $allowed_types ) {
|
346 |
// check if the array is formatted properly
|
347 |
-
if ( ! is_array( $allowed_types ) && count( $allowed_types ) < 1 )
|
348 |
return;
|
|
|
349 |
|
350 |
//loop through each type
|
351 |
foreach ( $allowed_types as $key => &$type ) {
|
352 |
|
353 |
-
if ( ! isset( $type[
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
|
|
358 |
unset( $allowed_types[ $key ] ); // if not unset this type
|
359 |
continue;
|
360 |
}
|
361 |
-
$slug = strtoupper( $type[
|
362 |
-
if ( defined(
|
363 |
-
$type[
|
364 |
}
|
365 |
-
if ( defined(
|
366 |
-
$type[
|
367 |
}
|
368 |
// if thumbnail is not supplied, use the default thumbnail
|
369 |
-
if ( ! isset( $type[
|
370 |
-
$type[
|
371 |
}
|
372 |
}
|
|
|
373 |
return $allowed_types;
|
374 |
}
|
375 |
|
@@ -378,22 +407,22 @@ class RTMedia {
|
|
378 |
*/
|
379 |
function set_default_sizes() {
|
380 |
$this->default_sizes = array(
|
381 |
-
'photo'
|
382 |
'thumbnail' => array( 'width' => 150, 'height' => 150, 'crop' => 1 ),
|
383 |
-
'medium'
|
384 |
-
'large'
|
385 |
),
|
386 |
-
'video'
|
387 |
'activityPlayer' => array( 'width' => 320, 'height' => 240 ),
|
388 |
-
'singlePlayer'
|
389 |
),
|
390 |
-
'music'
|
391 |
'activityPlayer' => array( 'width' => 320 ),
|
392 |
-
'singlePlayer'
|
393 |
),
|
394 |
'featured' => array(
|
395 |
-
'default' => array( 'width' => 100, 'height' => 100, 'crop' => 1 )
|
396 |
-
)
|
397 |
);
|
398 |
|
399 |
$this->default_sizes = apply_filters( 'rtmedia_allowed_sizes', $this->default_sizes );
|
@@ -406,16 +435,16 @@ class RTMedia {
|
|
406 |
|
407 |
$this->privacy_settings = array(
|
408 |
'levels' => array(
|
409 |
-
60 =>
|
410 |
-
40 =>
|
411 |
-
20 =>
|
412 |
-
0
|
413 |
-
)
|
414 |
);
|
415 |
$this->privacy_settings = apply_filters( 'rtmedia_privacy_levels', $this->privacy_settings );
|
416 |
|
417 |
if ( function_exists( 'bp_is_active' ) && ! bp_is_active( 'friends' ) ) {
|
418 |
-
unset( $this->privacy_settings[
|
419 |
}
|
420 |
}
|
421 |
|
@@ -451,20 +480,22 @@ class RTMedia {
|
|
451 |
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
452 |
|
453 |
$group = 0;
|
454 |
-
if ( isset( $bp_media_options[
|
455 |
-
$group = $bp_media_options[
|
456 |
-
else if ( function_exists(
|
457 |
$group = bp_is_active( 'groups' );
|
458 |
-
|
|
|
459 |
|
460 |
$activity = 0;
|
461 |
-
if ( isset( $bp_media_options[
|
462 |
-
$activity = $bp_media_options[
|
463 |
-
else if ( function_exists(
|
464 |
$activity = bp_is_active( 'activity' );
|
465 |
-
|
|
|
466 |
|
467 |
-
$this->options[
|
468 |
|
469 |
/* Last settings updated in options. Update them in DB & after this no other option would be saved in db */
|
470 |
rtmedia_update_site_option( 'rtmedia-options', $this->options );
|
@@ -475,45 +506,47 @@ class RTMedia {
|
|
475 |
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
476 |
|
477 |
$defaults = array(
|
478 |
-
'general_enableAlbums'
|
479 |
-
'general_enableComments'
|
480 |
-
'general_downloadButton'
|
481 |
-
'general_enableLightbox'
|
482 |
-
'general_perPageMedia'
|
483 |
'general_enableMediaEndPoint' => 0,
|
484 |
-
'general_showAdminMenu'
|
485 |
-
'general_videothumbs'
|
486 |
-
'general_jpeg_image_quality'
|
487 |
-
'general_AllowUserData'
|
488 |
);
|
489 |
|
490 |
-
|
491 |
foreach ( $this->allowed_types as $type ) {
|
492 |
// invalid keys handled in sanitize method
|
493 |
-
$defaults[ 'allowedTypes_' . $type[
|
494 |
-
$defaults[ 'allowedTypes_' . $type[
|
495 |
}
|
496 |
|
497 |
/* Previous Sizes values from buddypress is migrated */
|
498 |
-
foreach ( $this->default_sizes as $type => $
|
499 |
-
foreach ( $
|
500 |
-
foreach ( $
|
501 |
switch ( $type ) {
|
502 |
case 'photo':
|
503 |
-
if ( isset( $bp_media_options[
|
504 |
-
$value = $bp_media_options[
|
|
|
505 |
break;
|
506 |
case 'video':
|
507 |
case 'music':
|
508 |
-
$old = (
|
509 |
switch ( $size ) {
|
510 |
case 'activityPlayer':
|
511 |
-
if ( isset( $bp_media_options[
|
512 |
-
$value = $bp_media_options[
|
|
|
513 |
break;
|
514 |
case 'singlePlayer':
|
515 |
-
if ( isset( $bp_media_options[
|
516 |
-
$value = $bp_media_options[
|
|
|
517 |
break;
|
518 |
}
|
519 |
break;
|
@@ -524,12 +557,12 @@ class RTMedia {
|
|
524 |
}
|
525 |
|
526 |
/* Privacy */
|
527 |
-
$defaults[
|
528 |
-
$defaults[
|
529 |
-
$defaults[
|
530 |
|
531 |
-
$defaults[
|
532 |
-
$defaults[
|
533 |
|
534 |
$this->options = $defaults;
|
535 |
|
@@ -543,97 +576,114 @@ class RTMedia {
|
|
543 |
public function constants() {
|
544 |
|
545 |
/* If the plugin is installed. */
|
546 |
-
if ( ! defined( 'RTMEDIA_IS_INSTALLED' ) )
|
547 |
define( 'RTMEDIA_IS_INSTALLED', 1 );
|
548 |
-
|
549 |
|
550 |
/* Required Version */
|
551 |
-
if ( ! defined( 'RTMEDIA_REQUIRED_BP' ) )
|
552 |
define( 'RTMEDIA_REQUIRED_BP', '1.7' );
|
553 |
-
|
554 |
|
555 |
/* Slug Constants for building urls */
|
556 |
|
557 |
/* Media slugs */
|
558 |
|
559 |
-
if ( ! defined( 'RTMEDIA_MEDIA_SLUG' ) )
|
560 |
define( 'RTMEDIA_MEDIA_SLUG', 'media' );
|
|
|
561 |
|
562 |
-
if ( ! defined( 'RTMEDIA_MEDIA_LABEL' ) )
|
563 |
-
define( 'RTMEDIA_MEDIA_LABEL',
|
|
|
564 |
|
565 |
-
if ( ! defined( 'RTMEDIA_ALL_SLUG' ) )
|
566 |
define( 'RTMEDIA_ALL_SLUG', 'all' );
|
|
|
567 |
|
568 |
-
if ( ! defined( 'RTMEDIA_ALL_LABEL' ) )
|
569 |
-
define( 'RTMEDIA_ALL_LABEL',
|
|
|
570 |
|
571 |
-
if ( ! defined( 'RTMEDIA_ALBUM_SLUG' ) )
|
572 |
define( 'RTMEDIA_ALBUM_SLUG', 'album' );
|
|
|
573 |
|
574 |
-
if ( ! defined( 'RTMEDIA_ALBUM_PLURAL_SLUG' ) )
|
575 |
define( 'RTMEDIA_ALBUM_PLURAL_SLUG', 'albums' );
|
|
|
576 |
|
577 |
-
if ( ! defined( 'RTMEDIA_ALBUM_LABEL' ) )
|
578 |
-
define( 'RTMEDIA_ALBUM_LABEL',
|
|
|
579 |
|
580 |
-
if ( ! defined( 'RTMEDIA_ALBUM_PLURAL_LABEL' ) )
|
581 |
-
define( 'RTMEDIA_ALBUM_PLURAL_LABEL',
|
|
|
582 |
|
583 |
/* Upload slug */
|
584 |
-
if ( ! defined( 'RTMEDIA_UPLOAD_SLUG' ) )
|
585 |
define( 'RTMEDIA_UPLOAD_SLUG', 'upload' );
|
|
|
586 |
|
587 |
/* Upload slug */
|
588 |
-
if ( ! defined( 'RTMEDIA_UPLOAD_LABEL' ) )
|
589 |
-
define( 'RTMEDIA_UPLOAD_LABEL',
|
|
|
590 |
|
591 |
/* Global Album/Wall Post */
|
592 |
-
if ( ! defined( 'RTMEDIA_GLOBAL_ALBUM_LABEL' ) )
|
593 |
-
define( 'RTMEDIA_GLOBAL_ALBUM_LABEL',
|
|
|
594 |
|
595 |
$this->define_type_constants();
|
596 |
}
|
597 |
|
598 |
function define_type_constants() {
|
599 |
|
600 |
-
if ( ! isset( $this->allowed_types ) )
|
601 |
return;
|
|
|
602 |
foreach ( $this->allowed_types as $type ) {
|
603 |
|
604 |
-
if ( ! isset( $type[
|
605 |
continue;
|
|
|
606 |
|
607 |
-
$name = $type[
|
608 |
|
609 |
-
if ( isset( $type[
|
610 |
-
$plural = $type[
|
611 |
} else {
|
612 |
$plural = $name . 's';
|
613 |
}
|
614 |
|
615 |
-
if ( isset( $type[
|
616 |
-
$label = $type[
|
617 |
} else {
|
618 |
$label = ucfirst( $name );
|
619 |
}
|
620 |
|
621 |
-
if ( isset( $type[
|
622 |
-
$label_plural = $type[
|
623 |
} else {
|
624 |
$label_plural = ucfirst( $plural );
|
625 |
}
|
626 |
|
627 |
$slug = strtoupper( $name );
|
628 |
|
629 |
-
if ( ! defined( 'RTMEDIA_' . $slug . '_SLUG' ) )
|
630 |
define( 'RTMEDIA_' . $slug . '_SLUG', $name );
|
631 |
-
|
|
|
632 |
define( 'RTMEDIA_' . $slug . '_PLURAL_SLUG', $plural );
|
633 |
-
|
|
|
634 |
define( 'RTMEDIA_' . $slug . '_LABEL', $label );
|
635 |
-
|
|
|
636 |
define( 'RTMEDIA_' . $slug . '_PLURAL_LABEL', $label_plural );
|
|
|
637 |
}
|
638 |
}
|
639 |
|
@@ -672,12 +722,6 @@ class RTMedia {
|
|
672 |
*/
|
673 |
$this->set_site_options();
|
674 |
|
675 |
-
|
676 |
-
/**
|
677 |
-
* Add a settings link to the Plugin list screen
|
678 |
-
*/
|
679 |
-
// add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
|
680 |
-
|
681 |
/**
|
682 |
* BuddyPress - Media Navigation Tab Inject
|
683 |
*
|
@@ -685,23 +729,23 @@ class RTMedia {
|
|
685 |
/**
|
686 |
* Load accessory functions
|
687 |
*/
|
688 |
-
|
689 |
$class_construct = array(
|
690 |
-
'deprecated'
|
691 |
-
'interaction'
|
692 |
-
'upload_shortcode'
|
693 |
-
'gallery_shortcode'
|
694 |
-
'upload_endpoint'
|
695 |
-
'privacy'
|
696 |
-
'nav'
|
697 |
-
'like'
|
698 |
-
'featured'
|
699 |
-
'GroupFeatured'
|
700 |
-
'ViewCount'
|
701 |
-
'GalleryItemAction'
|
702 |
-
|
703 |
'CommentNotification' => false,
|
704 |
-
'LikeNotification'
|
705 |
);
|
706 |
global $rtmedia_nav;
|
707 |
|
@@ -710,7 +754,7 @@ class RTMedia {
|
|
710 |
foreach ( $bp_class_construct as $classname => $global_scope ) {
|
711 |
$class = 'BPMedia' . ucfirst( $classname );
|
712 |
if ( class_exists( $class ) ) {
|
713 |
-
if ( $global_scope
|
714 |
global ${'bp_media_' . $classname};
|
715 |
${'bp_media_' . $classname} = new $class();
|
716 |
} else {
|
@@ -721,11 +765,11 @@ class RTMedia {
|
|
721 |
/** ------------------- * */
|
722 |
$class_construct = apply_filters( 'rtmedia_class_construct', $class_construct );
|
723 |
|
724 |
-
$class_construct[
|
725 |
|
726 |
foreach ( $class_construct as $key => $global_scope ) {
|
727 |
$classname = '';
|
728 |
-
$ck
|
729 |
|
730 |
foreach ( $ck as $cn ) {
|
731 |
$classname .= ucfirst( $cn );
|
@@ -734,7 +778,7 @@ class RTMedia {
|
|
734 |
$class = 'RTMedia' . $classname;
|
735 |
|
736 |
if ( class_exists( $class ) ) {
|
737 |
-
if ( $global_scope
|
738 |
global ${'rtmedia_' . $key};
|
739 |
${'rtmedia_' . $key} = new $class();
|
740 |
} else {
|
@@ -747,10 +791,9 @@ class RTMedia {
|
|
747 |
|
748 |
global $rtmedia_buddypress_activity;
|
749 |
$rtmedia_buddypress_activity = new RTMediaBuddyPressActivity();
|
750 |
-
$media
|
751 |
$media->delete_hook();
|
752 |
|
753 |
-
|
754 |
global $rtmedia_ajax;
|
755 |
$rtmedia_ajax = new RTMediaAJAX();
|
756 |
//API Classes
|
@@ -763,81 +806,88 @@ class RTMedia {
|
|
763 |
|
764 |
function set_rtmedia_meta_wpdbfix() {
|
765 |
global $wpdb;
|
766 |
-
$media_meta
|
767 |
$wpdb->mediameta = $media_meta->model->table_name;
|
768 |
}
|
769 |
|
770 |
function redirect_on_change_slug() {
|
771 |
-
$old_slugs
|
772 |
-
$current_slugs = rtmedia_get_site_option(
|
773 |
-
if (
|
774 |
-
rtmedia_update_site_option(
|
|
|
775 |
return;
|
776 |
}
|
777 |
-
if (
|
778 |
return;
|
779 |
-
|
|
|
780 |
$old_slugs = array();
|
|
|
781 |
$old_slugs[] = $current_slugs;
|
782 |
-
rtmedia_update_site_option(
|
783 |
}
|
784 |
|
785 |
/**
|
786 |
* Loads translations
|
787 |
*/
|
788 |
static
|
789 |
-
|
790 |
load_plugin_textdomain( 'buddypress-media', false, basename( RTMEDIA_PATH ) . '/languages/' );
|
791 |
}
|
792 |
|
793 |
function check_global_album() {
|
794 |
-
|
|
|
795 |
$global_album = $album->get_default();
|
|
|
796 |
//** Hack for plupload default name
|
797 |
-
if ( isset( $_POST[
|
798 |
-
unset( $_POST[
|
799 |
-
}
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
|
|
820 |
|
821 |
function default_count() {
|
822 |
$count = $this->posts_per_page;
|
823 |
if ( array_key_exists( 'default_count', $this->options ) ) {
|
824 |
-
$count = $this->options[
|
825 |
}
|
826 |
-
$count = ( ! is_int( $count )) ? 0 : $count;
|
827 |
-
|
|
|
828 |
}
|
829 |
|
830 |
-
static
|
831 |
-
|
832 |
-
|
833 |
-
$
|
834 |
-
$
|
835 |
-
|
836 |
return $plugin_version;
|
837 |
}
|
838 |
|
839 |
function update_db() {
|
840 |
-
$update = new RTDBUpdate( false, RTMEDIA_PATH .
|
841 |
/* Current Version. */
|
842 |
if ( ! defined( 'RTMEDIA_VERSION' ) ) {
|
843 |
define( 'RTMEDIA_VERSION', $update->db_version );
|
@@ -845,9 +895,9 @@ class RTMedia {
|
|
845 |
if ( $update->check_upgrade() ) {
|
846 |
$update->do_upgrade();
|
847 |
}
|
848 |
-
if ( ! $update->table_exists( $update->genrate_table_name(
|
849 |
delete_site_option( $update->get_db_version_option_name() );
|
850 |
-
$update->install_db_version =
|
851 |
$update->do_upgrade();
|
852 |
}
|
853 |
}
|
@@ -855,7 +905,7 @@ class RTMedia {
|
|
855 |
function create_table_error_notice() {
|
856 |
global $rtmedia_error;
|
857 |
$rtmedia_error = true;
|
858 |
-
echo "<div class='error'><p><strong>rtMedia</strong>
|
859 |
}
|
860 |
|
861 |
function enqueue_scripts_styles() {
|
@@ -869,94 +919,97 @@ class RTMedia {
|
|
869 |
wp_enqueue_script( 'wp-mediaelement-start', RTMEDIA_URL . 'lib/media-element/wp-mediaelement.js', 'wp-mediaelement', RTMEDIA_VERSION, true );
|
870 |
}
|
871 |
|
872 |
-
|
873 |
// Dashicons: Needs if not loaded by WP
|
874 |
wp_enqueue_style( 'dashicons' );
|
875 |
|
876 |
// Dont enqueue rtmedia.min.css if default styles is checked false in rtmedia settings
|
877 |
$suffix = ( function_exists( 'rtm_get_script_style_suffix' ) ) ? rtm_get_script_style_suffix() : '.min';
|
878 |
|
879 |
-
if ( ! ( isset( $rtmedia->options ) && isset( $rtmedia->options[
|
880 |
wp_enqueue_style( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/rtmedia' . $suffix . '.css', '', RTMEDIA_VERSION );
|
881 |
}
|
882 |
|
883 |
-
if(
|
884 |
-
wp_enqueue_script( 'rtmedia-magnific-popup', RTMEDIA_URL . 'app/assets/js/vendors/magnific-popup.js', array(
|
885 |
-
|
886 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
} else {
|
888 |
-
wp_enqueue_script( 'rtmedia-main', RTMEDIA_URL . 'app/assets/js/rtmedia.min.js', array(
|
|
|
|
|
|
|
889 |
}
|
890 |
|
891 |
wp_localize_script( 'rtmedia-main', 'rtmedia_ajax_url', admin_url( 'admin-ajax.php' ) );
|
892 |
wp_localize_script( 'rtmedia-main', 'rtmedia_media_slug', RTMEDIA_MEDIA_SLUG );
|
893 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_lightbox_enabled', strval( $this->options[
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
//gallery reload after media upload, by default true
|
899 |
wp_localize_script( 'rtmedia-main', 'rtmedia_gallery_reload_on_upload', '1' );
|
900 |
|
901 |
//javascript messages
|
902 |
-
wp_localize_script( 'rtmedia-magnific', 'rtmedia_load_more',
|
903 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_empty_activity_msg',
|
904 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_empty_comment_msg',
|
905 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_media_delete_confirmation',
|
906 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_media_comment_delete_confirmation',
|
907 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_album_delete_confirmation',
|
908 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_drop_media_msg',
|
909 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_album_created_msg', ' ' .
|
910 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_something_wrong_msg',
|
911 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_empty_album_name_msg',
|
912 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_max_file_msg',
|
913 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_allowed_file_formats',
|
914 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_select_all_visible',
|
915 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_unselect_all_visible',
|
916 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_no_media_selected',
|
917 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_selected_media_delete_confirmation',
|
918 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_selected_media_move_confirmation',
|
919 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_waiting_msg',
|
920 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_uploaded_msg',
|
921 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_uploading_msg',
|
922 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_upload_failed_msg',
|
923 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_close',
|
924 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_edit',
|
925 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_delete',
|
926 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_edit_media',
|
927 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_remove_from_queue',
|
928 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_add_more_files_msg',
|
929 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_file_extension_error_msg',
|
930 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_more',
|
931 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_less',
|
932 |
-
wp_localize_script( 'rtmedia-main', 'rtmedia_delete_uploaded_media',
|
933 |
wp_localize_script( 'rtmedia-main', 'rtm_wp_version', get_bloginfo( 'version' ) );
|
934 |
-
wp_localize_script( 'rtmedia-backbone', 'rMedia_loading_media', RTMEDIA_URL .
|
935 |
$rtmedia_media_thumbs = array();
|
936 |
foreach ( $this->allowed_types as $key_type => $value_type ) {
|
937 |
-
$rtmedia_media_thumbs[ $key_type ] = $value_type[
|
938 |
}
|
939 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_media_thumbs', $rtmedia_media_thumbs );
|
940 |
-
wp_localize_script( 'rtmedia-backbone', 'rtmedia_set_featured_image_msg',
|
941 |
-
wp_localize_script( 'rtmedia-backbone', 'rtmedia_unset_featured_image_msg',
|
942 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_edit_media_info_upload', array(
|
943 |
-
'title'
|
944 |
-
'description' =>
|
945 |
) );
|
946 |
|
947 |
-
// We are not using it anymore and hence commenting
|
948 |
-
// global $rtmedia_query;
|
949 |
-
// if( class_exists('BuddyPress') ) {
|
950 |
-
// $rtmedia_user_domain = trailingslashit ( bp_displayed_user_domain() . constant('RTMEDIA_MEDIA_SLUG') );
|
951 |
-
// } else {
|
952 |
-
// $rtmedia_user_domain = trailingslashit( trailingslashit( get_author_posts_url($rtmedia_query->query['context_id'] ) ). constant('RTMEDIA_MEDIA_SLUG') );
|
953 |
-
// }
|
954 |
-
// wp_localize_script ( 'rtmedia-backbone', 'rtmedia_user_domain', $rtmedia_user_domain );
|
955 |
// Enqueue touchswipe
|
956 |
wp_enqueue_script( 'rtmedia-touchswipe', RTMEDIA_URL . 'lib/touchswipe/jquery.touchSwipe.min.js', array( 'jquery' ), RTMEDIA_VERSION, true );
|
957 |
|
958 |
-
if ( isset( $rtmedia->options ) && isset( $rtmedia->options[
|
959 |
-
if ( wp_script_is(
|
960 |
wp_enqueue_style( 'jquery-masonry' );
|
961 |
wp_enqueue_script( 'jquery-masonry' );
|
962 |
wp_localize_script( 'rtmedia-main', 'rtmedia_masonry_layout', 'true' );
|
@@ -967,63 +1020,63 @@ class RTMedia {
|
|
967 |
wp_localize_script( 'rtmedia-main', 'rtmedia_masonry_layout', 'false' );
|
968 |
}
|
969 |
|
970 |
-
if ( isset( $rtmedia->options[
|
971 |
-
wp_localize_script( 'rtmedia-backbone', 'rtmedia_load_more_or_pagination', (
|
972 |
} else {
|
973 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_load_more_or_pagination', 'load_more' );
|
974 |
}
|
975 |
|
976 |
-
if ( isset( $rtmedia->options[
|
977 |
-
wp_localize_script( 'rtmedia-backbone', 'rtmedia_bp_enable_activity', (
|
978 |
} else {
|
979 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_bp_enable_activity', '0' );
|
980 |
}
|
981 |
|
982 |
-
wp_localize_script( 'rtmedia-backbone', 'rtmedia_upload_progress_error_message',
|
983 |
|
984 |
// localise media size config
|
985 |
$media_size_config = array(
|
986 |
-
'photo'
|
987 |
-
'thumb'
|
988 |
-
'width'
|
989 |
-
'height' => $rtmedia->options[
|
990 |
-
'crop'
|
991 |
),
|
992 |
'medium' => array(
|
993 |
-
'width'
|
994 |
-
'height' => $rtmedia->options[
|
995 |
-
'crop'
|
996 |
),
|
997 |
-
'large'
|
998 |
-
'width'
|
999 |
-
'height' => $rtmedia->options[
|
1000 |
-
'crop'
|
1001 |
),
|
1002 |
),
|
1003 |
-
'video'
|
1004 |
'activity_media' => array(
|
1005 |
-
'width'
|
1006 |
-
'height' => $rtmedia->options[
|
1007 |
),
|
1008 |
-
'single_media'
|
1009 |
-
'width'
|
1010 |
-
'height' => $rtmedia->options[
|
1011 |
),
|
1012 |
),
|
1013 |
-
'music'
|
1014 |
'activity_media' => array(
|
1015 |
-
'width' => $rtmedia->options[
|
1016 |
),
|
1017 |
-
'single_media'
|
1018 |
-
'width' => $rtmedia->options[
|
1019 |
),
|
1020 |
),
|
1021 |
'featured' => array(
|
1022 |
'default' => array(
|
1023 |
-
'width'
|
1024 |
-
'height' => $rtmedia->options[
|
1025 |
-
'crop'
|
1026 |
-
)
|
1027 |
),
|
1028 |
);
|
1029 |
wp_localize_script( 'rtmedia-main', 'rtmedia_media_size_config', $media_size_config );
|
@@ -1034,9 +1087,10 @@ class RTMedia {
|
|
1034 |
remove_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
|
1035 |
}
|
1036 |
|
|
|
1037 |
function set_friends_object() {
|
1038 |
if ( is_user_logged_in() ) {
|
1039 |
-
$user
|
1040 |
$friends = friends_get_friend_user_ids( $user );
|
1041 |
} else {
|
1042 |
$user = 0;
|
@@ -1044,43 +1098,48 @@ class RTMedia {
|
|
1044 |
}
|
1045 |
|
1046 |
function filter_image_sizes_details( $sizes ) {
|
1047 |
-
if ( isset( $_REQUEST[
|
1048 |
$sizes = $this->unset_bp_media_image_sizes_details( $sizes );
|
1049 |
-
} elseif ( isset( $_REQUEST[
|
1050 |
-
$model
|
1051 |
-
$result = $model->get( array( 'media_id' => $_REQUEST[
|
1052 |
if ( ! empty( $result ) ) {
|
1053 |
$bp_media_sizes = $this->image_sizes();
|
1054 |
-
$sizes
|
1055 |
-
'rt_media_thumbnail'
|
1056 |
-
'rt_media_activity_image' => $bp_media_sizes[
|
1057 |
-
'rt_media_single_image'
|
1058 |
-
'rt_media_featured_image' => $bp_media_sizes[
|
1059 |
);
|
1060 |
} else {
|
1061 |
$sizes = $this->unset_bp_media_image_sizes_details( $sizes );
|
1062 |
}
|
1063 |
}
|
|
|
1064 |
return $sizes;
|
1065 |
}
|
1066 |
|
1067 |
function rtmedia_custom_image_sizes_choose( $sizes ) {
|
1068 |
$custom_sizes = array(
|
1069 |
-
'rt_media_thumbnail'
|
1070 |
-
'rt_media_activity_image' =>
|
1071 |
-
'rt_media_single_image'
|
1072 |
-
'rt_media_featured_image' =>
|
1073 |
);
|
|
|
1074 |
return array_merge( $sizes, $custom_sizes );
|
1075 |
}
|
1076 |
|
1077 |
function filter_image_sizes( $sizes ) {
|
1078 |
-
if ( isset( $_REQUEST[
|
1079 |
-
if ( $parent_id = get_post_field( 'post_parent', $_REQUEST[
|
1080 |
$post_type = get_post_field( 'post_type', $parent_id );
|
1081 |
-
if (
|
1082 |
$sizes = array(
|
1083 |
-
'rt_media_thumbnail',
|
|
|
|
|
|
|
1084 |
);
|
1085 |
} else {
|
1086 |
$sizes = $this->unset_bp_media_image_sizes( $sizes );
|
@@ -1094,36 +1153,45 @@ class RTMedia {
|
|
1094 |
}
|
1095 |
|
1096 |
function unset_bp_media_image_sizes_details( $sizes ) {
|
1097 |
-
if ( isset( $sizes[
|
1098 |
-
unset( $sizes[
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
if ( isset( $sizes[
|
1104 |
-
unset( $sizes[
|
|
|
|
|
|
|
|
|
|
|
1105 |
return $sizes;
|
1106 |
}
|
1107 |
|
1108 |
function unset_bp_media_image_sizes( $sizes ) {
|
1109 |
-
if ( ($key = array_search( 'rt_media_thumbnail', $sizes )) !== false )
|
1110 |
unset( $sizes[ $key ] );
|
1111 |
-
|
|
|
1112 |
unset( $sizes[ $key ] );
|
1113 |
-
|
|
|
1114 |
unset( $sizes[ $key ] );
|
1115 |
-
|
|
|
1116 |
unset( $sizes[ $key ] );
|
|
|
|
|
1117 |
return $sizes;
|
1118 |
}
|
1119 |
-
|
1120 |
}
|
1121 |
|
1122 |
function parentlink_global_album( $id ) {
|
1123 |
$global_albums = RTMediaAlbum::get_globals();
|
1124 |
-
$parent_link
|
1125 |
-
if ( is_array( $global_albums ) && $global_albums
|
1126 |
-
if ( in_array( $id, $global_albums ) && function_exists(
|
1127 |
$disp_user = bp_displayed_user_id();
|
1128 |
$curr_user = get_current_user_id();
|
1129 |
if ( $disp_user == $curr_user ) {
|
@@ -1132,40 +1200,41 @@ function parentlink_global_album( $id ) {
|
|
1132 |
$parent_link = get_rtmedia_user_link( $disp_user );
|
1133 |
}
|
1134 |
global $rtmedia_query;
|
1135 |
-
if ( isset( $rtmedia_query->is_gallery_shortcode ) && $rtmedia_query->is_gallery_shortcode
|
1136 |
$parent_link = get_rtmedia_user_link( get_current_user_id() );
|
1137 |
}
|
1138 |
}
|
1139 |
}
|
|
|
1140 |
return $parent_link;
|
1141 |
}
|
1142 |
|
1143 |
function get_rtmedia_permalink( $id ) {
|
1144 |
-
$
|
1145 |
-
$media
|
1146 |
global $rtmedia_query;
|
1147 |
|
1148 |
// Adding filter to get permalink for current blog
|
1149 |
add_filter( 'bp_get_root_domain', 'rtmedia_get_current_blog_url' );
|
1150 |
|
1151 |
-
if ( ! isset( $media[
|
1152 |
-
if ( function_exists(
|
1153 |
-
$parent_link = get_rtmedia_group_link( $rtmedia_query->query[
|
1154 |
} else {
|
1155 |
// check for global album
|
1156 |
$parent_link = parentlink_global_album( $id );
|
1157 |
-
if ( $parent_link
|
1158 |
-
$parent_link = get_rtmedia_user_link( $media[
|
1159 |
}
|
1160 |
}
|
1161 |
} else {
|
1162 |
-
if ( function_exists(
|
1163 |
-
$parent_link = get_rtmedia_group_link( $media[
|
1164 |
} else {
|
1165 |
// check for global album
|
1166 |
$parent_link = parentlink_global_album( $id );
|
1167 |
-
if ( $parent_link
|
1168 |
-
$parent_link = get_rtmedia_user_link( $media[
|
1169 |
}
|
1170 |
}
|
1171 |
}
|
@@ -1184,6 +1253,7 @@ function get_rtmedia_user_link( $id ) {
|
|
1184 |
} else {
|
1185 |
$parent_link = get_author_posts_url( $id );
|
1186 |
}
|
|
|
1187 |
return $parent_link;
|
1188 |
}
|
1189 |
|
@@ -1197,16 +1267,17 @@ function rtmedia_update_site_option( $option_name, $option_value ) {
|
|
1197 |
|
1198 |
function get_rtmedia_group_link( $group_id ) {
|
1199 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
|
|
1200 |
return apply_filters( 'rtmedia_get_group_link', bp_get_group_permalink( $group ) );
|
1201 |
}
|
1202 |
|
1203 |
function rtmedia_get_site_option( $option_name, $default = false ) {
|
1204 |
if ( is_multisite() ) {
|
1205 |
$return_val = get_option( $option_name, $default );
|
1206 |
-
if (
|
1207 |
$return_val = get_site_option( $option_name, $default );
|
1208 |
-
if (
|
1209 |
-
if ( function_exists(
|
1210 |
$return_val = bp_get_option( $option_name, $default );
|
1211 |
}
|
1212 |
}
|
@@ -1214,16 +1285,17 @@ function rtmedia_get_site_option( $option_name, $default = false ) {
|
|
1214 |
}
|
1215 |
} else {
|
1216 |
$return_val = get_site_option( $option_name, $default );
|
1217 |
-
if (
|
1218 |
-
if ( function_exists(
|
1219 |
$return_val = bp_get_option( $option_name, $default );
|
1220 |
rtmedia_update_site_option( $option_name, $return_val );
|
1221 |
}
|
1222 |
}
|
1223 |
}
|
1224 |
-
if ( $default
|
1225 |
$return_val = $default;
|
1226 |
}
|
|
|
1227 |
return $return_val;
|
1228 |
}
|
1229 |
|
@@ -1238,4 +1310,3 @@ function rtmedia_get_site_option( $option_name, $default = false ) {
|
|
1238 |
* using 'bpmedia_excerpt_lengths' hook
|
1239 |
*
|
1240 |
*/
|
1241 |
-
|
43 |
* @var object default application wide privacy levels
|
44 |
*/
|
45 |
public $default_privacy = array(
|
46 |
+
'0' => 'Public',
|
47 |
'20' => 'Users',
|
48 |
'40' => 'Friends',
|
49 |
+
'60' => 'Private',
|
50 |
);
|
51 |
|
52 |
/**
|
68 |
public $activity_types = array(
|
69 |
'media_upload',
|
70 |
'album_updated',
|
71 |
+
'album_created',
|
72 |
);
|
73 |
public $options;
|
74 |
public $render_options;
|
89 |
add_action( 'plugins_loaded', array( $this, 'init' ), 20 );
|
90 |
add_action( 'wp_enqueue_scripts', array( 'RTMediaGalleryShortcode', 'register_scripts' ) );
|
91 |
add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts_styles' ), 999 );
|
92 |
+
include( RTMEDIA_PATH . 'app/main/controllers/template/rt-template-functions.php' );
|
93 |
add_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_details' ) );
|
94 |
add_filter( 'intermediate_image_sizes', array( $this, 'filter_image_sizes' ) );
|
95 |
+
add_filter( 'site_option_upload_filetypes', array( &$this, 'filter_allow_mime_type_mu' ), 1, 1 );
|
96 |
add_filter( 'image_size_names_choose', array( $this, 'rtmedia_custom_image_sizes_choose' ) );
|
97 |
}
|
98 |
|
99 |
function filter_allow_mime_type_mu( $options ) {
|
100 |
+
$allowed_types = array();
|
101 |
$this->allowed_types = apply_filters( 'rtmedia_allowed_types', $this->allowed_types );
|
102 |
foreach ( $this->allowed_types as $type ) {
|
103 |
+
if ( '' !== $type['extn'] && call_user_func( 'is_rtmedia_upload_' . $type['name'] . '_enabled' ) ) {
|
104 |
+
foreach ( $type['extn'] as $extn ) {
|
105 |
$allowed_types[] = $extn;
|
106 |
}
|
107 |
}
|
108 |
}
|
109 |
+
$ext = apply_filters( 'rtmedia_plupload_files_filter', array(
|
110 |
+
array(
|
111 |
+
'title' => 'Media Files',
|
112 |
+
'extensions' => implode( ',', $allowed_types ),
|
113 |
+
),
|
114 |
+
) );
|
115 |
+
$ext_arr = explode( ',', $ext[0]['extensions'] );
|
116 |
$options = trim( $options );
|
117 |
foreach ( $ext_arr as $f_ext ) {
|
118 |
if ( $f_ext && strpos( $options, $f_ext ) === false ) {
|
119 |
+
$options .= ' ' . $f_ext;
|
120 |
}
|
121 |
}
|
122 |
+
|
123 |
return $options;
|
124 |
}
|
125 |
|
126 |
function fix_parent_id() {
|
127 |
$site_global = rtmedia_get_site_option( 'rtmedia-global-albums' );
|
128 |
+
if ( $site_global && is_array( $site_global ) && isset( $site_global[0] ) ) {
|
129 |
+
$model = new RTMediaModel();
|
130 |
+
$album_row = $model->get_by_id( $site_global[0] );
|
131 |
+
if ( isset( $album_row['result'] ) && count( $album_row['result'] ) > 0 ) {
|
132 |
global $wpdb;
|
133 |
+
$row = $album_row['result'][0];
|
134 |
+
if ( isset( $row['media_id'] ) ) {
|
135 |
+
// @codingStandardsIgnoreStart
|
136 |
+
$sql = $wpdb->prepare( "update $wpdb->posts p
|
137 |
left join
|
138 |
+
$model->table_name r ON ( p.ID = r.media_id and blog_id = %d )
|
139 |
set
|
140 |
+
post_parent = %d
|
141 |
where
|
142 |
+
p.guid like %s
|
143 |
and (p.post_parent = 0 or p.post_parent is NULL)
|
144 |
and not r.id is NULL
|
145 |
+
and r.media_type <> 'album'", get_current_blog_id(), $row['media_id'], '%/rtMedia/%' );
|
146 |
$wpdb->query( $sql );
|
147 |
+
// @codingStandardsIgnoreEnd
|
148 |
}
|
149 |
}
|
150 |
}
|
152 |
|
153 |
function fix_privacy() {
|
154 |
global $wpdb;
|
155 |
+
$model = new RTMediaModel();
|
156 |
+
$update_sql = "UPDATE {$model->table_name} SET privacy = '80' where privacy = '-1' ";
|
157 |
+
$wpdb->query( $update_sql ); // @codingStandardsIgnoreLine
|
158 |
}
|
159 |
|
160 |
/*
|
166 |
//if buddypress is active and groups are enabled
|
167 |
global $wpdb;
|
168 |
$table_exist = false;
|
169 |
+
if ( $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}bp_groups'" ) ) {
|
170 |
$table_exist = true;
|
171 |
}
|
172 |
if ( class_exists( 'BuddyPress' ) && $table_exist ) {
|
173 |
+
$model = new RTMediaModel();
|
174 |
$sql_group = " UPDATE $model->table_name m join {$wpdb->prefix}bp_groups bp on m.context_id = bp.id SET m.privacy = 0 where m.context = 'group' and bp.status = 'public' and m.privacy <> 80 ";
|
175 |
+
$wpdb->query( $wpdb->prepare( $sql_group ) ); // @codingStandardsIgnoreLine
|
176 |
$sql_group = " UPDATE $model->table_name m join {$wpdb->prefix}bp_groups bp on m.context_id = bp.id SET m.privacy = 20 where m.context = 'group' and ( bp.status = 'private' OR bp.status = 'hidden' ) and m.privacy <> 80 ";
|
177 |
+
$wpdb->query( $wpdb->prepare( $sql_group ) ); // @codingStandardsIgnoreLine
|
178 |
}
|
179 |
}
|
180 |
|
181 |
function fix_db_collation() {
|
182 |
global $wpdb;
|
183 |
+
$model = new RTMediaModel();
|
184 |
$interaction_model = new RTMediaInteractionModel();
|
185 |
+
$update_media_sql = 'ALTER TABLE ' . $model->table_name . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci';
|
186 |
+
$wpdb->query( $update_media_sql ); // @codingStandardsIgnoreLine
|
187 |
+
$update_media_meta_sql = 'ALTER TABLE ' . $wpdb->base_prefix . $model->meta_table_name . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci';
|
188 |
+
$wpdb->query( $update_media_meta_sql ); // @codingStandardsIgnoreLine
|
189 |
+
$update_media_interaction_sql = 'ALTER TABLE ' . $interaction_model->table_name . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci';
|
190 |
+
$wpdb->query( $update_media_interaction_sql ); // @codingStandardsIgnoreLine
|
191 |
}
|
192 |
|
193 |
function set_site_options() {
|
194 |
|
195 |
+
$rtmedia_options = rtmedia_get_site_option( 'rtmedia-options' );
|
196 |
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
197 |
|
198 |
+
if ( false === $rtmedia_options ) {
|
199 |
$this->init_site_options();
|
200 |
} else {
|
201 |
/* if new options added via filter then it needs to be updated */
|
210 |
}
|
211 |
|
212 |
public function rtmedia_jpeg_quality( $quality ) {
|
213 |
+
$quality = isset( $this->options['general_jpeg_image_quality'] ) ? $this->options['general_jpeg_image_quality'] : 90;
|
214 |
|
215 |
return $quality;
|
216 |
}
|
217 |
|
218 |
public function image_sizes() {
|
219 |
+
$image_sizes = array();
|
220 |
+
$image_sizes['thumbnail'] = array(
|
221 |
+
'width' => $this->options['defaultSizes_photo_thumbnail_width'],
|
222 |
+
'height' => $this->options['defaultSizes_photo_thumbnail_height'],
|
223 |
+
'crop' => ( 0 === intval( $this->options['defaultSizes_photo_thumbnail_crop'] ) ) ? false : true,
|
224 |
+
);
|
225 |
+
$image_sizes['activity'] = array(
|
226 |
+
'width' => $this->options['defaultSizes_photo_medium_width'],
|
227 |
+
'height' => $this->options['defaultSizes_photo_medium_height'],
|
228 |
+
'crop' => ( 0 === intval( $this->options['defaultSizes_photo_medium_crop'] ) ) ? false : true,
|
229 |
+
);
|
230 |
+
$image_sizes['single'] = array(
|
231 |
+
'width' => $this->options['defaultSizes_photo_large_width'],
|
232 |
+
'height' => $this->options['defaultSizes_photo_large_height'],
|
233 |
+
'crop' => ( 0 === intval( $this->options['defaultSizes_photo_large_crop'] ) ) ? false : true,
|
234 |
+
);
|
235 |
+
$image_sizes['featured'] = array(
|
236 |
+
'width' => $this->options['defaultSizes_featured_default_width'],
|
237 |
+
'height' => $this->options['defaultSizes_featured_default_height'],
|
238 |
+
'crop' => ( 0 === intval( $this->options['defaultSizes_featured_default_crop'] ) ) ? false : true,
|
239 |
+
);
|
240 |
+
|
241 |
return $image_sizes;
|
242 |
}
|
243 |
|
244 |
public function add_image_sizes() {
|
245 |
$bp_media_sizes = $this->image_sizes();
|
246 |
+
add_image_size( 'rt_media_thumbnail', $bp_media_sizes['thumbnail']['width'], $bp_media_sizes['thumbnail']['height'], $bp_media_sizes['thumbnail']['crop'] );
|
247 |
+
add_image_size( 'rt_media_activity_image', $bp_media_sizes['activity']['width'], $bp_media_sizes['activity']['height'], $bp_media_sizes['activity']['crop'] );
|
248 |
+
add_image_size( 'rt_media_single_image', $bp_media_sizes['single']['width'], $bp_media_sizes['single']['height'], $bp_media_sizes['single']['crop'] );
|
249 |
+
add_image_size( 'rt_media_featured_image', $bp_media_sizes['featured']['width'], $bp_media_sizes['featured']['height'], $bp_media_sizes['featured']['crop'] );
|
250 |
add_action( 'wp_head', array( &$this, 'custom_style_for_image_size' ) );
|
251 |
}
|
252 |
|
254 |
if ( apply_filters( 'rtmedia_custom_image_style', true ) ) {
|
255 |
?>
|
256 |
<style type="text/css">
|
257 |
+
<?php
|
258 |
+
$this->custom_style_for_activity_image_size();
|
259 |
+
global $rtmedia;
|
260 |
+
if ( isset( $rtmedia->options['general_masonry_layout'] ) && 1 === intval( $rtmedia->options['general_masonry_layout'] ) ) {
|
261 |
+
$this->custom_style_for_gallery_image_size_masonry();
|
262 |
+
} else {
|
263 |
+
$this->custom_style_for_gallery_image_size();
|
264 |
+
}
|
265 |
+
do_action( 'rtmedia_custom_styles' );
|
266 |
+
?>
|
267 |
</style>
|
268 |
<?php
|
269 |
}
|
272 |
function custom_style_for_activity_image_size() {
|
273 |
?>
|
274 |
.rtmedia-activity-container .media-type-photo .rtmedia-item-thumbnail {
|
275 |
+
max-width: <?php echo esc_attr( $this->options['defaultSizes_photo_medium_width'] ); ?>px;
|
276 |
+
max-height: <?php echo esc_attr( $this->options['defaultSizes_photo_medium_height'] ); ?>px;
|
277 |
overflow: hidden;
|
278 |
}
|
279 |
.rtmedia-activity-container .mejs-container.mejs-video{
|
280 |
+
min-height: <?php echo esc_attr( $this->options['defaultSizes_video_activityPlayer_height'] ); ?>px;
|
281 |
+
min-width: <?php echo esc_attr( $this->options['defaultSizes_video_activityPlayer_width'] ); ?>px;
|
282 |
}
|
283 |
<?php
|
284 |
}
|
286 |
function custom_style_for_gallery_image_size() {
|
287 |
?>
|
288 |
.rtmedia-container ul.rtmedia-list li.rtmedia-list-item div.rtmedia-item-thumbnail {
|
289 |
+
width: <?php echo esc_attr( $this->options['defaultSizes_photo_thumbnail_width'] ); ?>px;
|
290 |
+
height: <?php echo esc_attr( $this->options['defaultSizes_photo_thumbnail_height'] ); ?>px;
|
291 |
+
line-height: <?php echo esc_attr( $this->options['defaultSizes_photo_thumbnail_height'] ); ?>px;
|
292 |
}
|
293 |
.rtmedia-container ul.rtmedia-list li.rtmedia-list-item div.rtmedia-item-thumbnail img {
|
294 |
+
max-width: <?php echo esc_attr( $this->options['defaultSizes_photo_thumbnail_width'] ); ?>px;
|
295 |
+
max-height: <?php echo esc_attr( $this->options['defaultSizes_photo_thumbnail_height'] ); ?>px;
|
296 |
}
|
297 |
.rtmedia-container .rtmedia-list .rtmedia-list-item {
|
298 |
+
width: <?php echo intval( $this->options['defaultSizes_photo_thumbnail_width'] ); ?>px;
|
299 |
}
|
300 |
<?php
|
301 |
}
|
302 |
|
303 |
function custom_style_for_gallery_image_size_masonry() {
|
304 |
+
if ( intval( $this->options['defaultSizes_photo_thumbnail_height'] ) > 0 ) {
|
305 |
?>
|
306 |
.rtmedia-container .rtmedia-list .rtmedia-list-item .rtmedia-item-thumbnail {
|
307 |
+
max-height: <?php echo intval( $this->options['defaultSizes_photo_thumbnail_height'] ); ?>px;
|
308 |
}
|
309 |
<?php
|
310 |
}
|
311 |
+
if ( intval( $this->options['defaultSizes_photo_thumbnail_width'] ) > 0 ) {
|
312 |
?>
|
313 |
.rtmedia-container .rtmedia-list .rtmedia-list-item .rtmedia-item-thumbnail {
|
314 |
+
max-width: <?php echo intval( $this->options['defaultSizes_photo_thumbnail_width'] ); ?>px;
|
315 |
}
|
316 |
<?php
|
317 |
}
|
323 |
function set_allowed_types() {
|
324 |
$allowed_types = array(
|
325 |
'photo' => array(
|
326 |
+
'name' => 'photo',
|
327 |
+
'plural' => 'photos',
|
328 |
+
'label' => esc_html__( 'Photo', 'buddypress-media' ),
|
329 |
+
'plural_label' => esc_html__( 'Photos', 'buddypress-media' ),
|
330 |
+
'extn' => array( 'jpg', 'jpeg', 'png', 'gif' ),
|
331 |
+
'thumbnail' => RTMEDIA_URL . 'app/assets/admin/img/image_thumb.png',
|
332 |
+
'settings_visibility' => true,
|
333 |
),
|
334 |
'video' => array(
|
335 |
+
'name' => 'video',
|
336 |
+
'plural' => 'videos',
|
337 |
+
'label' => esc_html__( 'Video', 'buddypress-media' ),
|
338 |
+
'plural_label' => esc_html__( 'Videos', 'buddypress-media' ),
|
339 |
+
'extn' => array( 'mp4' ),
|
340 |
+
'thumbnail' => RTMEDIA_URL . 'app/assets/admin/img/video_thumb.png',
|
341 |
+
'settings_visibility' => true,
|
342 |
),
|
343 |
'music' => array(
|
344 |
+
'name' => 'music',
|
345 |
+
'plural' => 'music',
|
346 |
+
'label' => esc_html__( 'Music', 'buddypress-media' ),
|
347 |
+
'plural_label' => esc_html__( 'Music', 'buddypress-media' ),
|
348 |
+
'extn' => array( 'mp3' ),
|
349 |
+
'thumbnail' => RTMEDIA_URL . 'app/assets/admin/img/audio_thumb.png',
|
350 |
+
'settings_visibility' => true,
|
351 |
+
),
|
352 |
);
|
353 |
|
354 |
// filter for hooking additional media types
|
365 |
* Sanitize all media sizes after hooking custom media types
|
366 |
*
|
367 |
* @param array $allowed_types allowed media types after hooking custom types
|
368 |
+
*
|
369 |
* @return array $allowed_types sanitized media types
|
370 |
*/
|
371 |
function sanitize_allowed_types( $allowed_types ) {
|
372 |
// check if the array is formatted properly
|
373 |
+
if ( ! is_array( $allowed_types ) && count( $allowed_types ) < 1 ) {
|
374 |
return;
|
375 |
+
}
|
376 |
|
377 |
//loop through each type
|
378 |
foreach ( $allowed_types as $key => &$type ) {
|
379 |
|
380 |
+
if ( ! isset( $type['name'] ) || // check if a name is set
|
381 |
+
empty( $type['name'] ) ||
|
382 |
+
//commented this section for playlist // !isset($type['extn']) || // check if file extensions are set
|
383 |
+
//commented this section for playlist // empty($type['extn']) ||
|
384 |
+
strstr( $type['name'], ' ' ) || strstr( $type['name'], '_' )
|
385 |
+
) {
|
386 |
unset( $allowed_types[ $key ] ); // if not unset this type
|
387 |
continue;
|
388 |
}
|
389 |
+
$slug = strtoupper( $type['name'] );
|
390 |
+
if ( defined( 'RTMEDIA_' . $slug . '_LABEL' ) ) {
|
391 |
+
$type['label'] = constant( 'RTMEDIA_' . $slug . '_LABEL' );
|
392 |
}
|
393 |
+
if ( defined( 'RTMEDIA_' . $slug . '_PLURAL_LABEL' ) ) {
|
394 |
+
$type['plural_label'] = constant( 'RTMEDIA_' . $slug . '_PLURAL_LABEL' );
|
395 |
}
|
396 |
// if thumbnail is not supplied, use the default thumbnail
|
397 |
+
if ( ! isset( $type['thumbnail'] ) || empty( $type['thumbnail'] ) ) {
|
398 |
+
$type['thumbnail'] = $this->default_thumbnail;
|
399 |
}
|
400 |
}
|
401 |
+
|
402 |
return $allowed_types;
|
403 |
}
|
404 |
|
407 |
*/
|
408 |
function set_default_sizes() {
|
409 |
$this->default_sizes = array(
|
410 |
+
'photo' => array(
|
411 |
'thumbnail' => array( 'width' => 150, 'height' => 150, 'crop' => 1 ),
|
412 |
+
'medium' => array( 'width' => 320, 'height' => 240, 'crop' => 1 ),
|
413 |
+
'large' => array( 'width' => 800, 'height' => 0, 'crop' => 1 ),
|
414 |
),
|
415 |
+
'video' => array(
|
416 |
'activityPlayer' => array( 'width' => 320, 'height' => 240 ),
|
417 |
+
'singlePlayer' => array( 'width' => 640, 'height' => 480 ),
|
418 |
),
|
419 |
+
'music' => array(
|
420 |
'activityPlayer' => array( 'width' => 320 ),
|
421 |
+
'singlePlayer' => array( 'width' => 640 ),
|
422 |
),
|
423 |
'featured' => array(
|
424 |
+
'default' => array( 'width' => 100, 'height' => 100, 'crop' => 1 ),
|
425 |
+
),
|
426 |
);
|
427 |
|
428 |
$this->default_sizes = apply_filters( 'rtmedia_allowed_sizes', $this->default_sizes );
|
435 |
|
436 |
$this->privacy_settings = array(
|
437 |
'levels' => array(
|
438 |
+
60 => esc_html__( 'Private - Visible only to the user', 'buddypress-media' ),
|
439 |
+
40 => esc_html__( 'Friends - Visible to user\'s friends', 'buddypress-media' ),
|
440 |
+
20 => esc_html__( 'Logged in Users - Visible to registered users', 'buddypress-media' ),
|
441 |
+
0 => esc_html__( 'Public - Visible to the world', 'buddypress-media' ),
|
442 |
+
),
|
443 |
);
|
444 |
$this->privacy_settings = apply_filters( 'rtmedia_privacy_levels', $this->privacy_settings );
|
445 |
|
446 |
if ( function_exists( 'bp_is_active' ) && ! bp_is_active( 'friends' ) ) {
|
447 |
+
unset( $this->privacy_settings['levels'][40] );
|
448 |
}
|
449 |
}
|
450 |
|
480 |
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
481 |
|
482 |
$group = 0;
|
483 |
+
if ( isset( $bp_media_options['enable_on_group'] ) && ! empty( $bp_media_options['enable_on_group'] ) ) {
|
484 |
+
$group = $bp_media_options['enable_on_group'];
|
485 |
+
} else if ( function_exists( 'bp_is_active' ) ) {
|
486 |
$group = bp_is_active( 'groups' );
|
487 |
+
}
|
488 |
+
$this->options['buddypress_enableOnGroup'] = $group;
|
489 |
|
490 |
$activity = 0;
|
491 |
+
if ( isset( $bp_media_options['activity_upload'] ) && ! empty( $bp_media_options['activity_upload'] ) ) {
|
492 |
+
$activity = $bp_media_options['activity_upload'];
|
493 |
+
} else if ( function_exists( 'bp_is_active' ) ) {
|
494 |
$activity = bp_is_active( 'activity' );
|
495 |
+
}
|
496 |
+
$this->options['buddypress_enableOnActivity'] = $activity;
|
497 |
|
498 |
+
$this->options['buddypress_enableOnProfile'] = 1;
|
499 |
|
500 |
/* Last settings updated in options. Update them in DB & after this no other option would be saved in db */
|
501 |
rtmedia_update_site_option( 'rtmedia-options', $this->options );
|
506 |
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
507 |
|
508 |
$defaults = array(
|
509 |
+
'general_enableAlbums' => 1,
|
510 |
+
'general_enableComments' => 0,
|
511 |
+
'general_downloadButton' => ( isset( $bp_media_options['download_enabled'] ) ) ? $bp_media_options['download_enabled'] : 0,
|
512 |
+
'general_enableLightbox' => ( isset( $bp_media_options['enable_lightbox'] ) ) ? $bp_media_options['enable_lightbox'] : 1,
|
513 |
+
'general_perPageMedia' => ( isset( $bp_media_options['default_count'] ) ) ? $bp_media_options['default_count'] : 10,
|
514 |
'general_enableMediaEndPoint' => 0,
|
515 |
+
'general_showAdminMenu' => ( isset( $bp_media_options['show_admin_menu'] ) ) ? $bp_media_options['show_admin_menu'] : 0,
|
516 |
+
'general_videothumbs' => 2,
|
517 |
+
'general_jpeg_image_quality' => 90,
|
518 |
+
'general_AllowUserData' => 1,
|
519 |
);
|
520 |
|
|
|
521 |
foreach ( $this->allowed_types as $type ) {
|
522 |
// invalid keys handled in sanitize method
|
523 |
+
$defaults[ 'allowedTypes_' . $type['name'] . '_enabled' ] = 1;
|
524 |
+
$defaults[ 'allowedTypes_' . $type['name'] . '_featured' ] = 0;
|
525 |
}
|
526 |
|
527 |
/* Previous Sizes values from buddypress is migrated */
|
528 |
+
foreach ( $this->default_sizes as $type => $type_value ) {
|
529 |
+
foreach ( $type_value as $size => $size_value ) {
|
530 |
+
foreach ( $size_value as $dimension => $value ) {
|
531 |
switch ( $type ) {
|
532 |
case 'photo':
|
533 |
+
if ( isset( $bp_media_options['sizes']['image'][ $size ][ $dimension ] ) && ! empty( $bp_media_options['sizes']['image'][ $size ][ $dimension ] ) ) {
|
534 |
+
$value = $bp_media_options['sizes']['image'][ $size ][ $dimension ];
|
535 |
+
}
|
536 |
break;
|
537 |
case 'video':
|
538 |
case 'music':
|
539 |
+
$old = ( 'video' === $type ) ? 'video' : ( 'music' === $type ) ? 'audio' : '';
|
540 |
switch ( $size ) {
|
541 |
case 'activityPlayer':
|
542 |
+
if ( isset( $bp_media_options['sizes'][ $old ]['medium'][ $dimension ] ) && ! empty( $bp_media_options['sizes'][ $old ]['medium'][ $dimension ] ) ) {
|
543 |
+
$value = $bp_media_options['sizes'][ $old ]['medium'][ $dimension ];
|
544 |
+
}
|
545 |
break;
|
546 |
case 'singlePlayer':
|
547 |
+
if ( isset( $bp_media_options['sizes'][ $old ]['large'][ $dimension ] ) && ! empty( $bp_media_options['sizes'][ $old ]['large'][ $dimension ] ) ) {
|
548 |
+
$value = $bp_media_options['sizes'][ $old ]['large'][ $dimension ];
|
549 |
+
}
|
550 |
break;
|
551 |
}
|
552 |
break;
|
557 |
}
|
558 |
|
559 |
/* Privacy */
|
560 |
+
$defaults['privacy_enabled'] = ( isset( $bp_media_options['privacy_enabled'] ) ) ? $bp_media_options['privacy_enabled'] : 0;
|
561 |
+
$defaults['privacy_default'] = ( isset( $bp_media_options['default_privacy_level'] ) ) ? $bp_media_options['default_privacy_level'] : 0;
|
562 |
+
$defaults['privacy_userOverride'] = ( isset( $bp_media_options['privacy_override_enabled'] ) ) ? $bp_media_options['privacy_override_enabled'] : 0;
|
563 |
|
564 |
+
$defaults['styles_custom'] = ( isset( $bp_media_options['styles_custom'] ) ) ? $bp_media_options['styles_custom'] : '';
|
565 |
+
$defaults['styles_enabled'] = ( isset( $bp_media_options['styles_enabled'] ) ) ? $bp_media_options['styles_enabled'] : 1;
|
566 |
|
567 |
$this->options = $defaults;
|
568 |
|
576 |
public function constants() {
|
577 |
|
578 |
/* If the plugin is installed. */
|
579 |
+
if ( ! defined( 'RTMEDIA_IS_INSTALLED' ) ) {
|
580 |
define( 'RTMEDIA_IS_INSTALLED', 1 );
|
581 |
+
}
|
582 |
|
583 |
/* Required Version */
|
584 |
+
if ( ! defined( 'RTMEDIA_REQUIRED_BP' ) ) {
|
585 |
define( 'RTMEDIA_REQUIRED_BP', '1.7' );
|
586 |
+
}
|
587 |
|
588 |
/* Slug Constants for building urls */
|
589 |
|
590 |
/* Media slugs */
|
591 |
|
592 |
+
if ( ! defined( 'RTMEDIA_MEDIA_SLUG' ) ) {
|
593 |
define( 'RTMEDIA_MEDIA_SLUG', 'media' );
|
594 |
+
}
|
595 |
|
596 |
+
if ( ! defined( 'RTMEDIA_MEDIA_LABEL' ) ) {
|
597 |
+
define( 'RTMEDIA_MEDIA_LABEL', esc_html__( 'Media', 'buddypress-media' ) );
|
598 |
+
}
|
599 |
|
600 |
+
if ( ! defined( 'RTMEDIA_ALL_SLUG' ) ) {
|
601 |
define( 'RTMEDIA_ALL_SLUG', 'all' );
|
602 |
+
}
|
603 |
|
604 |
+
if ( ! defined( 'RTMEDIA_ALL_LABEL' ) ) {
|
605 |
+
define( 'RTMEDIA_ALL_LABEL', esc_html__( 'All', 'buddypress-media' ) );
|
606 |
+
}
|
607 |
|
608 |
+
if ( ! defined( 'RTMEDIA_ALBUM_SLUG' ) ) {
|
609 |
define( 'RTMEDIA_ALBUM_SLUG', 'album' );
|
610 |
+
}
|
611 |
|
612 |
+
if ( ! defined( 'RTMEDIA_ALBUM_PLURAL_SLUG' ) ) {
|
613 |
define( 'RTMEDIA_ALBUM_PLURAL_SLUG', 'albums' );
|
614 |
+
}
|
615 |
|
616 |
+
if ( ! defined( 'RTMEDIA_ALBUM_LABEL' ) ) {
|
617 |
+
define( 'RTMEDIA_ALBUM_LABEL', esc_html__( 'Album', 'buddypress-media' ) );
|
618 |
+
}
|
619 |
|
620 |
+
if ( ! defined( 'RTMEDIA_ALBUM_PLURAL_LABEL' ) ) {
|
621 |
+
define( 'RTMEDIA_ALBUM_PLURAL_LABEL', esc_html__( 'Albums', 'buddypress-media' ) );
|
622 |
+
}
|
623 |
|
624 |
/* Upload slug */
|
625 |
+
if ( ! defined( 'RTMEDIA_UPLOAD_SLUG' ) ) {
|
626 |
define( 'RTMEDIA_UPLOAD_SLUG', 'upload' );
|
627 |
+
}
|
628 |
|
629 |
/* Upload slug */
|
630 |
+
if ( ! defined( 'RTMEDIA_UPLOAD_LABEL' ) ) {
|
631 |
+
define( 'RTMEDIA_UPLOAD_LABEL', esc_html__( 'Upload', 'buddypress-media' ) );
|
632 |
+
}
|
633 |
|
634 |
/* Global Album/Wall Post */
|
635 |
+
if ( ! defined( 'RTMEDIA_GLOBAL_ALBUM_LABEL' ) ) {
|
636 |
+
define( 'RTMEDIA_GLOBAL_ALBUM_LABEL', esc_html__( 'Wall Post', 'buddypress-media' ) );
|
637 |
+
}
|
638 |
|
639 |
$this->define_type_constants();
|
640 |
}
|
641 |
|
642 |
function define_type_constants() {
|
643 |
|
644 |
+
if ( ! isset( $this->allowed_types ) ) {
|
645 |
return;
|
646 |
+
}
|
647 |
foreach ( $this->allowed_types as $type ) {
|
648 |
|
649 |
+
if ( ! isset( $type['name'] ) || '' === $type['name'] ) {
|
650 |
continue;
|
651 |
+
}
|
652 |
|
653 |
+
$name = $type['name'];
|
654 |
|
655 |
+
if ( isset( $type['plural'] ) && '' !== $type['plural'] ) {
|
656 |
+
$plural = $type['plural'];
|
657 |
} else {
|
658 |
$plural = $name . 's';
|
659 |
}
|
660 |
|
661 |
+
if ( isset( $type['label'] ) && '' !== $type['label'] ) {
|
662 |
+
$label = $type['label'];
|
663 |
} else {
|
664 |
$label = ucfirst( $name );
|
665 |
}
|
666 |
|
667 |
+
if ( isset( $type['plural_label'] ) && '' !== $type['plural_label'] ) {
|
668 |
+
$label_plural = $type['plural_label'];
|
669 |
} else {
|
670 |
$label_plural = ucfirst( $plural );
|
671 |
}
|
672 |
|
673 |
$slug = strtoupper( $name );
|
674 |
|
675 |
+
if ( ! defined( 'RTMEDIA_' . $slug . '_SLUG' ) ) {
|
676 |
define( 'RTMEDIA_' . $slug . '_SLUG', $name );
|
677 |
+
}
|
678 |
+
if ( ! defined( 'RTMEDIA_' . $slug . '_PLURAL_SLUG' ) ) {
|
679 |
define( 'RTMEDIA_' . $slug . '_PLURAL_SLUG', $plural );
|
680 |
+
}
|
681 |
+
if ( ! defined( 'RTMEDIA_' . $slug . '_LABEL' ) ) {
|
682 |
define( 'RTMEDIA_' . $slug . '_LABEL', $label );
|
683 |
+
}
|
684 |
+
if ( ! defined( 'RTMEDIA_' . $slug . '_PLURAL_LABEL' ) ) {
|
685 |
define( 'RTMEDIA_' . $slug . '_PLURAL_LABEL', $label_plural );
|
686 |
+
}
|
687 |
}
|
688 |
}
|
689 |
|
722 |
*/
|
723 |
$this->set_site_options();
|
724 |
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
/**
|
726 |
* BuddyPress - Media Navigation Tab Inject
|
727 |
*
|
729 |
/**
|
730 |
* Load accessory functions
|
731 |
*/
|
732 |
+
|
733 |
$class_construct = array(
|
734 |
+
'deprecated' => true,
|
735 |
+
'interaction' => true,
|
736 |
+
'upload_shortcode' => false,
|
737 |
+
'gallery_shortcode' => false,
|
738 |
+
'upload_endpoint' => false,
|
739 |
+
'privacy' => false,
|
740 |
+
'nav' => true,
|
741 |
+
'like' => false,
|
742 |
+
'featured' => false,
|
743 |
+
'GroupFeatured' => false,
|
744 |
+
'ViewCount' => false,
|
745 |
+
'GalleryItemAction' => false,
|
746 |
+
'LoginPopup' => false,
|
747 |
'CommentNotification' => false,
|
748 |
+
'LikeNotification' => false,
|
749 |
);
|
750 |
global $rtmedia_nav;
|
751 |
|
754 |
foreach ( $bp_class_construct as $classname => $global_scope ) {
|
755 |
$class = 'BPMedia' . ucfirst( $classname );
|
756 |
if ( class_exists( $class ) ) {
|
757 |
+
if ( true === $global_scope ) {
|
758 |
global ${'bp_media_' . $classname};
|
759 |
${'bp_media_' . $classname} = new $class();
|
760 |
} else {
|
765 |
/** ------------------- * */
|
766 |
$class_construct = apply_filters( 'rtmedia_class_construct', $class_construct );
|
767 |
|
768 |
+
$class_construct['Group'] = false; // will be constructed after rtmedia pro class.
|
769 |
|
770 |
foreach ( $class_construct as $key => $global_scope ) {
|
771 |
$classname = '';
|
772 |
+
$ck = explode( '_', $key );
|
773 |
|
774 |
foreach ( $ck as $cn ) {
|
775 |
$classname .= ucfirst( $cn );
|
778 |
$class = 'RTMedia' . $classname;
|
779 |
|
780 |
if ( class_exists( $class ) ) {
|
781 |
+
if ( true === $global_scope ) {
|
782 |
global ${'rtmedia_' . $key};
|
783 |
${'rtmedia_' . $key} = new $class();
|
784 |
} else {
|
791 |
|
792 |
global $rtmedia_buddypress_activity;
|
793 |
$rtmedia_buddypress_activity = new RTMediaBuddyPressActivity();
|
794 |
+
$media = new RTMediaMedia();
|
795 |
$media->delete_hook();
|
796 |
|
|
|
797 |
global $rtmedia_ajax;
|
798 |
$rtmedia_ajax = new RTMediaAJAX();
|
799 |
//API Classes
|
806 |
|
807 |
function set_rtmedia_meta_wpdbfix() {
|
808 |
global $wpdb;
|
809 |
+
$media_meta = new RTMediaMeta();
|
810 |
$wpdb->mediameta = $media_meta->model->table_name;
|
811 |
}
|
812 |
|
813 |
function redirect_on_change_slug() {
|
814 |
+
$old_slugs = rtmedia_get_site_option( 'rtmedia_old_media_slug', false, true );
|
815 |
+
$current_slugs = rtmedia_get_site_option( 'rtmedia_current_media_slug', false, false );
|
816 |
+
if ( false === $current_slugs ) {
|
817 |
+
rtmedia_update_site_option( 'rtmedia_current_media_slug', RTMEDIA_MEDIA_SLUG );
|
818 |
+
|
819 |
return;
|
820 |
}
|
821 |
+
if ( RTMEDIA_MEDIA_SLUG === $current_slugs ) {
|
822 |
return;
|
823 |
+
}
|
824 |
+
if ( false === $old_slugs ) {
|
825 |
$old_slugs = array();
|
826 |
+
}
|
827 |
$old_slugs[] = $current_slugs;
|
828 |
+
rtmedia_update_site_option( 'rtmedia_current_media_slug', RTMEDIA_MEDIA_SLUG );
|
829 |
}
|
830 |
|
831 |
/**
|
832 |
* Loads translations
|
833 |
*/
|
834 |
static
|
835 |
+
function load_translation() {
|
836 |
load_plugin_textdomain( 'buddypress-media', false, basename( RTMEDIA_PATH ) . '/languages/' );
|
837 |
}
|
838 |
|
839 |
function check_global_album() {
|
840 |
+
//todo: Nonce required
|
841 |
+
$album = new RTMediaAlbum();
|
842 |
$global_album = $album->get_default();
|
843 |
+
// @codingStandardsIgnoreStart
|
844 |
//** Hack for plupload default name
|
845 |
+
if ( isset( $_POST['action'] ) && isset( $_POST['mode'] ) && 'file_upload' === sanitize_text_field( $_POST['mode'] ) ) {
|
846 |
+
unset( $_POST['name'] );
|
847 |
+
}
|
848 |
+
// @codingStandardsIgnoreEnd
|
849 |
+
//**
|
850 |
+
global $rtmedia_error;
|
851 |
+
if ( isset( $rtmedia_error ) && true === $rtmedia_error ) {
|
852 |
+
return false;
|
853 |
+
}
|
854 |
+
if ( ! $global_album ) {
|
855 |
+
$global_album = $album->add_global( esc_html__( 'Wall Posts', 'buddypress-media' ) );
|
856 |
+
}
|
857 |
+
|
858 |
+
// fix multisite global album doesn't exist issue.
|
859 |
+
if ( is_multisite() && ! rtmedia_get_site_option( 'rtmedia_fix_multisite_global_albums', false ) ) {
|
860 |
+
$model = new RTMediaModel();
|
861 |
+
$global_albums = rtmedia_global_albums();
|
862 |
+
$album_objects = $model->get_media( array( 'id' => ( $global_albums ) ), false, false );
|
863 |
+
if ( empty( $album_objects ) ) {
|
864 |
+
$global_album = $album->add_global( esc_html__( 'Wall Posts', 'buddypress-media' ) );
|
865 |
+
}
|
866 |
+
rtmedia_update_site_option( 'rtmedia_fix_multisite_global_albums', true );
|
867 |
+
}
|
868 |
+
}
|
869 |
|
870 |
function default_count() {
|
871 |
$count = $this->posts_per_page;
|
872 |
if ( array_key_exists( 'default_count', $this->options ) ) {
|
873 |
+
$count = $this->options['default_count'];
|
874 |
}
|
875 |
+
$count = ( ! is_int( $count ) ) ? 0 : $count;
|
876 |
+
|
877 |
+
return ( ! $count ) ? 10 : $count;
|
878 |
}
|
879 |
|
880 |
+
static function plugin_get_version( $path = null ) {
|
881 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
882 |
+
$path = ( $path ) ? $path : RTMEDIA_PATH . 'index.php';
|
883 |
+
$plugin_data = get_plugin_data( $path );
|
884 |
+
$plugin_version = $plugin_data['Version'];
|
885 |
+
|
886 |
return $plugin_version;
|
887 |
}
|
888 |
|
889 |
function update_db() {
|
890 |
+
$update = new RTDBUpdate( false, RTMEDIA_PATH . 'index.php', RTMEDIA_PATH . 'app/schema/', true );
|
891 |
/* Current Version. */
|
892 |
if ( ! defined( 'RTMEDIA_VERSION' ) ) {
|
893 |
define( 'RTMEDIA_VERSION', $update->db_version );
|
895 |
if ( $update->check_upgrade() ) {
|
896 |
$update->do_upgrade();
|
897 |
}
|
898 |
+
if ( ! $update->table_exists( $update->genrate_table_name( 'rtm_media' ) ) ) {
|
899 |
delete_site_option( $update->get_db_version_option_name() );
|
900 |
+
$update->install_db_version = '0';
|
901 |
$update->do_upgrade();
|
902 |
}
|
903 |
}
|
905 |
function create_table_error_notice() {
|
906 |
global $rtmedia_error;
|
907 |
$rtmedia_error = true;
|
908 |
+
echo "<div class='error'><p><strong>" . esc_html__( 'rtMedia', 'buddypress-media' ) . '</strong>' . esc_html__( ": Can't Create Database table. Please check create table permission.", 'buddypress-media' ) . '</p></div>';
|
909 |
}
|
910 |
|
911 |
function enqueue_scripts_styles() {
|
919 |
wp_enqueue_script( 'wp-mediaelement-start', RTMEDIA_URL . 'lib/media-element/wp-mediaelement.js', 'wp-mediaelement', RTMEDIA_VERSION, true );
|
920 |
}
|
921 |
|
|
|
922 |
// Dashicons: Needs if not loaded by WP
|
923 |
wp_enqueue_style( 'dashicons' );
|
924 |
|
925 |
// Dont enqueue rtmedia.min.css if default styles is checked false in rtmedia settings
|
926 |
$suffix = ( function_exists( 'rtm_get_script_style_suffix' ) ) ? rtm_get_script_style_suffix() : '.min';
|
927 |
|
928 |
+
if ( ! ( isset( $rtmedia->options ) && isset( $rtmedia->options['styles_enabled'] ) && 0 === $rtmedia->options['styles_enabled'] ) ) {
|
929 |
wp_enqueue_style( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/rtmedia' . $suffix . '.css', '', RTMEDIA_VERSION );
|
930 |
}
|
931 |
|
932 |
+
if ( '' === $suffix ) {
|
933 |
+
wp_enqueue_script( 'rtmedia-magnific-popup', RTMEDIA_URL . 'app/assets/js/vendors/magnific-popup.js', array(
|
934 |
+
'jquery',
|
935 |
+
'wp-mediaelement',
|
936 |
+
), RTMEDIA_VERSION );
|
937 |
+
wp_enqueue_script( 'rtmedia-admin-tabs', RTMEDIA_URL . 'app/assets/admin/js/vendors/tabs.js', array(
|
938 |
+
'jquery',
|
939 |
+
'wp-mediaelement',
|
940 |
+
), RTMEDIA_VERSION );
|
941 |
+
wp_enqueue_script( 'rtmedia-main', RTMEDIA_URL . 'app/assets/js/rtMedia.js', array(
|
942 |
+
'jquery',
|
943 |
+
'wp-mediaelement',
|
944 |
+
), RTMEDIA_VERSION );
|
945 |
} else {
|
946 |
+
wp_enqueue_script( 'rtmedia-main', RTMEDIA_URL . 'app/assets/js/rtmedia.min.js', array(
|
947 |
+
'jquery',
|
948 |
+
'wp-mediaelement',
|
949 |
+
), RTMEDIA_VERSION );
|
950 |
}
|
951 |
|
952 |
wp_localize_script( 'rtmedia-main', 'rtmedia_ajax_url', admin_url( 'admin-ajax.php' ) );
|
953 |
wp_localize_script( 'rtmedia-main', 'rtmedia_media_slug', RTMEDIA_MEDIA_SLUG );
|
954 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_lightbox_enabled', strval( $this->options['general_enableLightbox'] ) );
|
955 |
+
|
956 |
+
$direct_upload = ( isset( $this->options['general_direct_upload'] ) ? $this->options['general_direct_upload'] : '0' );
|
957 |
+
|
958 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_direct_upload_enabled', $direct_upload );
|
959 |
//gallery reload after media upload, by default true
|
960 |
wp_localize_script( 'rtmedia-main', 'rtmedia_gallery_reload_on_upload', '1' );
|
961 |
|
962 |
//javascript messages
|
963 |
+
wp_localize_script( 'rtmedia-magnific', 'rtmedia_load_more', esc_html__( 'Loading media', 'buddypress-media' ) );
|
964 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_empty_activity_msg', esc_html__( 'Please enter some content to post.', 'buddypress-media' ) );
|
965 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_empty_comment_msg', esc_html__( 'Empty Comment is not allowed.', 'buddypress-media' ) );
|
966 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_media_delete_confirmation', esc_html__( 'Are you sure you want to delete this media?', 'buddypress-media' ) );
|
967 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_media_comment_delete_confirmation', esc_html__( 'Are you sure you want to delete this comment?', 'buddypress-media' ) );
|
968 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_album_delete_confirmation', esc_html__( 'Are you sure you want to delete this Album?', 'buddypress-media' ) );
|
969 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_drop_media_msg', esc_html__( 'Drop files here', 'buddypress-media' ) );
|
970 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_album_created_msg', ' ' . esc_html__( 'album created successfully.', 'buddypress-media' ) );
|
971 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_something_wrong_msg', esc_html__( 'Something went wrong. Please try again.', 'buddypress-media' ) );
|
972 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_empty_album_name_msg', esc_html__( 'Enter an album name.', 'buddypress-media' ) );
|
973 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_max_file_msg', esc_html__( 'Max file Size Limit : ', 'buddypress-media' ) );
|
974 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_allowed_file_formats', esc_html__( 'Allowed File Formats', 'buddypress-media' ) );
|
975 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_select_all_visible', esc_html__( 'Select All Visible', 'buddypress-media' ) );
|
976 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_unselect_all_visible', esc_html__( 'Unselect All Visible', 'buddypress-media' ) );
|
977 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_no_media_selected', esc_html__( 'Please select some media.', 'buddypress-media' ) );
|
978 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_selected_media_delete_confirmation', esc_html__( 'Are you sure you want to delete the selected media?', 'buddypress-media' ) );
|
979 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_selected_media_move_confirmation', esc_html__( 'Are you sure you want to move the selected media?', 'buddypress-media' ) );
|
980 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_waiting_msg', esc_html__( 'Waiting', 'buddypress-media' ) );
|
981 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_uploaded_msg', esc_html__( 'Uploaded', 'buddypress-media' ) );
|
982 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_uploading_msg', esc_html__( 'Uploading', 'buddypress-media' ) );
|
983 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_upload_failed_msg', esc_html__( 'Failed', 'buddypress-media' ) );
|
984 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_close', esc_html__( 'Close', 'buddypress-media' ) );
|
985 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_edit', esc_html__( 'Edit', 'buddypress-media' ) );
|
986 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_delete', esc_html__( 'Delete', 'buddypress-media' ) );
|
987 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_edit_media', esc_html__( 'Edit Media', 'buddypress-media' ) );
|
988 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_remove_from_queue', esc_html__( 'Remove from queue', 'buddypress-media' ) );
|
989 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_add_more_files_msg', esc_html__( 'Add more files', 'buddypress-media' ) );
|
990 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_file_extension_error_msg', esc_html__( 'File not supported', 'buddypress-media' ) );
|
991 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_more', esc_html__( 'more', 'buddypress-media' ) );
|
992 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_less', esc_html__( 'less', 'buddypress-media' ) );
|
993 |
+
wp_localize_script( 'rtmedia-main', 'rtmedia_delete_uploaded_media', esc_html__( 'This media is uploaded. Are you sure you want to delete this media?', 'buddypress-media' ) );
|
994 |
wp_localize_script( 'rtmedia-main', 'rtm_wp_version', get_bloginfo( 'version' ) );
|
995 |
+
wp_localize_script( 'rtmedia-backbone', 'rMedia_loading_media', RTMEDIA_URL . 'app/assets/admin/img/boxspinner.gif' );
|
996 |
$rtmedia_media_thumbs = array();
|
997 |
foreach ( $this->allowed_types as $key_type => $value_type ) {
|
998 |
+
$rtmedia_media_thumbs[ $key_type ] = $value_type['thumbnail'];
|
999 |
}
|
1000 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_media_thumbs', $rtmedia_media_thumbs );
|
1001 |
+
wp_localize_script( 'rtmedia-backbone', 'rtmedia_set_featured_image_msg', esc_html__( 'Featured media set successfully.', 'buddypress-media' ) );
|
1002 |
+
wp_localize_script( 'rtmedia-backbone', 'rtmedia_unset_featured_image_msg', esc_html__( 'Featured media removed successfully.', 'buddypress-media' ) );
|
1003 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_edit_media_info_upload', array(
|
1004 |
+
'title' => esc_html__( 'Title:', 'buddypress-media' ),
|
1005 |
+
'description' => esc_html__( 'Description:', 'buddypress-media' ),
|
1006 |
) );
|
1007 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
// Enqueue touchswipe
|
1009 |
wp_enqueue_script( 'rtmedia-touchswipe', RTMEDIA_URL . 'lib/touchswipe/jquery.touchSwipe.min.js', array( 'jquery' ), RTMEDIA_VERSION, true );
|
1010 |
|
1011 |
+
if ( isset( $rtmedia->options ) && isset( $rtmedia->options['general_masonry_layout'] ) && 1 === intval( $rtmedia->options['general_masonry_layout'] ) ) {
|
1012 |
+
if ( wp_script_is( 'jquery-masonry', 'registered' ) ) {
|
1013 |
wp_enqueue_style( 'jquery-masonry' );
|
1014 |
wp_enqueue_script( 'jquery-masonry' );
|
1015 |
wp_localize_script( 'rtmedia-main', 'rtmedia_masonry_layout', 'true' );
|
1020 |
wp_localize_script( 'rtmedia-main', 'rtmedia_masonry_layout', 'false' );
|
1021 |
}
|
1022 |
|
1023 |
+
if ( isset( $rtmedia->options['general_display_media'] ) ) {
|
1024 |
+
wp_localize_script( 'rtmedia-backbone', 'rtmedia_load_more_or_pagination', (string) $rtmedia->options['general_display_media'] );
|
1025 |
} else {
|
1026 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_load_more_or_pagination', 'load_more' );
|
1027 |
}
|
1028 |
|
1029 |
+
if ( isset( $rtmedia->options['buddypress_enableOnActivity'] ) ) {
|
1030 |
+
wp_localize_script( 'rtmedia-backbone', 'rtmedia_bp_enable_activity', (string) $rtmedia->options['buddypress_enableOnActivity'] );
|
1031 |
} else {
|
1032 |
wp_localize_script( 'rtmedia-backbone', 'rtmedia_bp_enable_activity', '0' );
|
1033 |
}
|
1034 |
|
1035 |
+
wp_localize_script( 'rtmedia-backbone', 'rtmedia_upload_progress_error_message', esc_html__( 'There are some uploads in progress. Do you want to cancel them?', 'buddypress-media' ) );
|
1036 |
|
1037 |
// localise media size config
|
1038 |
$media_size_config = array(
|
1039 |
+
'photo' => array(
|
1040 |
+
'thumb' => array(
|
1041 |
+
'width' => $rtmedia->options['defaultSizes_photo_thumbnail_width'],
|
1042 |
+
'height' => $rtmedia->options['defaultSizes_photo_thumbnail_height'],
|
1043 |
+
'crop' => $rtmedia->options['defaultSizes_photo_thumbnail_crop'],
|
1044 |
),
|
1045 |
'medium' => array(
|
1046 |
+
'width' => $rtmedia->options['defaultSizes_photo_medium_width'],
|
1047 |
+
'height' => $rtmedia->options['defaultSizes_photo_medium_height'],
|
1048 |
+
'crop' => $rtmedia->options['defaultSizes_photo_medium_crop'],
|
1049 |
),
|
1050 |
+
'large' => array(
|
1051 |
+
'width' => $rtmedia->options['defaultSizes_photo_large_width'],
|
1052 |
+
'height' => $rtmedia->options['defaultSizes_photo_large_height'],
|
1053 |
+
'crop' => $rtmedia->options['defaultSizes_photo_large_crop'],
|
1054 |
),
|
1055 |
),
|
1056 |
+
'video' => array(
|
1057 |
'activity_media' => array(
|
1058 |
+
'width' => $rtmedia->options['defaultSizes_video_activityPlayer_width'],
|
1059 |
+
'height' => $rtmedia->options['defaultSizes_video_activityPlayer_height'],
|
1060 |
),
|
1061 |
+
'single_media' => array(
|
1062 |
+
'width' => $rtmedia->options['defaultSizes_video_singlePlayer_width'],
|
1063 |
+
'height' => $rtmedia->options['defaultSizes_video_singlePlayer_height'],
|
1064 |
),
|
1065 |
),
|
1066 |
+
'music' => array(
|
1067 |
'activity_media' => array(
|
1068 |
+
'width' => $rtmedia->options['defaultSizes_music_activityPlayer_width'],
|
1069 |
),
|
1070 |
+
'single_media' => array(
|
1071 |
+
'width' => $rtmedia->options['defaultSizes_music_singlePlayer_width'],
|
1072 |
),
|
1073 |
),
|
1074 |
'featured' => array(
|
1075 |
'default' => array(
|
1076 |
+
'width' => $rtmedia->options['defaultSizes_featured_default_width'],
|
1077 |
+
'height' => $rtmedia->options['defaultSizes_featured_default_height'],
|
1078 |
+
'crop' => $rtmedia->options['defaultSizes_featured_default_crop'],
|
1079 |
+
),
|
1080 |
),
|
1081 |
);
|
1082 |
wp_localize_script( 'rtmedia-main', 'rtmedia_media_size_config', $media_size_config );
|
1087 |
remove_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
|
1088 |
}
|
1089 |
|
1090 |
+
//todo: This function should return value or pass argument
|
1091 |
function set_friends_object() {
|
1092 |
if ( is_user_logged_in() ) {
|
1093 |
+
$user = get_current_user_id();
|
1094 |
$friends = friends_get_friend_user_ids( $user );
|
1095 |
} else {
|
1096 |
$user = 0;
|
1098 |
}
|
1099 |
|
1100 |
function filter_image_sizes_details( $sizes ) {
|
1101 |
+
if ( isset( $_REQUEST['post_id'] ) ) {
|
1102 |
$sizes = $this->unset_bp_media_image_sizes_details( $sizes );
|
1103 |
+
} elseif ( isset( $_REQUEST['id'] ) ) { //For Regenerate Thumbnails Plugin
|
1104 |
+
$model = new RTMediaModel();
|
1105 |
+
$result = $model->get( array( 'media_id' => intval( wp_unslash( $_REQUEST['id'] ) ) ) );
|
1106 |
if ( ! empty( $result ) ) {
|
1107 |
$bp_media_sizes = $this->image_sizes();
|
1108 |
+
$sizes = array(
|
1109 |
+
'rt_media_thumbnail' => $bp_media_sizes['thumbnail'],
|
1110 |
+
'rt_media_activity_image' => $bp_media_sizes['activity'],
|
1111 |
+
'rt_media_single_image' => $bp_media_sizes['single'],
|
1112 |
+
'rt_media_featured_image' => $bp_media_sizes['featured'],
|
1113 |
);
|
1114 |
} else {
|
1115 |
$sizes = $this->unset_bp_media_image_sizes_details( $sizes );
|
1116 |
}
|
1117 |
}
|
1118 |
+
|
1119 |
return $sizes;
|
1120 |
}
|
1121 |
|
1122 |
function rtmedia_custom_image_sizes_choose( $sizes ) {
|
1123 |
$custom_sizes = array(
|
1124 |
+
'rt_media_thumbnail' => 'rtMedia Thumbnail',
|
1125 |
+
'rt_media_activity_image' => 'rtMedia Activity Image',
|
1126 |
+
'rt_media_single_image' => 'rtMedia Single Image',
|
1127 |
+
'rt_media_featured_image' => 'rtMedia Fetured Image',
|
1128 |
);
|
1129 |
+
|
1130 |
return array_merge( $sizes, $custom_sizes );
|
1131 |
}
|
1132 |
|
1133 |
function filter_image_sizes( $sizes ) {
|
1134 |
+
if ( isset( $_REQUEST['postid'] ) ) { //For Regenerate Thumbnails Plugin
|
1135 |
+
if ( $parent_id = get_post_field( 'post_parent', intval( wp_unslash( $_REQUEST['postid'] ) ) ) ) {
|
1136 |
$post_type = get_post_field( 'post_type', $parent_id );
|
1137 |
+
if ( 'rtmedia_album' === $post_type ) {
|
1138 |
$sizes = array(
|
1139 |
+
'rt_media_thumbnail',
|
1140 |
+
'rt_media_activity_image',
|
1141 |
+
'rt_media_single_image',
|
1142 |
+
'rt_media_featured_image',
|
1143 |
);
|
1144 |
} else {
|
1145 |
$sizes = $this->unset_bp_media_image_sizes( $sizes );
|
1153 |
}
|
1154 |
|
1155 |
function unset_bp_media_image_sizes_details( $sizes ) {
|
1156 |
+
if ( isset( $sizes['rt_media_thumbnail'] ) ) {
|
1157 |
+
unset( $sizes['rt_media_thumbnail'] );
|
1158 |
+
}
|
1159 |
+
if ( isset( $sizes['rt_media_activity_image'] ) ) {
|
1160 |
+
unset( $sizes['rt_media_activity_image'] );
|
1161 |
+
}
|
1162 |
+
if ( isset( $sizes['rt_media_single_image'] ) ) {
|
1163 |
+
unset( $sizes['rt_media_single_image'] );
|
1164 |
+
}
|
1165 |
+
if ( isset( $sizes['rt_media_featured_image'] ) ) {
|
1166 |
+
unset( $sizes['rt_media_featured_image'] );
|
1167 |
+
}
|
1168 |
+
|
1169 |
return $sizes;
|
1170 |
}
|
1171 |
|
1172 |
function unset_bp_media_image_sizes( $sizes ) {
|
1173 |
+
if ( ( $key = array_search( 'rt_media_thumbnail', $sizes ) ) !== false ) {
|
1174 |
unset( $sizes[ $key ] );
|
1175 |
+
}
|
1176 |
+
if ( ( $key = array_search( 'rt_media_activity_image', $sizes ) ) !== false ) {
|
1177 |
unset( $sizes[ $key ] );
|
1178 |
+
}
|
1179 |
+
if ( ( $key = array_search( 'rt_media_single_image', $sizes ) ) !== false ) {
|
1180 |
unset( $sizes[ $key ] );
|
1181 |
+
}
|
1182 |
+
if ( ( $key = array_search( 'rt_media_featured_image', $sizes ) ) !== false ) {
|
1183 |
unset( $sizes[ $key ] );
|
1184 |
+
}
|
1185 |
+
|
1186 |
return $sizes;
|
1187 |
}
|
|
|
1188 |
}
|
1189 |
|
1190 |
function parentlink_global_album( $id ) {
|
1191 |
$global_albums = RTMediaAlbum::get_globals();
|
1192 |
+
$parent_link = '';
|
1193 |
+
if ( is_array( $global_albums ) && '' !== $global_albums ) {
|
1194 |
+
if ( in_array( $id, $global_albums ) && function_exists( 'bp_displayed_user_id' ) ) {
|
1195 |
$disp_user = bp_displayed_user_id();
|
1196 |
$curr_user = get_current_user_id();
|
1197 |
if ( $disp_user == $curr_user ) {
|
1200 |
$parent_link = get_rtmedia_user_link( $disp_user );
|
1201 |
}
|
1202 |
global $rtmedia_query;
|
1203 |
+
if ( isset( $rtmedia_query->is_gallery_shortcode ) && true === $rtmedia_query->is_gallery_shortcode ) {
|
1204 |
$parent_link = get_rtmedia_user_link( get_current_user_id() );
|
1205 |
}
|
1206 |
}
|
1207 |
}
|
1208 |
+
|
1209 |
return $parent_link;
|
1210 |
}
|
1211 |
|
1212 |
function get_rtmedia_permalink( $id ) {
|
1213 |
+
$media_model = new RTMediaModel();
|
1214 |
+
$media = $media_model->get( array( 'id' => intval( $id ) ) );
|
1215 |
global $rtmedia_query;
|
1216 |
|
1217 |
// Adding filter to get permalink for current blog
|
1218 |
add_filter( 'bp_get_root_domain', 'rtmedia_get_current_blog_url' );
|
1219 |
|
1220 |
+
if ( ! isset( $media[0]->context ) ) {
|
1221 |
+
if ( function_exists( 'bp_get_groups_root_slug' ) && isset( $rtmedia_query->query ) && isset( $rtmedia_query->query['context'] ) && 'group' === $rtmedia_query->query['context'] ) {
|
1222 |
+
$parent_link = get_rtmedia_group_link( $rtmedia_query->query['context_id'] );
|
1223 |
} else {
|
1224 |
// check for global album
|
1225 |
$parent_link = parentlink_global_album( $id );
|
1226 |
+
if ( '' === $parent_link ) {
|
1227 |
+
$parent_link = get_rtmedia_user_link( $media[0]->media_author );
|
1228 |
}
|
1229 |
}
|
1230 |
} else {
|
1231 |
+
if ( function_exists( 'bp_get_groups_root_slug' ) && 'group' === $media[0]->context ) {
|
1232 |
+
$parent_link = get_rtmedia_group_link( $media[0]->context_id );
|
1233 |
} else {
|
1234 |
// check for global album
|
1235 |
$parent_link = parentlink_global_album( $id );
|
1236 |
+
if ( '' === $parent_link ) {
|
1237 |
+
$parent_link = get_rtmedia_user_link( $media[0]->media_author );
|
1238 |
}
|
1239 |
}
|
1240 |
}
|
1253 |
} else {
|
1254 |
$parent_link = get_author_posts_url( $id );
|
1255 |
}
|
1256 |
+
|
1257 |
return $parent_link;
|
1258 |
}
|
1259 |
|
1267 |
|
1268 |
function get_rtmedia_group_link( $group_id ) {
|
1269 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
1270 |
+
|
1271 |
return apply_filters( 'rtmedia_get_group_link', bp_get_group_permalink( $group ) );
|
1272 |
}
|
1273 |
|
1274 |
function rtmedia_get_site_option( $option_name, $default = false ) {
|
1275 |
if ( is_multisite() ) {
|
1276 |
$return_val = get_option( $option_name, $default );
|
1277 |
+
if ( false === $return_val ) {
|
1278 |
$return_val = get_site_option( $option_name, $default );
|
1279 |
+
if ( false === $return_val ) {
|
1280 |
+
if ( function_exists( 'bp_get_option' ) ) {
|
1281 |
$return_val = bp_get_option( $option_name, $default );
|
1282 |
}
|
1283 |
}
|
1285 |
}
|
1286 |
} else {
|
1287 |
$return_val = get_site_option( $option_name, $default );
|
1288 |
+
if ( false === $return_val ) {
|
1289 |
+
if ( function_exists( 'bp_get_option' ) ) {
|
1290 |
$return_val = bp_get_option( $option_name, $default );
|
1291 |
rtmedia_update_site_option( $option_name, $return_val );
|
1292 |
}
|
1293 |
}
|
1294 |
}
|
1295 |
+
if ( false !== $default && false === $return_val ) {
|
1296 |
$return_val = $default;
|
1297 |
}
|
1298 |
+
|
1299 |
return $return_val;
|
1300 |
}
|
1301 |
|
1310 |
* using 'bpmedia_excerpt_lengths' hook
|
1311 |
*
|
1312 |
*/
|
|
app/main/contexts/RTMediaContext.php
CHANGED
@@ -29,17 +29,17 @@ class RTMediaContext {
|
|
29 |
*
|
30 |
* @return \RTMediaContext
|
31 |
*/
|
32 |
-
function __construct(){
|
33 |
$this->set_context();
|
34 |
|
35 |
return $this;
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
*/
|
41 |
-
function set_context(){
|
42 |
-
if ( class_exists( 'BuddyPress' ) ){
|
43 |
$this->set_bp_context();
|
44 |
} else {
|
45 |
$this->set_wp_context();
|
@@ -47,13 +47,13 @@ class RTMediaContext {
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
*
|
51 |
* @global type $post
|
52 |
*/
|
53 |
-
function set_wp_context(){
|
54 |
global $post;
|
55 |
global $bp;
|
56 |
-
if ( is_author() ){
|
57 |
$this->type = 'profile';
|
58 |
$this->id = get_query_var( 'author' );
|
59 |
} elseif ( isset( $post->post_type ) ) {
|
@@ -68,10 +68,10 @@ class RTMediaContext {
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
*/
|
73 |
-
function set_bp_context(){
|
74 |
-
if ( bp_is_blog_page() && ! is_home() ){
|
75 |
$this->set_wp_context();
|
76 |
} else {
|
77 |
$this->set_bp_component_context();
|
@@ -79,33 +79,33 @@ class RTMediaContext {
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
*
|
83 |
*/
|
84 |
-
function set_bp_component_context(){
|
85 |
-
if ( bp_displayed_user_id() && ! bp_is_group() ){
|
86 |
$this->type = 'profile';
|
87 |
} else {
|
88 |
-
if ( ! bp_displayed_user_id() && bp_is_group() ){
|
89 |
$this->type = 'group';
|
90 |
} else {
|
91 |
$this->type = 'profile';
|
92 |
}
|
93 |
}
|
94 |
$this->id = $this->get_current_bp_component_id();
|
95 |
-
if ( $this->id
|
96 |
global $bp;
|
97 |
$this->id = $bp->loggedin_user->id;
|
98 |
}
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
-
*
|
103 |
-
* @return
|
104 |
*/
|
105 |
-
function get_current_bp_component_id(){
|
106 |
switch ( bp_current_component() ) {
|
107 |
case 'groups':
|
108 |
-
if ( function_exists( 'bp_get_current_group_id' ) ){
|
109 |
return bp_get_current_group_id();
|
110 |
}
|
111 |
|
@@ -116,5 +116,4 @@ class RTMediaContext {
|
|
116 |
break;
|
117 |
}
|
118 |
}
|
119 |
-
|
120 |
}
|
29 |
*
|
30 |
* @return \RTMediaContext
|
31 |
*/
|
32 |
+
function __construct() {
|
33 |
$this->set_context();
|
34 |
|
35 |
return $this;
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
+
* Set current request context
|
40 |
*/
|
41 |
+
function set_context() {
|
42 |
+
if ( class_exists( 'BuddyPress' ) ) {
|
43 |
$this->set_bp_context();
|
44 |
} else {
|
45 |
$this->set_wp_context();
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Set WordPress context
|
51 |
* @global type $post
|
52 |
*/
|
53 |
+
function set_wp_context() {
|
54 |
global $post;
|
55 |
global $bp;
|
56 |
+
if ( is_author() ) {
|
57 |
$this->type = 'profile';
|
58 |
$this->id = get_query_var( 'author' );
|
59 |
} elseif ( isset( $post->post_type ) ) {
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Set BuddyPress context
|
72 |
*/
|
73 |
+
function set_bp_context() {
|
74 |
+
if ( bp_is_blog_page() && ! is_home() ) {
|
75 |
$this->set_wp_context();
|
76 |
} else {
|
77 |
$this->set_bp_component_context();
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Set BuddyPress component context
|
83 |
*/
|
84 |
+
function set_bp_component_context() {
|
85 |
+
if ( bp_displayed_user_id() && ! bp_is_group() ) {
|
86 |
$this->type = 'profile';
|
87 |
} else {
|
88 |
+
if ( ! bp_displayed_user_id() && bp_is_group() ) {
|
89 |
$this->type = 'group';
|
90 |
} else {
|
91 |
$this->type = 'profile';
|
92 |
}
|
93 |
}
|
94 |
$this->id = $this->get_current_bp_component_id();
|
95 |
+
if ( null === $this->id ) {
|
96 |
global $bp;
|
97 |
$this->id = $bp->loggedin_user->id;
|
98 |
}
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
+
* Get current bp component id
|
103 |
+
* @return int/null
|
104 |
*/
|
105 |
+
function get_current_bp_component_id() {
|
106 |
switch ( bp_current_component() ) {
|
107 |
case 'groups':
|
108 |
+
if ( function_exists( 'bp_get_current_group_id' ) ) {
|
109 |
return bp_get_current_group_id();
|
110 |
}
|
111 |
|
116 |
break;
|
117 |
}
|
118 |
}
|
|
|
119 |
}
|
app/main/controllers/activity/RTMediaActivity.php
CHANGED
@@ -17,7 +17,9 @@ class RTMediaActivity {
|
|
17 |
var $privacy;
|
18 |
|
19 |
/**
|
20 |
-
*
|
|
|
|
|
21 |
*/
|
22 |
function __construct( $media, $privacy = 0, $activity_text = false ) {
|
23 |
if ( ! isset( $media ) ) {
|
@@ -27,9 +29,9 @@ class RTMediaActivity {
|
|
27 |
$media = array( $media );
|
28 |
}
|
29 |
|
30 |
-
$this->media
|
31 |
$this->activity_text = bp_activity_filter_kses( $activity_text );
|
32 |
-
$this->privacy
|
33 |
}
|
34 |
|
35 |
function create_activity_html() {
|
@@ -45,25 +47,25 @@ class RTMediaActivity {
|
|
45 |
}
|
46 |
|
47 |
global $rtmedia;
|
48 |
-
if ( isset( $rtmedia->options[
|
49 |
-
$
|
50 |
} else {
|
51 |
-
$
|
52 |
}
|
53 |
|
54 |
-
$mediaObj
|
55 |
$media_details = $mediaObj->get( array( 'id' => $this->media ) );
|
56 |
|
57 |
-
if ( intval( $
|
58 |
-
$media_details = array_slice( $media_details, 0, $
|
59 |
}
|
60 |
$rtmedia_activity_ul_class = apply_filters( 'rtmedia_activity_ul_class', 'rtm-activity-media-list' );
|
61 |
-
$li_content
|
62 |
-
$count
|
63 |
foreach ( $media_details as $media ) {
|
64 |
-
$li_content .= '<li class="rtmedia-list-item media-type-' . $media->media_type . '">';
|
65 |
-
if ( 'photo'
|
66 |
-
$li_content .= '<a href ="' . get_rtmedia_permalink( $media->id ) . '">';
|
67 |
}
|
68 |
$li_content .= '<div class="rtmedia-item-thumbnail">';
|
69 |
|
@@ -72,25 +74,25 @@ class RTMediaActivity {
|
|
72 |
$li_content .= '</div>';
|
73 |
|
74 |
$li_content .= '<div class="rtmedia-item-title">';
|
75 |
-
$li_content .= '<h4 title="' . $media->media_title . '">';
|
76 |
-
if ( 'photo'
|
77 |
-
$li_content .= '<a href="' . get_rtmedia_permalink( $media->id ) . '">';
|
78 |
}
|
79 |
|
80 |
$li_content .= $media->media_title;
|
81 |
-
if ( 'photo'
|
82 |
$li_content .= '</a>';
|
83 |
}
|
84 |
$li_content .= '</h4>';
|
85 |
$li_content .= '</div>';
|
86 |
-
if ( 'photo'
|
87 |
$li_content .= '</a>';
|
88 |
}
|
89 |
|
90 |
$li_content .= '</li>';
|
91 |
$count ++;
|
92 |
}
|
93 |
-
$html .= '<ul class="rtmedia-list ' . $rtmedia_activity_ul_class . ' rtmedia-activity-media-length-' . $count . '">';
|
94 |
$html .= $li_content;
|
95 |
$html .= '</ul>';
|
96 |
$html .= '</div>';
|
@@ -106,32 +108,28 @@ class RTMediaActivity {
|
|
106 |
}
|
107 |
|
108 |
function media( $media ) {
|
|
|
109 |
if ( isset( $media->media_type ) ) {
|
110 |
global $rtmedia;
|
111 |
-
if ( 'photo'
|
112 |
$thumbnail_id = $media->media_id;
|
113 |
if ( $thumbnail_id ) {
|
114 |
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumbnail_id, apply_filters( 'rtmedia_activity_image_size', 'rt_media_activity_image' ) );
|
115 |
-
$html = '<img alt="' . $media->media_title . '" src="' . $src . '" />';
|
116 |
}
|
117 |
-
} elseif ( 'video'
|
118 |
$cover_art = rtmedia_get_cover_art_src( $media->id );
|
119 |
if ( $cover_art ) {
|
120 |
-
$poster = 'poster = "' . $cover_art . '"';
|
121 |
} else {
|
122 |
$poster = '';
|
123 |
}
|
124 |
-
$html = '<video ' . $poster . ' src="' . wp_get_attachment_url( $media->media_id ) . '" width="' . $rtmedia->options[
|
125 |
-
} elseif ( 'music'
|
126 |
-
$html = '<audio src="' . wp_get_attachment_url( $media->media_id ) . '" width="' . $rtmedia->options[
|
127 |
-
} else {
|
128 |
-
$html = false;
|
129 |
}
|
130 |
-
} else {
|
131 |
-
$html = false;
|
132 |
}
|
133 |
|
134 |
return apply_filters( 'rtmedia_single_activity_filter', $html, $media, true );
|
135 |
}
|
136 |
-
|
137 |
}
|
17 |
var $privacy;
|
18 |
|
19 |
/**
|
20 |
+
* @param $media
|
21 |
+
* @param int $privacy
|
22 |
+
* @param bool $activity_text
|
23 |
*/
|
24 |
function __construct( $media, $privacy = 0, $activity_text = false ) {
|
25 |
if ( ! isset( $media ) ) {
|
29 |
$media = array( $media );
|
30 |
}
|
31 |
|
32 |
+
$this->media = $media;
|
33 |
$this->activity_text = bp_activity_filter_kses( $activity_text );
|
34 |
+
$this->privacy = $privacy;
|
35 |
}
|
36 |
|
37 |
function create_activity_html() {
|
47 |
}
|
48 |
|
49 |
global $rtmedia;
|
50 |
+
if ( isset( $rtmedia->options['buddypress_limitOnActivity'] ) ) {
|
51 |
+
$limit_activity_feed = $rtmedia->options['buddypress_limitOnActivity'];
|
52 |
} else {
|
53 |
+
$limit_activity_feed = 0;
|
54 |
}
|
55 |
|
56 |
+
$mediaObj = new RTMediaModel();
|
57 |
$media_details = $mediaObj->get( array( 'id' => $this->media ) );
|
58 |
|
59 |
+
if ( intval( $limit_activity_feed ) > 0 ) {
|
60 |
+
$media_details = array_slice( $media_details, 0, $limit_activity_feed, true );
|
61 |
}
|
62 |
$rtmedia_activity_ul_class = apply_filters( 'rtmedia_activity_ul_class', 'rtm-activity-media-list' );
|
63 |
+
$li_content = '';
|
64 |
+
$count = 0;
|
65 |
foreach ( $media_details as $media ) {
|
66 |
+
$li_content .= '<li class="rtmedia-list-item media-type-' . esc_attr( $media->media_type ) . '">';
|
67 |
+
if ( 'photo' === $media->media_type ) {
|
68 |
+
$li_content .= '<a href ="' . esc_url( get_rtmedia_permalink( $media->id ) ) . '">';
|
69 |
}
|
70 |
$li_content .= '<div class="rtmedia-item-thumbnail">';
|
71 |
|
74 |
$li_content .= '</div>';
|
75 |
|
76 |
$li_content .= '<div class="rtmedia-item-title">';
|
77 |
+
$li_content .= '<h4 title="' . esc_attr( $media->media_title ) . '">';
|
78 |
+
if ( 'photo' !== $media->media_type ) {
|
79 |
+
$li_content .= '<a href="' . esc_url( get_rtmedia_permalink( $media->id ) ) . '">';
|
80 |
}
|
81 |
|
82 |
$li_content .= $media->media_title;
|
83 |
+
if ( 'photo' !== $media->media_type ) {
|
84 |
$li_content .= '</a>';
|
85 |
}
|
86 |
$li_content .= '</h4>';
|
87 |
$li_content .= '</div>';
|
88 |
+
if ( 'photo' === $media->media_type ) {
|
89 |
$li_content .= '</a>';
|
90 |
}
|
91 |
|
92 |
$li_content .= '</li>';
|
93 |
$count ++;
|
94 |
}
|
95 |
+
$html .= '<ul class="rtmedia-list ' . esc_attr( $rtmedia_activity_ul_class ) . ' rtmedia-activity-media-length-' . esc_attr( $count ) . '">';
|
96 |
$html .= $li_content;
|
97 |
$html .= '</ul>';
|
98 |
$html .= '</div>';
|
108 |
}
|
109 |
|
110 |
function media( $media ) {
|
111 |
+
$html = false;
|
112 |
if ( isset( $media->media_type ) ) {
|
113 |
global $rtmedia;
|
114 |
+
if ( 'photo' === $media->media_type ) {
|
115 |
$thumbnail_id = $media->media_id;
|
116 |
if ( $thumbnail_id ) {
|
117 |
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumbnail_id, apply_filters( 'rtmedia_activity_image_size', 'rt_media_activity_image' ) );
|
118 |
+
$html = '<img alt="' . esc_attr( $media->media_title ) . '" src="' . esc_url( $src ) . '" />';
|
119 |
}
|
120 |
+
} elseif ( 'video' === $media->media_type ) {
|
121 |
$cover_art = rtmedia_get_cover_art_src( $media->id );
|
122 |
if ( $cover_art ) {
|
123 |
+
$poster = 'poster = "' . esc_url( $cover_art ) . '"';
|
124 |
} else {
|
125 |
$poster = '';
|
126 |
}
|
127 |
+
$html = '<video ' . $poster . ' src="' . esc_url( wp_get_attachment_url( $media->media_id ) ) . '" width="' . esc_attr( $rtmedia->options['defaultSizes_video_activityPlayer_width'] ) . '" height="' . esc_attr( $rtmedia->options['defaultSizes_video_activityPlayer_height'] ) . '" type="video/mp4" class="wp-video-shortcode" id="rt_media_video_' . esc_attr( $media->id ) . '" controls="controls" preload="none"></video>';
|
128 |
+
} elseif ( 'music' === $media->media_type ) {
|
129 |
+
$html = '<audio src="' . esc_url( wp_get_attachment_url( $media->media_id ) ) . '" width="' . esc_attr( $rtmedia->options['defaultSizes_music_activityPlayer_width'] ) . '" height="0" type="audio/mp3" class="wp-audio-shortcode" id="rt_media_audio_' . esc_attr( $media->id ) . '" controls="controls" preload="none"></audio>';
|
|
|
|
|
130 |
}
|
|
|
|
|
131 |
}
|
132 |
|
133 |
return apply_filters( 'rtmedia_single_activity_filter', $html, $media, true );
|
134 |
}
|
|
|
135 |
}
|
app/main/controllers/activity/RTMediaBuddyPressActivity.php
CHANGED
@@ -12,9 +12,9 @@
|
|
12 |
*/
|
13 |
class RTMediaBuddyPressActivity {
|
14 |
|
15 |
-
function __construct(){
|
16 |
global $rtmedia;
|
17 |
-
if ( 0
|
18 |
add_action( 'bp_after_activity_post_form', array( &$this, 'bp_after_activity_post_form' ) );
|
19 |
add_action( 'bp_activity_posted_update', array( &$this, 'bp_activity_posted_update' ), 99, 3 );
|
20 |
|
@@ -28,27 +28,26 @@ class RTMediaBuddyPressActivity {
|
|
28 |
add_filter( 'bp_activity_allowed_tags', array( &$this, 'override_allowed_tags' ) );
|
29 |
add_filter( 'bp_get_activity_parent_content', array( &$this, 'bp_get_activity_parent_content' ) );
|
30 |
add_action( 'bp_activity_deleted_activities', array( &$this, 'bp_activity_deleted_activities' ) );
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
// BuddyPress activity for media like action
|
36 |
-
if ( isset( $rtmedia->options['buddypress_mediaLikeActivity'] ) && 0
|
37 |
add_action( 'rtmedia_after_like_media', array( $this, 'activity_after_media_like' ) );
|
38 |
}
|
39 |
|
40 |
// BuddyPress activity for media comment action
|
41 |
-
if ( isset( $rtmedia->options['buddypress_mediaCommentActivity'] ) && 0
|
42 |
add_action( 'rtmedia_after_add_comment', array( $this, 'activity_after_media_comment' ) );
|
43 |
add_action( 'rtmedia_before_remove_comment', array( $this, 'remove_activity_after_media_comment_delete' ) );
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
function bp_activity_deleted_activities( $activity_ids_deleted ){
|
48 |
-
//$activity_ids_deleted
|
49 |
$rt_model = new RTMediaModel();
|
50 |
$all_media = $rt_model->get( array( 'activity_id' => $activity_ids_deleted ) );
|
51 |
-
if ( $all_media ){
|
52 |
$media = new RTMediaMedia();
|
53 |
remove_action( 'bp_activity_deleted_activities', array( &$this, 'bp_activity_deleted_activities' ) );
|
54 |
foreach ( $all_media as $single_media ) {
|
@@ -57,21 +56,21 @@ class RTMediaBuddyPressActivity {
|
|
57 |
}
|
58 |
}
|
59 |
|
60 |
-
function bp_get_activity_parent_content( $content ){
|
61 |
global $activities_template;
|
62 |
|
63 |
// Get the ID of the parent activity content
|
64 |
-
if ( ! $parent_id = $activities_template->activity->item_id ){
|
65 |
return false;
|
66 |
}
|
67 |
|
68 |
// Bail if no parent content
|
69 |
-
if ( empty( $activities_template->activity_parents[ $parent_id ] ) ){
|
70 |
return false;
|
71 |
}
|
72 |
|
73 |
// Bail if no action
|
74 |
-
if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ){
|
75 |
return false;
|
76 |
}
|
77 |
|
@@ -79,7 +78,7 @@ class RTMediaBuddyPressActivity {
|
|
79 |
$content = $activities_template->activity_parents[ $parent_id ]->action;
|
80 |
|
81 |
// Maybe append activity content, if it exists
|
82 |
-
if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ){
|
83 |
$content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
|
84 |
}
|
85 |
|
@@ -89,76 +88,91 @@ class RTMediaBuddyPressActivity {
|
|
89 |
return $content;
|
90 |
}
|
91 |
|
92 |
-
function delete_comment_sync( $activity_id, $comment_id ){
|
93 |
global $wpdb;
|
94 |
-
$comment_id = $wpdb->get_var( $wpdb->prepare( "select comment_id from {$wpdb->commentmeta} where meta_key = 'activity_id' and meta_value
|
95 |
-
if ( $comment_id ){
|
96 |
wp_delete_comment( $comment_id, true );
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
function comment_sync( $comment_id, $param ){
|
101 |
-
|
102 |
-
$
|
103 |
-
$
|
104 |
-
|
105 |
-
if ( ! empty( $user_id ) ){
|
106 |
$user_data = get_userdata( $user_id );
|
107 |
$comment_author = $user_data->data->user_login;
|
108 |
}
|
109 |
$mediamodel = new RTMediaModel();
|
110 |
$media = $mediamodel->get( array( 'activity_id' => $param['activity_id'] ) );
|
111 |
// if there is only single media in activity
|
112 |
-
if ( 1
|
113 |
$media_id = $media[0]->media_id;
|
114 |
$comment = new RTMediaComment();
|
115 |
-
$id = $comment->add( array(
|
|
|
|
|
|
|
|
|
|
|
116 |
update_comment_meta( $id, 'activity_id', $comment_id );
|
117 |
}
|
118 |
}
|
119 |
|
120 |
-
function non_threaded_comments(){
|
121 |
-
|
122 |
-
|
|
|
123 |
$act = new BP_Activity_Activity( $activity_id );
|
124 |
|
125 |
-
if ( 'rtmedia_update'
|
126 |
-
$_POST['comment_id'] = $
|
127 |
}
|
128 |
}
|
129 |
}
|
130 |
|
131 |
-
function bp_groups_posted_update( $content, $user_id, $group_id, $activity_id ){
|
132 |
$this->bp_activity_posted_update( $content, $user_id, $activity_id );
|
133 |
}
|
134 |
|
135 |
-
function bp_activity_posted_update( $content, $user_id, $activity_id ){
|
136 |
global $wpdb, $bp;
|
137 |
$updated_content = '';
|
138 |
|
139 |
// hook for rtmedia buddypress before activity posted
|
140 |
do_action( 'rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id );
|
141 |
|
142 |
-
|
143 |
-
|
|
|
144 |
|
145 |
-
$
|
146 |
-
$html_content = $
|
147 |
bp_activity_update_meta( $activity_id, 'bp_old_activity_content', $html_content );
|
148 |
bp_activity_update_meta( $activity_id, 'bp_activity_text', $updated_content );
|
149 |
-
$wpdb->update( $bp->activity->table_name, array(
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
// hook for rtmedia buddypress after activity posted
|
155 |
do_action( 'rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id );
|
156 |
-
|
157 |
-
if (
|
158 |
$privacy = - 1;
|
159 |
-
if ( is_rtmedia_privacy_enable() ){
|
160 |
-
if ( is_rtmedia_privacy_user_overide() ){
|
161 |
-
$privacy = $
|
162 |
} else {
|
163 |
$privacy = get_rtmedia_default_privacy();
|
164 |
}
|
@@ -166,10 +180,18 @@ class RTMediaBuddyPressActivity {
|
|
166 |
bp_activity_update_meta( $activity_id, 'rtmedia_privacy', $privacy );
|
167 |
// insert/update activity details in rtmedia activity table
|
168 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
169 |
-
if ( ! $rtmedia_activity_model->check( $activity_id ) ){
|
170 |
-
$rtmedia_activity_model->insert( array(
|
|
|
|
|
|
|
|
|
171 |
} else {
|
172 |
-
$rtmedia_activity_model->update( array(
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
}
|
175 |
}
|
@@ -181,86 +203,106 @@ class RTMediaBuddyPressActivity {
|
|
181 |
* @param $user_id
|
182 |
* @param $activity_id
|
183 |
*/
|
184 |
-
function manage_user_last_activity_update( $content, $user_id, $activity_id ){
|
185 |
-
global $wpdb
|
186 |
|
187 |
// do not proceed if not allowed
|
188 |
-
if( ! apply_filters( 'rtm_manage_user_last_activity_update', true, $activity_id ) ){
|
189 |
return;
|
190 |
}
|
191 |
$rtm_activity_model = new RTMediaActivityModel();
|
192 |
|
193 |
$rtm_activity_obj = $rtm_activity_model->get( array( 'activity_id' => $activity_id ) );
|
194 |
|
195 |
-
if( !empty( $rtm_activity_obj ) ){
|
196 |
-
if( isset( $rtm_activity_obj[0]->privacy ) && $rtm_activity_obj[0]->privacy > 0 ){
|
197 |
|
198 |
$get_columns = array(
|
199 |
'activity_id' => array(
|
200 |
'compare' => '<',
|
201 |
-
'value'
|
202 |
),
|
203 |
-
'user_id'
|
204 |
-
'privacy'
|
205 |
'compare' => '<=',
|
206 |
-
'value'
|
207 |
),
|
208 |
);
|
209 |
|
210 |
// get user's latest public activity update
|
211 |
$new_last_activity_obj = $rtm_activity_model->get( $get_columns, 0, 1 );
|
212 |
|
213 |
-
if( !empty( $new_last_activity_obj ) ){
|
214 |
// latest public activity id
|
215 |
$public_activity_id = $new_last_activity_obj[0]->activity_id;
|
216 |
|
217 |
// latest public activity content
|
218 |
$activity_content = bp_activity_get_meta( $public_activity_id, 'bp_activity_text' );
|
219 |
-
if( empty( $activity_content ) ){
|
220 |
-
$activity_content = $wpdb->get_var( "SELECT content FROM {$bp->activity->table_name} WHERE id = $public_activity_id
|
221 |
}
|
222 |
$activity_content = apply_filters( 'bp_activity_latest_update_content', $activity_content, $activity_content );
|
223 |
|
224 |
// update user's latest update
|
225 |
bp_update_user_meta( $user_id, 'bp_latest_update', array(
|
226 |
'id' => $public_activity_id,
|
227 |
-
'content' => $activity_content
|
228 |
) );
|
229 |
}
|
230 |
}
|
231 |
}
|
232 |
}
|
233 |
|
234 |
-
function bp_after_activity_post_form(){
|
235 |
-
$
|
|
|
236 |
$slug_split = explode( '/', $url );
|
237 |
// check position of media slug for end of the URL
|
238 |
-
if ( $slug_split[
|
239 |
// replace media slug with the blank space
|
240 |
-
$slug_split[
|
241 |
-
$url_upload
|
242 |
-
$url
|
243 |
} else {
|
244 |
-
$url = trailingslashit
|
245 |
}
|
246 |
-
if ( rtmedia_is_uploader_view_allowed( true, 'activity' ) ){
|
247 |
$params = array(
|
248 |
-
'url'
|
249 |
-
'runtimes'
|
250 |
-
'browse_button'
|
251 |
-
|
252 |
-
'
|
253 |
-
'
|
254 |
-
|
255 |
-
'
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
258 |
-
'file_data_name'
|
259 |
-
|
260 |
-
'
|
261 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
);
|
263 |
-
if ( wp_is_mobile() ){
|
264 |
$params['multi_selection'] = false;
|
265 |
}
|
266 |
$params = apply_filters( 'rtmedia_modify_upload_params', $params );
|
@@ -271,16 +313,16 @@ class RTMediaBuddyPressActivity {
|
|
271 |
wp_localize_script( 'rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed );
|
272 |
wp_localize_script( 'rtmedia-backbone', 'rtMedia_update_plupload_config', $params );
|
273 |
|
274 |
-
$
|
275 |
-
$
|
276 |
} else {
|
277 |
-
echo "<div class='rtmedia-upload-not-allowed'>" . apply_filters( 'rtmedia_upload_not_allowed_message',
|
278 |
}
|
279 |
}
|
280 |
|
281 |
-
function override_allowed_tags( $activity_allowedtags ){
|
282 |
|
283 |
-
$activity_allowedtags['video']
|
284 |
$activity_allowedtags['video']['id'] = array();
|
285 |
$activity_allowedtags['video']['class'] = array();
|
286 |
$activity_allowedtags['video']['src'] = array();
|
@@ -291,7 +333,7 @@ class RTMediaBuddyPressActivity {
|
|
291 |
$activity_allowedtags['video']['width'] = array();
|
292 |
$activity_allowedtags['video']['height'] = array();
|
293 |
$activity_allowedtags['video']['poster'] = array();
|
294 |
-
$activity_allowedtags['audio']
|
295 |
$activity_allowedtags['audio']['id'] = array();
|
296 |
$activity_allowedtags['audio']['class'] = array();
|
297 |
$activity_allowedtags['audio']['src'] = array();
|
@@ -301,148 +343,146 @@ class RTMediaBuddyPressActivity {
|
|
301 |
$activity_allowedtags['audio']['title'] = array();
|
302 |
$activity_allowedtags['audio']['width'] = array();
|
303 |
$activity_allowedtags['audio']['poster'] = array();
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
$activity_allowedtags['div']['id']
|
310 |
-
$activity_allowedtags['div']['class']
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$activity_allowedtags['a']['title']
|
317 |
-
$activity_allowedtags['a']['href']
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
$activity_allowedtags['ul']['class']
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
$activity_allowedtags['li']['class']
|
329 |
-
|
330 |
-
/* Legacy Code */
|
331 |
-
//$activity_allowedtags[ 'script' ] = array( );
|
332 |
-
//$activity_allowedtags[ 'script' ][ 'type' ] = array( );
|
333 |
|
334 |
return $activity_allowedtags;
|
335 |
}
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
|
|
|
|
435 |
|
436 |
/**
|
437 |
* Create BP activity when user like and delete associated activity when user remove like.
|
438 |
*
|
439 |
* @param $obj RTMediaLike
|
440 |
*/
|
441 |
-
function activity_after_media_like( $obj ){
|
442 |
global $rtmedia_points_media_id;
|
443 |
-
if( is_a( $obj, 'RTMediaLike' ) && isset( $obj->action_query->id ) ){
|
444 |
$media_id = $obj->action_query->id;
|
445 |
-
} elseif( ! empty( $rtmedia_points_media_id ) ){
|
446 |
$media_id = $rtmedia_points_media_id;
|
447 |
} else {
|
448 |
$media_id = false;
|
@@ -451,56 +491,56 @@ class RTMediaBuddyPressActivity {
|
|
451 |
$media_obj = $obj->media;
|
452 |
|
453 |
// Proceed only if we have media to process.
|
454 |
-
if(
|
455 |
|
456 |
$user_id = $obj->interactor;
|
457 |
|
458 |
// If $obj->increase is true than request is to like the media.
|
459 |
-
if( $obj->increase ){
|
460 |
|
461 |
// Create activity on media like
|
462 |
-
$user
|
463 |
-
$username = '<a href="' . get_rtmedia_user_link( $user_id ) . '">' . $user->display_name . '</a>';
|
464 |
|
465 |
$media_author = $obj->owner;
|
466 |
|
467 |
$primary_link = get_rtmedia_permalink( $media_id );
|
468 |
|
469 |
$media_const = 'RTMEDIA_' . strtoupper( $obj->media->media_type ) . '_LABEL';
|
470 |
-
$media_str
|
471 |
|
472 |
-
if( $media_obj->context
|
473 |
$group_data = groups_get_group( array( 'group_id' => $media_obj->context_id ) );
|
474 |
-
$group_name = '<a href="' . bp_get_group_permalink( $group_data ) . '">' . $group_data->name . '</a>';
|
475 |
-
$action
|
476 |
} else {
|
477 |
-
if( $user_id
|
478 |
-
$action = sprintf(
|
479 |
} else {
|
480 |
$media_author_data = get_userdata( $media_author );
|
481 |
-
$media_author_name = '<a href="' . get_rtmedia_user_link( $media_author ) . '">' . $media_author_data->display_name . '</a>';
|
482 |
-
$action
|
483 |
}
|
484 |
}
|
485 |
|
486 |
-
$action
|
487 |
$primary_link = get_rtmedia_permalink( $media_id );
|
488 |
|
489 |
// generate activity arguments.
|
490 |
$activity_args = array(
|
491 |
-
'user_id'
|
492 |
-
'action'
|
493 |
-
'type'
|
494 |
'primary_link' => $primary_link,
|
495 |
-
'item_id'
|
496 |
);
|
497 |
|
498 |
// set activity component
|
499 |
-
if( $media_obj->context
|
500 |
-
$activity_args[
|
501 |
-
if( $media_obj->context
|
502 |
-
$activity_args[
|
503 |
-
$activity_args[
|
504 |
}
|
505 |
}
|
506 |
|
@@ -508,15 +548,18 @@ class RTMediaBuddyPressActivity {
|
|
508 |
$activity_id = bp_activity_add( $activity_args );
|
509 |
|
510 |
// Store activity id into user meta for reference
|
|
|
511 |
update_user_meta( $user_id, 'rtm-bp-media-like-activity-' . $media_id, $activity_id );
|
512 |
} else {
|
513 |
|
514 |
$meta_key = 'rtm-bp-media-like-activity-' . $media_id;
|
515 |
// Delete activity when user remove his like.
|
|
|
516 |
$activity_id = get_user_meta( $user_id, $meta_key, true );
|
517 |
|
518 |
-
if( ! empty( $activity_id ) ){
|
519 |
-
if( bp_activity_delete( array( 'id' => $activity_id ) ) ){
|
|
|
520 |
delete_user_meta( $user_id, $meta_key );
|
521 |
}
|
522 |
}
|
@@ -529,65 +572,65 @@ class RTMediaBuddyPressActivity {
|
|
529 |
*
|
530 |
* @param $params array
|
531 |
*/
|
532 |
-
function activity_after_media_comment( $params ){
|
533 |
|
534 |
-
if( isset( $params['comment_post_ID'] ) ){
|
535 |
|
536 |
// get media details
|
537 |
$media_model = new RTMediaModel();
|
538 |
-
$media_obj
|
539 |
-
$media_obj
|
540 |
|
541 |
// only proceed if corresponding media is exist.
|
542 |
-
if( ! empty( $media_obj ) && ( $media_obj->context
|
543 |
|
544 |
$media_id = $media_obj->id;
|
545 |
|
546 |
-
$user_id
|
547 |
-
$user
|
548 |
-
$username = '<a href="' . get_rtmedia_user_link( $user_id ) . '">' . $user->display_name . '</a>';
|
549 |
|
550 |
$primary_link = get_rtmedia_permalink( $media_id );
|
551 |
|
552 |
$media_const = 'RTMEDIA_' . strtoupper( $media_obj->media_type ) . '_LABEL';
|
553 |
-
$media_str
|
554 |
|
555 |
$media_author = $media_obj->media_author;
|
556 |
|
557 |
-
if( $media_obj->context
|
558 |
$group_data = groups_get_group( array( 'group_id' => $media_obj->context_id ) );
|
559 |
-
$group_name = '<a href="' . bp_get_group_permalink( $group_data ) . '">' . $group_data->name . '</a>';
|
560 |
-
$action
|
561 |
} else {
|
562 |
-
if( $user_id
|
563 |
-
$action = sprintf(
|
564 |
} else {
|
565 |
$media_author_data = get_userdata( $media_author );
|
566 |
-
$media_author_name = '<a href="' . get_rtmedia_user_link( $media_author ) . '">' . $media_author_data->display_name . '</a>';
|
567 |
-
$action
|
568 |
}
|
569 |
}
|
570 |
|
571 |
$comment_content = $params['comment_content'];
|
572 |
-
$wp_comment_id
|
573 |
|
574 |
// prepare activity arguments
|
575 |
$activity_args = array(
|
576 |
-
'user_id'
|
577 |
-
'action'
|
578 |
-
'content'
|
579 |
-
'type'
|
580 |
-
'primary_link'
|
581 |
-
'item_id'
|
582 |
-
'secondary_item_id' => $wp_comment_id
|
583 |
);
|
584 |
|
585 |
// set activity component
|
586 |
-
if( $media_obj->context
|
587 |
-
$activity_args[
|
588 |
-
if( $media_obj->context
|
589 |
-
$activity_args[
|
590 |
-
$activity_args[
|
591 |
}
|
592 |
}
|
593 |
|
@@ -595,6 +638,7 @@ class RTMediaBuddyPressActivity {
|
|
595 |
$activity_id = bp_activity_add( $activity_args );
|
596 |
|
597 |
// Store activity id into user meta for reference
|
|
|
598 |
update_user_meta( $user_id, 'rtm-bp-media-comment-activity-' . $media_id . '-' . $wp_comment_id, $activity_id );
|
599 |
}
|
600 |
}
|
@@ -605,26 +649,28 @@ class RTMediaBuddyPressActivity {
|
|
605 |
*
|
606 |
* @param $comment_id
|
607 |
*/
|
608 |
-
function remove_activity_after_media_comment_delete( $comment_id ){
|
609 |
-
if( !empty( $comment_id ) ) {
|
610 |
|
611 |
// get comment details from comment id
|
612 |
$comment = get_comment( $comment_id );
|
613 |
$user_id = $comment->user_id;
|
614 |
|
615 |
-
if( isset( $comment->comment_post_ID ) && isset( $comment->user_id ) ){
|
616 |
-
$model
|
617 |
$media_obj = $model->get( array( 'media_id' => $comment->comment_post_ID ) );
|
618 |
$media_obj = $media_obj[0];
|
619 |
|
620 |
-
if( ! empty( $media_obj ) ){
|
621 |
$meta_key = 'rtm-bp-media-comment-activity-' . $media_obj->id . '-' . $comment_id;
|
622 |
|
623 |
// Delete activity when user remove his comment.
|
|
|
624 |
$activity_id = get_user_meta( $user_id, $meta_key, true );
|
625 |
|
626 |
-
if( ! empty( $activity_id ) ){
|
627 |
-
if( bp_activity_delete( array( 'id' => $activity_id ) ) ){
|
|
|
628 |
delete_user_meta( $user_id, $meta_key );
|
629 |
}
|
630 |
}
|
@@ -632,5 +678,4 @@ class RTMediaBuddyPressActivity {
|
|
632 |
}
|
633 |
}
|
634 |
}
|
635 |
-
|
636 |
}
|
12 |
*/
|
13 |
class RTMediaBuddyPressActivity {
|
14 |
|
15 |
+
function __construct() {
|
16 |
global $rtmedia;
|
17 |
+
if ( 0 !== intval( $rtmedia->options['buddypress_enableOnActivity'] ) ) {
|
18 |
add_action( 'bp_after_activity_post_form', array( &$this, 'bp_after_activity_post_form' ) );
|
19 |
add_action( 'bp_activity_posted_update', array( &$this, 'bp_activity_posted_update' ), 99, 3 );
|
20 |
|
28 |
add_filter( 'bp_activity_allowed_tags', array( &$this, 'override_allowed_tags' ) );
|
29 |
add_filter( 'bp_get_activity_parent_content', array( &$this, 'bp_get_activity_parent_content' ) );
|
30 |
add_action( 'bp_activity_deleted_activities', array( &$this, 'bp_activity_deleted_activities' ) );
|
31 |
+
|
32 |
+
// Filter bp_activity_prefetch_object_data for translatable activity actions
|
33 |
+
add_filter( 'bp_activity_prefetch_object_data', array( $this, 'bp_prefetch_activity_object_data' ), 10, 1 );
|
34 |
|
35 |
// BuddyPress activity for media like action
|
36 |
+
if ( isset( $rtmedia->options['buddypress_mediaLikeActivity'] ) && 0 !== intval( $rtmedia->options['buddypress_mediaLikeActivity'] ) ) {
|
37 |
add_action( 'rtmedia_after_like_media', array( $this, 'activity_after_media_like' ) );
|
38 |
}
|
39 |
|
40 |
// BuddyPress activity for media comment action
|
41 |
+
if ( isset( $rtmedia->options['buddypress_mediaCommentActivity'] ) && 0 !== intval( $rtmedia->options['buddypress_mediaCommentActivity'] ) ) {
|
42 |
add_action( 'rtmedia_after_add_comment', array( $this, 'activity_after_media_comment' ) );
|
43 |
add_action( 'rtmedia_before_remove_comment', array( $this, 'remove_activity_after_media_comment_delete' ) );
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
function bp_activity_deleted_activities( $activity_ids_deleted ) {
|
|
|
48 |
$rt_model = new RTMediaModel();
|
49 |
$all_media = $rt_model->get( array( 'activity_id' => $activity_ids_deleted ) );
|
50 |
+
if ( $all_media ) {
|
51 |
$media = new RTMediaMedia();
|
52 |
remove_action( 'bp_activity_deleted_activities', array( &$this, 'bp_activity_deleted_activities' ) );
|
53 |
foreach ( $all_media as $single_media ) {
|
56 |
}
|
57 |
}
|
58 |
|
59 |
+
function bp_get_activity_parent_content( $content ) {
|
60 |
global $activities_template;
|
61 |
|
62 |
// Get the ID of the parent activity content
|
63 |
+
if ( ! $parent_id = $activities_template->activity->item_id ) {
|
64 |
return false;
|
65 |
}
|
66 |
|
67 |
// Bail if no parent content
|
68 |
+
if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
|
69 |
return false;
|
70 |
}
|
71 |
|
72 |
// Bail if no action
|
73 |
+
if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
|
74 |
return false;
|
75 |
}
|
76 |
|
78 |
$content = $activities_template->activity_parents[ $parent_id ]->action;
|
79 |
|
80 |
// Maybe append activity content, if it exists
|
81 |
+
if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
|
82 |
$content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
|
83 |
}
|
84 |
|
88 |
return $content;
|
89 |
}
|
90 |
|
91 |
+
function delete_comment_sync( $activity_id, $comment_id ) {
|
92 |
global $wpdb;
|
93 |
+
$comment_id = $wpdb->get_var( $wpdb->prepare( "select comment_id from {$wpdb->commentmeta} where meta_key = 'activity_id' and meta_value = %s", $comment_id ) );
|
94 |
+
if ( $comment_id ) {
|
95 |
wp_delete_comment( $comment_id, true );
|
96 |
}
|
97 |
}
|
98 |
|
99 |
+
function comment_sync( $comment_id, $param ) {
|
100 |
+
$default_args = array( 'user_id' => '', 'comment_author' => '' );
|
101 |
+
$param = wp_parse_args( $param, $default_args );
|
102 |
+
$user_id = $param['user_id'];
|
103 |
+
$comment_author = $param['comment_author'];
|
104 |
+
if ( ! empty( $user_id ) ) {
|
105 |
$user_data = get_userdata( $user_id );
|
106 |
$comment_author = $user_data->data->user_login;
|
107 |
}
|
108 |
$mediamodel = new RTMediaModel();
|
109 |
$media = $mediamodel->get( array( 'activity_id' => $param['activity_id'] ) );
|
110 |
// if there is only single media in activity
|
111 |
+
if ( 1 === count( $media ) && isset( $media[0]->media_id ) ) {
|
112 |
$media_id = $media[0]->media_id;
|
113 |
$comment = new RTMediaComment();
|
114 |
+
$id = $comment->add( array(
|
115 |
+
'comment_content' => $param['content'],
|
116 |
+
'comment_post_ID' => $media_id,
|
117 |
+
'user_id' => $user_id,
|
118 |
+
'comment_author' => $comment_author,
|
119 |
+
) );
|
120 |
update_comment_meta( $id, 'activity_id', $comment_id );
|
121 |
}
|
122 |
}
|
123 |
|
124 |
+
function non_threaded_comments() {
|
125 |
+
$action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING );
|
126 |
+
if ( 'new_activity_comment' === $action ) {
|
127 |
+
$activity_id = filter_input( INPUT_POST, 'form_id', FILTER_SANITIZE_NUMBER_INT );
|
128 |
$act = new BP_Activity_Activity( $activity_id );
|
129 |
|
130 |
+
if ( 'rtmedia_update' === $act->type ) {
|
131 |
+
$_POST['comment_id'] = $activity_id;
|
132 |
}
|
133 |
}
|
134 |
}
|
135 |
|
136 |
+
function bp_groups_posted_update( $content, $user_id, $group_id, $activity_id ) {
|
137 |
$this->bp_activity_posted_update( $content, $user_id, $activity_id );
|
138 |
}
|
139 |
|
140 |
+
function bp_activity_posted_update( $content, $user_id, $activity_id ) {
|
141 |
global $wpdb, $bp;
|
142 |
$updated_content = '';
|
143 |
|
144 |
// hook for rtmedia buddypress before activity posted
|
145 |
do_action( 'rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id );
|
146 |
|
147 |
+
$rtmedia_attached_files = filter_input( INPUT_POST, 'rtMedia_attached_files', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
148 |
+
if ( is_array( $rtmedia_attached_files ) ) {
|
149 |
+
$updated_content = $wpdb->get_var( "select content from {$bp->activity->table_name} where id= $activity_id limit 1" ); // @codingStandardsIgnoreLine
|
150 |
|
151 |
+
$obj_activity = new RTMediaActivity( $rtmedia_attached_files, 0, $updated_content );
|
152 |
+
$html_content = $obj_activity->create_activity_html();
|
153 |
bp_activity_update_meta( $activity_id, 'bp_old_activity_content', $html_content );
|
154 |
bp_activity_update_meta( $activity_id, 'bp_activity_text', $updated_content );
|
155 |
+
$wpdb->update( $bp->activity->table_name, array(
|
156 |
+
'type' => 'rtmedia_update',
|
157 |
+
'content' => $html_content,
|
158 |
+
), array( 'id' => $activity_id ) );
|
159 |
+
$media_obj = new RTMediaModel();
|
160 |
+
//Credit faisal : https://gist.github.com/faishal/c4306ae7267fff976465
|
161 |
+
$in_str_arr = array_fill( 0, count( $rtmedia_attached_files ), '%d' );
|
162 |
+
$in_str = join( ',', $in_str_arr );
|
163 |
+
$sql = $wpdb->prepare( "update {$media_obj->table_name} set activity_id = %d where blog_id = %d and ", $activity_id, get_current_blog_id() ); // @codingStandardsIgnoreLine
|
164 |
+
$form_id_where = $wpdb->prepare( "id IN ($in_str)", $rtmedia_attached_files );
|
165 |
+
$sql .= $form_id_where;
|
166 |
+
$wpdb->query( $sql );// @codingStandardsIgnoreLine
|
167 |
}
|
168 |
// hook for rtmedia buddypress after activity posted
|
169 |
do_action( 'rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id );
|
170 |
+
$rtmedia_privacy = filter_input( INPUT_POST, 'rtmedia-privacy', FILTER_SANITIZE_NUMBER_INT );
|
171 |
+
if ( null !== $rtmedia_privacy ) {
|
172 |
$privacy = - 1;
|
173 |
+
if ( is_rtmedia_privacy_enable() ) {
|
174 |
+
if ( is_rtmedia_privacy_user_overide() ) {
|
175 |
+
$privacy = $rtmedia_privacy;
|
176 |
} else {
|
177 |
$privacy = get_rtmedia_default_privacy();
|
178 |
}
|
180 |
bp_activity_update_meta( $activity_id, 'rtmedia_privacy', $privacy );
|
181 |
// insert/update activity details in rtmedia activity table
|
182 |
$rtmedia_activity_model = new RTMediaActivityModel();
|
183 |
+
if ( ! $rtmedia_activity_model->check( $activity_id ) ) {
|
184 |
+
$rtmedia_activity_model->insert( array(
|
185 |
+
'activity_id' => $activity_id,
|
186 |
+
'user_id' => $user_id,
|
187 |
+
'privacy' => $privacy,
|
188 |
+
) );
|
189 |
} else {
|
190 |
+
$rtmedia_activity_model->update( array(
|
191 |
+
'activity_id' => $activity_id,
|
192 |
+
'user_id' => $user_id,
|
193 |
+
'privacy' => $privacy,
|
194 |
+
), array( 'activity_id' => $activity_id ) );
|
195 |
}
|
196 |
}
|
197 |
}
|
203 |
* @param $user_id
|
204 |
* @param $activity_id
|
205 |
*/
|
206 |
+
function manage_user_last_activity_update( $content, $user_id, $activity_id ) {
|
207 |
+
global $wpdb, $bp;
|
208 |
|
209 |
// do not proceed if not allowed
|
210 |
+
if ( ! apply_filters( 'rtm_manage_user_last_activity_update', true, $activity_id ) ) {
|
211 |
return;
|
212 |
}
|
213 |
$rtm_activity_model = new RTMediaActivityModel();
|
214 |
|
215 |
$rtm_activity_obj = $rtm_activity_model->get( array( 'activity_id' => $activity_id ) );
|
216 |
|
217 |
+
if ( ! empty( $rtm_activity_obj ) ) {
|
218 |
+
if ( isset( $rtm_activity_obj[0]->privacy ) && $rtm_activity_obj[0]->privacy > 0 ) {
|
219 |
|
220 |
$get_columns = array(
|
221 |
'activity_id' => array(
|
222 |
'compare' => '<',
|
223 |
+
'value' => $activity_id,
|
224 |
),
|
225 |
+
'user_id' => $user_id,
|
226 |
+
'privacy' => array(
|
227 |
'compare' => '<=',
|
228 |
+
'value' => 0,
|
229 |
),
|
230 |
);
|
231 |
|
232 |
// get user's latest public activity update
|
233 |
$new_last_activity_obj = $rtm_activity_model->get( $get_columns, 0, 1 );
|
234 |
|
235 |
+
if ( ! empty( $new_last_activity_obj ) ) {
|
236 |
// latest public activity id
|
237 |
$public_activity_id = $new_last_activity_obj[0]->activity_id;
|
238 |
|
239 |
// latest public activity content
|
240 |
$activity_content = bp_activity_get_meta( $public_activity_id, 'bp_activity_text' );
|
241 |
+
if ( empty( $activity_content ) ) {
|
242 |
+
$activity_content = $wpdb->get_var( $wpdb->prepare( "SELECT content FROM {$bp->activity->table_name} WHERE id = %d", $public_activity_id ) ); // @codingStandardsIgnoreLine
|
243 |
}
|
244 |
$activity_content = apply_filters( 'bp_activity_latest_update_content', $activity_content, $activity_content );
|
245 |
|
246 |
// update user's latest update
|
247 |
bp_update_user_meta( $user_id, 'bp_latest_update', array(
|
248 |
'id' => $public_activity_id,
|
249 |
+
'content' => $activity_content,
|
250 |
) );
|
251 |
}
|
252 |
}
|
253 |
}
|
254 |
}
|
255 |
|
256 |
+
function bp_after_activity_post_form() {
|
257 |
+
$url_raw = filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_VALIDATE_URL );
|
258 |
+
$url = trailingslashit( $url_raw );
|
259 |
$slug_split = explode( '/', $url );
|
260 |
// check position of media slug for end of the URL
|
261 |
+
if ( RTMEDIA_MEDIA_SLUG === $slug_split[ count( $slug_split ) - 1 ] ) {
|
262 |
// replace media slug with the blank space
|
263 |
+
$slug_split[ count( $slug_split ) - 1 ] = '';
|
264 |
+
$url_upload = implode( '/', $slug_split );
|
265 |
+
$url = trailingslashit( $url_upload ) . 'upload/';
|
266 |
} else {
|
267 |
+
$url = trailingslashit( $url ) . 'upload/';
|
268 |
}
|
269 |
+
if ( rtmedia_is_uploader_view_allowed( true, 'activity' ) ) {
|
270 |
$params = array(
|
271 |
+
'url' => $url,
|
272 |
+
'runtimes' => 'html5,flash,html4',
|
273 |
+
'browse_button' => apply_filters( 'rtmedia_upload_button_id', 'rtmedia-add-media-button-post-update' ),
|
274 |
+
// browse button assigned to "Attach Files" Button.
|
275 |
+
'container' => 'rtmedia-whts-new-upload-container',
|
276 |
+
'drop_element' => 'whats-new-textarea',
|
277 |
+
// drag-drop area assigned to activity update textarea
|
278 |
+
'filters' => apply_filters( 'rtmedia_plupload_files_filter', array(
|
279 |
+
array(
|
280 |
+
'title' => esc_html__( 'Media Files', 'buddypress-media' ),
|
281 |
+
'extensions' => get_rtmedia_allowed_upload_type(),
|
282 |
+
),
|
283 |
+
) ),
|
284 |
+
'max_file_size' => ( wp_max_upload_size() ) / ( 1024 * 1024 ) . 'M',
|
285 |
+
'multipart' => true,
|
286 |
+
'urlstream_upload' => true,
|
287 |
+
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
288 |
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
289 |
+
'file_data_name' => 'rtmedia_file',
|
290 |
+
// key passed to $_FILE.
|
291 |
+
'multi_selection' => true,
|
292 |
+
'multipart_params' => apply_filters( 'rtmedia-multi-params', array(
|
293 |
+
'redirect' => 'no',
|
294 |
+
'rtmedia_update' => 'true',
|
295 |
+
'action' => 'wp_handle_upload',
|
296 |
+
'_wp_http_referer' => $url_raw,
|
297 |
+
'mode' => 'file_upload',
|
298 |
+
'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator( false, true ),
|
299 |
+
) ),
|
300 |
+
'max_file_size_msg' => apply_filters( 'rtmedia_plupload_file_size_msg', min( array(
|
301 |
+
ini_get( 'upload_max_filesize' ),
|
302 |
+
ini_get( 'post_max_size' ),
|
303 |
+
) ) ),
|
304 |
);
|
305 |
+
if ( wp_is_mobile() ) {
|
306 |
$params['multi_selection'] = false;
|
307 |
}
|
308 |
$params = apply_filters( 'rtmedia_modify_upload_params', $params );
|
313 |
wp_localize_script( 'rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed );
|
314 |
wp_localize_script( 'rtmedia-backbone', 'rtMedia_update_plupload_config', $params );
|
315 |
|
316 |
+
$upload_view = new RTMediaUploadView( array( 'activity' => true ) );
|
317 |
+
$upload_view->render( 'uploader' );
|
318 |
} else {
|
319 |
+
echo "<div class='rtmedia-upload-not-allowed'>" . wp_kses( apply_filters( 'rtmedia_upload_not_allowed_message', esc_html__( 'You are not allowed to upload/attach media.', 'buddypress-media' ), 'activity' ), RTMediaUpload::$wp_kses_allowed_tags ) . '</div>';
|
320 |
}
|
321 |
}
|
322 |
|
323 |
+
function override_allowed_tags( $activity_allowedtags ) {
|
324 |
|
325 |
+
$activity_allowedtags['video'] = array();
|
326 |
$activity_allowedtags['video']['id'] = array();
|
327 |
$activity_allowedtags['video']['class'] = array();
|
328 |
$activity_allowedtags['video']['src'] = array();
|
333 |
$activity_allowedtags['video']['width'] = array();
|
334 |
$activity_allowedtags['video']['height'] = array();
|
335 |
$activity_allowedtags['video']['poster'] = array();
|
336 |
+
$activity_allowedtags['audio'] = array();
|
337 |
$activity_allowedtags['audio']['id'] = array();
|
338 |
$activity_allowedtags['audio']['class'] = array();
|
339 |
$activity_allowedtags['audio']['src'] = array();
|
343 |
$activity_allowedtags['audio']['title'] = array();
|
344 |
$activity_allowedtags['audio']['width'] = array();
|
345 |
$activity_allowedtags['audio']['poster'] = array();
|
346 |
+
|
347 |
+
if ( ! isset( $activity_allowedtags['div'] ) ) {
|
348 |
+
$activity_allowedtags['div'] = array();
|
349 |
+
}
|
350 |
+
|
351 |
+
$activity_allowedtags['div']['id'] = array();
|
352 |
+
$activity_allowedtags['div']['class'] = array();
|
353 |
+
|
354 |
+
if ( ! isset( $activity_allowedtags['a'] ) ) {
|
355 |
+
$activity_allowedtags['a'] = array();
|
356 |
+
}
|
357 |
+
|
358 |
+
$activity_allowedtags['a']['title'] = array();
|
359 |
+
$activity_allowedtags['a']['href'] = array();
|
360 |
+
|
361 |
+
if ( ! isset( $activity_allowedtags['ul'] ) ) {
|
362 |
+
$activity_allowedtags['ul'] = array();
|
363 |
+
}
|
364 |
+
|
365 |
+
$activity_allowedtags['ul']['class'] = array();
|
366 |
+
|
367 |
+
if ( ! isset( $activity_allowedtags['li'] ) ) {
|
368 |
+
$activity_allowedtags['li'] = array();
|
369 |
+
}
|
370 |
+
$activity_allowedtags['li']['class'] = array();
|
|
|
|
|
|
|
|
|
371 |
|
372 |
return $activity_allowedtags;
|
373 |
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* To add dynamic activity actions for translation of activity items
|
377 |
+
*
|
378 |
+
* @param $activities
|
379 |
+
*/
|
380 |
+
function bp_prefetch_activity_object_data( $activities ) {
|
381 |
+
// If activities array is empty then return
|
382 |
+
if ( empty( $activities ) ) {
|
383 |
+
return;
|
384 |
+
}
|
385 |
+
|
386 |
+
// To store activity_id
|
387 |
+
$activity_ids = array();
|
388 |
+
$activity_index_array = array();
|
389 |
+
|
390 |
+
foreach ( $activities as $i => $activity ) {
|
391 |
+
// Checking if activity_type is of rtmedia and component must be profile
|
392 |
+
if ( 'rtmedia_update' === $activity->type && 'profile' === $activity->component ) {
|
393 |
+
// Storing activity_id
|
394 |
+
$activity_ids[] = $activity->id;
|
395 |
+
// Storing index of activity from activities array
|
396 |
+
$activity_index_array[] = $i;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
// Checking if media is linked with any of activity
|
401 |
+
if ( ! empty( $activity_ids ) ) {
|
402 |
+
$rtmedia_model = new RTMediaModel();
|
403 |
+
|
404 |
+
// Where condition array to get media using activity_id from rtm_media table
|
405 |
+
$rtmedia_media_where_array = array();
|
406 |
+
$rtmedia_media_where_array['activity_id'] = array(
|
407 |
+
'compare' => 'IN',
|
408 |
+
'value' => $activity_ids,
|
409 |
+
);
|
410 |
+
$rtmedia_media_query = $rtmedia_model->get( $rtmedia_media_where_array );
|
411 |
+
|
412 |
+
// Array to store media_type in simplified manner with activity_id as key
|
413 |
+
$rtmedia_media_type_array = array();
|
414 |
+
for ( $i = 0; $i < count( $rtmedia_media_query ); $i ++ ) {
|
415 |
+
// Storing media_type of uploaded media to check whether all media are of same type or different and key is activity_id
|
416 |
+
// Making activity_id array because there might be more then 1 media linked with activity
|
417 |
+
if ( ! isset( $rtmedia_media_type_array[ $rtmedia_media_query[ $i ]->activity_id ] ) || ! is_array( $rtmedia_media_type_array[ $rtmedia_media_query[ $i ]->activity_id ] ) ) {
|
418 |
+
$rtmedia_media_type_array[ $rtmedia_media_query[ $i ]->activity_id ] = array();
|
419 |
+
}
|
420 |
+
|
421 |
+
array_push( $rtmedia_media_type_array[ $rtmedia_media_query[ $i ]->activity_id ], $rtmedia_media_query[ $i ]->media_type );
|
422 |
+
}
|
423 |
+
|
424 |
+
// Updating action
|
425 |
+
for ( $a = 0; $a < count( $activity_ids ); $a ++ ) {
|
426 |
+
// Getting index of activity which is being updated
|
427 |
+
$index = $activity_index_array[ $a ];
|
428 |
+
// This pattern is for getting name. User might have change display name as first name or something instead on nicename.
|
429 |
+
$pattern = '/<a ?.*>(.*)<\/a>/';
|
430 |
+
preg_match( $pattern, $activities[ $index ]->action, $matches );
|
431 |
+
|
432 |
+
// Generating user_link with name
|
433 |
+
$user_link = '<a href="' . esc_url( $activities[ $index ]->primary_link ) . '">' . esc_html( $matches[1] ) . '</a>';
|
434 |
+
|
435 |
+
if ( isset( $rtmedia_media_type_array[ $activities[ $index ]->id ] ) ) {
|
436 |
+
// Counting media linked with activity
|
437 |
+
$count = count( $rtmedia_media_type_array[ $activities[ $index ]->id ] );
|
438 |
+
// Getting constant with single label or plural label
|
439 |
+
$media_const = 'RTMEDIA_' . strtoupper( $rtmedia_media_type_array[ $activities[ $index ]->id ][0] );
|
440 |
+
if ( $count > 1 ) {
|
441 |
+
$media_const .= '_PLURAL';
|
442 |
+
}
|
443 |
+
$media_const .= '_LABEL';
|
444 |
+
if ( defined( $media_const ) ) {
|
445 |
+
$media_str = constant( $media_const );
|
446 |
+
} else {
|
447 |
+
$media_str = RTMEDIA_MEDIA_SLUG;
|
448 |
+
}
|
449 |
+
|
450 |
+
$action = '';
|
451 |
+
$user = get_userdata( $activities[ $index ]->user_id );
|
452 |
+
// Updating activity based on count
|
453 |
+
if ( 1 === $count ) {
|
454 |
+
$action = sprintf( esc_html__( '%s added a %s', 'buddypress-media' ), $user_link, $media_str );
|
455 |
+
} else {
|
456 |
+
// Checking all the media linked with activity are of same type
|
457 |
+
if ( isset( $rtmedia_media_type_array[ $activities[ $index ]->id ] )
|
458 |
+
&& ! empty( $rtmedia_media_type_array[ $activities[ $index ]->id ] )
|
459 |
+
&& count( array_unique( $rtmedia_media_type_array[ $activities[ $index ]->id ] ) ) === 1
|
460 |
+
) {
|
461 |
+
$action = sprintf( esc_html__( '%s added %d %s', 'buddypress-media' ), $user_link, $count, $media_str );
|
462 |
+
} else {
|
463 |
+
$action = sprintf( esc_html__( '%s added %d %s', 'buddypress-media' ), $user_link, $count, RTMEDIA_MEDIA_SLUG );
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
$action = apply_filters( 'rtmedia_bp_activity_action_text', $action, $user_link, $count, $user, $rtmedia_media_type_array[ $activities[ $index ]->id ][0], $activities[ $index ]->id );
|
468 |
+
$activities[ $index ]->action = $action;
|
469 |
+
}
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
+
return $activities;
|
474 |
+
}
|
475 |
|
476 |
/**
|
477 |
* Create BP activity when user like and delete associated activity when user remove like.
|
478 |
*
|
479 |
* @param $obj RTMediaLike
|
480 |
*/
|
481 |
+
function activity_after_media_like( $obj ) {
|
482 |
global $rtmedia_points_media_id;
|
483 |
+
if ( is_a( $obj, 'RTMediaLike' ) && isset( $obj->action_query->id ) ) {
|
484 |
$media_id = $obj->action_query->id;
|
485 |
+
} elseif ( ! empty( $rtmedia_points_media_id ) ) {
|
486 |
$media_id = $rtmedia_points_media_id;
|
487 |
} else {
|
488 |
$media_id = false;
|
491 |
$media_obj = $obj->media;
|
492 |
|
493 |
// Proceed only if we have media to process.
|
494 |
+
if ( false !== $media_id && ( 'profile' === $media_obj->context || 'group' === $media_obj->context ) ) {
|
495 |
|
496 |
$user_id = $obj->interactor;
|
497 |
|
498 |
// If $obj->increase is true than request is to like the media.
|
499 |
+
if ( $obj->increase ) {
|
500 |
|
501 |
// Create activity on media like
|
502 |
+
$user = get_userdata( $user_id );
|
503 |
+
$username = '<a href="' . esc_url( get_rtmedia_user_link( $user_id ) ) . '">' . esc_html( $user->display_name ) . '</a>';
|
504 |
|
505 |
$media_author = $obj->owner;
|
506 |
|
507 |
$primary_link = get_rtmedia_permalink( $media_id );
|
508 |
|
509 |
$media_const = 'RTMEDIA_' . strtoupper( $obj->media->media_type ) . '_LABEL';
|
510 |
+
$media_str = '<a href="' . esc_url( $primary_link ) . '">' . esc_html( constant( $media_const ) ) . '</a>';
|
511 |
|
512 |
+
if ( 'group' === $media_obj->context ) {
|
513 |
$group_data = groups_get_group( array( 'group_id' => $media_obj->context_id ) );
|
514 |
+
$group_name = '<a href="' . esc_url( bp_get_group_permalink( $group_data ) ) . '">' . esc_html( $group_data->name ) . '</a>';
|
515 |
+
$action = sprintf( esc_html__( '%1$s liked a %2$s in the group %3$s', 'buddypress-media' ), $username, $media_str, $group_name );
|
516 |
} else {
|
517 |
+
if ( $user_id === $media_author ) {
|
518 |
+
$action = sprintf( esc_html__( '%1$s liked their %2$s', 'buddypress-media' ), $username, $media_str );
|
519 |
} else {
|
520 |
$media_author_data = get_userdata( $media_author );
|
521 |
+
$media_author_name = '<a href="' . esc_url( get_rtmedia_user_link( $media_author ) ) . '">' . esc_html( $media_author_data->display_name ) . '</a>';
|
522 |
+
$action = sprintf( esc_html__( '%1$s liked %2$s\'s %3$s', 'buddypress-media' ), $username, $media_author_name, $media_str );
|
523 |
}
|
524 |
}
|
525 |
|
526 |
+
$action = apply_filters( 'rtm_bp_like_activity_action', $action, $media_id, $user_id );
|
527 |
$primary_link = get_rtmedia_permalink( $media_id );
|
528 |
|
529 |
// generate activity arguments.
|
530 |
$activity_args = array(
|
531 |
+
'user_id' => $user_id,
|
532 |
+
'action' => $action,
|
533 |
+
'type' => 'rtmedia_like_activity',
|
534 |
'primary_link' => $primary_link,
|
535 |
+
'item_id' => $media_id,
|
536 |
);
|
537 |
|
538 |
// set activity component
|
539 |
+
if ( 'group' === $media_obj->context || 'profile' === $media_obj->context ) {
|
540 |
+
$activity_args['component'] = $media_obj->context;
|
541 |
+
if ( 'group' === $media_obj->context ) {
|
542 |
+
$activity_args['component'] = 'groups';
|
543 |
+
$activity_args['item_id'] = $media_obj->context_id;
|
544 |
}
|
545 |
}
|
546 |
|
548 |
$activity_id = bp_activity_add( $activity_args );
|
549 |
|
550 |
// Store activity id into user meta for reference
|
551 |
+
//todo user_attribute
|
552 |
update_user_meta( $user_id, 'rtm-bp-media-like-activity-' . $media_id, $activity_id );
|
553 |
} else {
|
554 |
|
555 |
$meta_key = 'rtm-bp-media-like-activity-' . $media_id;
|
556 |
// Delete activity when user remove his like.
|
557 |
+
//todo user_attribute
|
558 |
$activity_id = get_user_meta( $user_id, $meta_key, true );
|
559 |
|
560 |
+
if ( ! empty( $activity_id ) ) {
|
561 |
+
if ( bp_activity_delete( array( 'id' => $activity_id ) ) ) {
|
562 |
+
//todo user_attribute
|
563 |
delete_user_meta( $user_id, $meta_key );
|
564 |
}
|
565 |
}
|
572 |
*
|
573 |
* @param $params array
|
574 |
*/
|
575 |
+
function activity_after_media_comment( $params ) {
|
576 |
|
577 |
+
if ( isset( $params['comment_post_ID'] ) ) {
|
578 |
|
579 |
// get media details
|
580 |
$media_model = new RTMediaModel();
|
581 |
+
$media_obj = $media_model->get( array( 'media_id' => $params['comment_post_ID'] ) );
|
582 |
+
$media_obj = $media_obj[0];
|
583 |
|
584 |
// only proceed if corresponding media is exist.
|
585 |
+
if ( ! empty( $media_obj ) && ( 'profile' === $media_obj->context || 'group' === $media_obj->context ) ) {
|
586 |
|
587 |
$media_id = $media_obj->id;
|
588 |
|
589 |
+
$user_id = $params['user_id'];
|
590 |
+
$user = get_userdata( $user_id );
|
591 |
+
$username = '<a href="' . esc_url( get_rtmedia_user_link( $user_id ) ) . '">' . esc_html( $user->display_name ) . '</a>';
|
592 |
|
593 |
$primary_link = get_rtmedia_permalink( $media_id );
|
594 |
|
595 |
$media_const = 'RTMEDIA_' . strtoupper( $media_obj->media_type ) . '_LABEL';
|
596 |
+
$media_str = '<a href="' . esc_url( $primary_link ) . '">' . constant( $media_const ) . '</a>';
|
597 |
|
598 |
$media_author = $media_obj->media_author;
|
599 |
|
600 |
+
if ( 'group' === $media_obj->context ) {
|
601 |
$group_data = groups_get_group( array( 'group_id' => $media_obj->context_id ) );
|
602 |
+
$group_name = '<a href="' . esc_url( bp_get_group_permalink( $group_data ) ) . '">' . esc_html( $group_data->name ) . '</a>';
|
603 |
+
$action = sprintf( esc_html__( '%1$s commented on a %2$s in the group %3$s', 'buddypress-media' ), $username, $media_str, $group_name );
|
604 |
} else {
|
605 |
+
if ( $user_id === $media_author ) {
|
606 |
+
$action = sprintf( esc_html__( '%1$s commented on their %2$s', 'buddypress-media' ), $username, $media_str );
|
607 |
} else {
|
608 |
$media_author_data = get_userdata( $media_author );
|
609 |
+
$media_author_name = '<a href="' . esc_url( get_rtmedia_user_link( $media_author ) ) . '">' . esc_html( $media_author_data->display_name ) . '</a>';
|
610 |
+
$action = sprintf( esc_html__( '%1$s commented on %2$s\'s %3$s', 'buddypress-media' ), $username, $media_author_name, $media_str );
|
611 |
}
|
612 |
}
|
613 |
|
614 |
$comment_content = $params['comment_content'];
|
615 |
+
$wp_comment_id = $params['comment_id'];
|
616 |
|
617 |
// prepare activity arguments
|
618 |
$activity_args = array(
|
619 |
+
'user_id' => $user_id,
|
620 |
+
'action' => $action,
|
621 |
+
'content' => $comment_content,
|
622 |
+
'type' => 'rtmedia_comment_activity',
|
623 |
+
'primary_link' => $primary_link,
|
624 |
+
'item_id' => $media_id,
|
625 |
+
'secondary_item_id' => $wp_comment_id,
|
626 |
);
|
627 |
|
628 |
// set activity component
|
629 |
+
if ( 'group' === $media_obj->context || 'profile' === $media_obj->context ) {
|
630 |
+
$activity_args['component'] = $media_obj->context;
|
631 |
+
if ( 'group' === $media_obj->context ) {
|
632 |
+
$activity_args['component'] = 'groups';
|
633 |
+
$activity_args['item_id'] = $media_obj->context_id;
|
634 |
}
|
635 |
}
|
636 |
|
638 |
$activity_id = bp_activity_add( $activity_args );
|
639 |
|
640 |
// Store activity id into user meta for reference
|
641 |
+
//todo user_attribute
|
642 |
update_user_meta( $user_id, 'rtm-bp-media-comment-activity-' . $media_id . '-' . $wp_comment_id, $activity_id );
|
643 |
}
|
644 |
}
|
649 |
*
|
650 |
* @param $comment_id
|
651 |
*/
|
652 |
+
function remove_activity_after_media_comment_delete( $comment_id ) {
|
653 |
+
if ( ! empty( $comment_id ) ) {
|
654 |
|
655 |
// get comment details from comment id
|
656 |
$comment = get_comment( $comment_id );
|
657 |
$user_id = $comment->user_id;
|
658 |
|
659 |
+
if ( isset( $comment->comment_post_ID ) && isset( $comment->user_id ) ) {
|
660 |
+
$model = new RTMediaModel();
|
661 |
$media_obj = $model->get( array( 'media_id' => $comment->comment_post_ID ) );
|
662 |
$media_obj = $media_obj[0];
|
663 |
|
664 |
+
if ( ! empty( $media_obj ) ) {
|
665 |
$meta_key = 'rtm-bp-media-comment-activity-' . $media_obj->id . '-' . $comment_id;
|
666 |
|
667 |
// Delete activity when user remove his comment.
|
668 |
+
//todo user_attribute
|
669 |
$activity_id = get_user_meta( $user_id, $meta_key, true );
|
670 |
|
671 |
+
if ( ! empty( $activity_id ) ) {
|
672 |
+
if ( bp_activity_delete( array( 'id' => $activity_id ) ) ) {
|
673 |
+
//todo user_attribute
|
674 |
delete_user_meta( $user_id, $meta_key );
|
675 |
}
|
676 |
}
|
678 |
}
|
679 |
}
|
680 |
}
|
|
|
681 |
}
|
app/main/controllers/api/RTMediaApiLogin.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
/**
|
4 |
* @author Umesh Kumar<umeshsingla05@gmail.com>
|
5 |
*/
|
6 |
-
if(!class_exists('RTDBModel')){
|
7 |
-
|
8 |
}
|
9 |
class RTMediaApiLogin extends RTDBModel {
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
}
|
3 |
/**
|
4 |
* @author Umesh Kumar<umeshsingla05@gmail.com>
|
5 |
*/
|
6 |
+
if ( ! class_exists( 'RTDBModel' ) ) {
|
7 |
+
return;
|
8 |
}
|
9 |
class RTMediaApiLogin extends RTDBModel {
|
10 |
|
11 |
+
function __construct() {
|
12 |
+
parent::__construct( 'rtm_api' );
|
13 |
+
}
|
14 |
+
}
|
app/main/controllers/api/RTMediaJsonApi.php
CHANGED
@@ -1,1202 +1,1213 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* File Description
|
4 |
* @author Umesh Kumar <umeshsingla05@gmail.com>
|
5 |
*/
|
6 |
-
class RTMediaJsonApi{
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
}
|
331 |
-
$hashed = $wp_hasher->HashPassword( $key );
|
332 |
-
$wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user_login ) );
|
333 |
-
|
334 |
-
//create email message
|
335 |
-
$message = __('Someone has asked to reset the password for the following site and username.', 'buddypress-media') . "\r\n\r\n";
|
336 |
-
$message .= get_option('siteurl') . "\r\n\r\n";
|
337 |
-
$message .= sprintf(__('Username: %s', 'buddypress-media'), $user_login) . "\r\n\r\n";
|
338 |
-
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'buddypress-media') . "\r\n\r\n";
|
339 |
-
$message .='<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n";
|
340 |
-
//send email meassage
|
341 |
-
if (FALSE == wp_mail($user_email, sprintf(__('[%s] Password Reset','buddypress-media'), get_option('blogname')), $message))
|
342 |
-
echo $this->rtmedia_api_response_object ('FALSE', $this->ec_server_error, $this->msg_server_error);
|
343 |
-
else{
|
344 |
-
echo $this->rtmedia_api_response_object ('TRUE', $ec_email_sent, $msg_email_sent);
|
345 |
-
}
|
346 |
-
exit;
|
347 |
-
}
|
348 |
-
/**
|
349 |
-
* Sends a reset link to user email
|
350 |
-
* @global type $wpdb
|
351 |
-
*/
|
352 |
-
function rtmedia_api_process_bp_get_activities_request(){
|
353 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
354 |
-
//Feed Errors
|
355 |
-
$ec_latest_feed = 700001;
|
356 |
-
$msg_latest_feed = __('bp activities', 'buddypress-media' );
|
357 |
-
|
358 |
-
$ec_my_looks = 700002;
|
359 |
-
$msg_my_looks = __('user activities', 'buddypress-media' );
|
360 |
-
|
361 |
-
//Fetch user id from token
|
362 |
-
$activity_user_id = '';
|
363 |
-
extract($_REQUEST);
|
364 |
-
$per_page = !empty($_REQUEST['per_page']) ? $_REQUEST['per_page'] : 10;
|
365 |
-
$activity_feed = $this->rtmediajsonapifunction->rtmedia_api_get_feed($activity_user_id, '', $per_page);
|
366 |
-
if( empty($activity_feed) ){
|
367 |
-
$activity_feed = 'no updates';
|
368 |
-
}
|
369 |
-
if ( !empty( $activity_user_id ) ){
|
370 |
-
echo $this->rtmedia_api_response_object('TRUE', $ec_my_looks, $msg_my_looks, $activity_feed );
|
371 |
-
}else{
|
372 |
-
echo $this->rtmedia_api_response_object('TRUE', $ec_latest_feed, $msg_latest_feed, $activity_feed );
|
373 |
-
}
|
374 |
-
exit;
|
375 |
-
}
|
376 |
-
/**
|
377 |
-
* Post comment on activity_id or media_id
|
378 |
-
* @global type $this->msg_server_error
|
379 |
-
* @global int $this->ec_server_error
|
380 |
-
* @global int $this->ec_invalid_media_id
|
381 |
-
* @global type $this->msg_invalid_media_id
|
382 |
-
*/
|
383 |
-
function rtmedia_api_process_add_rtmedia_comment_request(){
|
384 |
-
|
385 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
386 |
-
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
387 |
-
//Post comment errors
|
388 |
-
$ec_comment_content_missing = 800001;
|
389 |
-
$msg_comment_content_missing = __('comment content missing', 'buddypress-media' );
|
390 |
-
|
391 |
-
$ec_comment_posted = 800002;
|
392 |
-
$msg_comment_posted = __('comment posted', 'buddypress-media' );
|
393 |
-
|
394 |
-
//Fetch user id from token
|
395 |
-
$user_data = get_userdata( $this->user_id );
|
396 |
-
if ( empty( $_POST['content'] ) ) {
|
397 |
-
echo $this->rtmedia_api_response_object('FALSE', $ec_comment_content_missing, $msg_comment_content_missing );
|
398 |
-
exit;
|
399 |
-
}
|
400 |
-
extract($_POST);
|
401 |
-
|
402 |
-
if ( empty( $activity_id ) && !empty( $media_id ) ){
|
403 |
-
$activity_id = $this->rtmediajsonapifunction->rtmedia_api_activityid_from_mediaid( $media_id );
|
404 |
-
}
|
405 |
-
if(empty($activity_id)){
|
406 |
-
echo $this->rtmedia_api_response_object('FALSE', $this->ec_invalid_media_id, $this->msg_invalid_media_id );
|
407 |
-
exit;
|
408 |
-
}
|
409 |
-
$args = array(
|
410 |
-
'content' => $content,
|
411 |
-
'activity_id' => $activity_id,
|
412 |
-
'user_id' => $this->user_id,
|
413 |
-
'parent_id' => false
|
414 |
-
);
|
415 |
-
if ( function_exists ( 'bp_activity_new_comment' ) ) {
|
416 |
-
$comment_id = bp_activity_new_comment ( $args );
|
417 |
-
}
|
418 |
-
if ( $comment_id ) {
|
419 |
-
echo $this->rtmedia_api_response_object('TRUE', $ec_comment_posted, $msg_comment_posted );
|
420 |
-
exit;
|
421 |
-
}else{
|
422 |
-
echo $this->rtmedia_api_response_object('FALSE', $this->msg_server_error, $this->ec_server_error );
|
423 |
-
exit;
|
424 |
-
}
|
425 |
-
}
|
426 |
-
/**
|
427 |
-
* Like/Unlike by media_id or activity_id
|
428 |
-
* @global int $this->ec_server_error
|
429 |
-
* @global type $this->msg_server_error
|
430 |
-
* @global int $this->ec_invalid_media_id
|
431 |
-
* @global type $this->msg_invalid_media_id
|
432 |
-
*/
|
433 |
-
function rtmedia_api_process_like_media_request(){
|
434 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
435 |
-
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
436 |
-
|
437 |
-
//Like errors
|
438 |
-
$ec_already_liked = 900001;
|
439 |
-
$msg_already_liked = __('unliked media', 'buddypress-media' );
|
440 |
-
|
441 |
-
$ec_liked_media = 900002;
|
442 |
-
$msg_liked_media = __('liked media', 'buddypress-media' );
|
443 |
-
|
444 |
-
extract($_POST);
|
445 |
-
|
446 |
-
if(class_exists('RTMediaInteractionModel') ):
|
447 |
-
$rtmediainteraction = new RTMediaInteractionModel();
|
448 |
-
|
449 |
-
if(class_exists('RTMediaLike') )
|
450 |
-
$rtmedialike = new RTMediaLike();
|
451 |
-
|
452 |
-
$action = 'like';
|
453 |
-
// Like or Unlike
|
454 |
-
if( !rtmedia_media_id( $media_id) ){
|
455 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $this->ec_invalid_media_id, $this->msg_invalid_media_id );
|
456 |
-
exit;
|
457 |
-
}
|
458 |
-
|
459 |
-
$like_count_old = get_rtmedia_like( rtmedia_media_id( $media_id) );
|
460 |
-
$check_action = $rtmediainteraction->check( $this->user_id, $media_id, $action);
|
461 |
-
if($check_action) {
|
462 |
-
$results = $rtmediainteraction->get_row( $this->user_id, $media_id, $action);
|
463 |
-
$row = $results[0];
|
464 |
-
$curr_value = $row->value;
|
465 |
-
if($curr_value == "1") {
|
466 |
-
$value = "0";
|
467 |
-
$increase =false;
|
468 |
-
} else {
|
469 |
-
$value = "1";
|
470 |
-
$increase = true;
|
471 |
-
}
|
472 |
-
$update_data = array('value' => $value);
|
473 |
-
$where_columns = array(
|
474 |
-
'user_id' => $this->user_id,
|
475 |
-
'media_id' => $media_id,
|
476 |
-
'action' => $action,
|
477 |
-
);
|
478 |
-
$update = $rtmediainteraction->update($update_data, $where_columns);
|
479 |
-
} else {
|
480 |
-
$value = "1";
|
481 |
-
$columns = array(
|
482 |
-
'user_id' => $this->user_id,
|
483 |
-
'media_id' => $media_id,
|
484 |
-
'action' => $action,
|
485 |
-
'value' => $value
|
486 |
-
);
|
487 |
-
$insert_id = $rtmediainteraction->insert($columns);
|
488 |
-
$increase = true;
|
489 |
-
}
|
490 |
-
if ( $increase ){
|
491 |
-
$like_count_old++;
|
492 |
-
}elseif(!$increase){
|
493 |
-
$like_count_old--;
|
494 |
-
}
|
495 |
-
if($like_count_old < 0 ){
|
496 |
-
$like_count_old = 0;
|
497 |
-
}
|
498 |
-
$data = array('like_count' => $like_count_old );
|
499 |
-
if ( !empty( $insert_id ) ){
|
500 |
-
$rtmedialike->model->update( array( 'likes' => $like_count_old ), array( 'id' => $media_id ) );
|
501 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_liked_media, $msg_liked_media, $data );
|
502 |
-
exit;
|
503 |
-
}elseif ( !empty( $update ) ){
|
504 |
-
$rtmedialike->model->update( array( 'likes' => $like_count_old ), array( 'id' => $media_id ) );
|
505 |
-
if ( $value == 1 ){
|
506 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_liked_media, $msg_liked_media, $data );
|
507 |
-
exit;
|
508 |
-
}elseif( $value == 0 ){
|
509 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_already_liked, $msg_already_liked, $data );
|
510 |
-
exit;
|
511 |
-
}
|
512 |
-
}else{
|
513 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $this->ec_server_error, $this->msg_server_error );
|
514 |
-
exit;
|
515 |
-
}
|
516 |
-
endif;
|
517 |
-
}
|
518 |
-
/**
|
519 |
-
* Fetch Comments by media id
|
520 |
-
* @global type $wpdb
|
521 |
-
*/
|
522 |
-
function rtmedia_api_process_get_rtmedia_comments_request(){
|
523 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
524 |
-
//Errors Fetching comment
|
525 |
-
$ec_no_comments = 800003;
|
526 |
-
$msg_no_comments = __('no comments', 'buddypress-media' );
|
527 |
-
|
528 |
-
$ec_media_comments = 800004;
|
529 |
-
$msg_media_comments = __('media comments', 'buddypress-media' );
|
530 |
-
|
531 |
-
$ec_my_comments = 800005;
|
532 |
-
$msg_my_comments = __('my comments', 'buddypress-media' );
|
533 |
-
|
534 |
-
extract($_REQUEST);
|
535 |
-
global $wpdb;
|
536 |
-
if ( empty( $media_id ) ){
|
537 |
-
|
538 |
-
$user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($this->user_id);
|
539 |
-
$comments = $wpdb->get_results ( "SELECT * FROM $wpdb->comments WHERE user_id = '" . $this->user_id . "'", ARRAY_A );
|
540 |
-
$my_comments = array();
|
541 |
-
if ( !empty( $comments ) ){
|
542 |
-
foreach ( $comments as $comment ){
|
543 |
-
$my_comments['comments'][] = array(
|
544 |
-
'comment_ID' => $comment['comment_ID'],
|
545 |
-
'comment_content' => $comment['comment_content'],
|
546 |
-
'media_id' => $comment['comment_post_ID']
|
547 |
-
);
|
548 |
-
}
|
549 |
-
$my_comments['user'] = array(
|
550 |
-
'user_id' => $this->user_id,
|
551 |
-
'name' => $user_data['name'],
|
552 |
-
'avatar' => $user_data['avatar']
|
553 |
-
);
|
554 |
-
|
555 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_media_comments, $msg_media_comments, $my_comments );
|
556 |
-
exit;
|
557 |
-
}
|
558 |
-
}else{
|
559 |
-
$media_comments = $this->rtmediajsonapifunction->rtmedia_api_get_media_comments($media_id);
|
560 |
-
if( $media_comments ){
|
561 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_media_comments, $msg_media_comments, $media_comments );
|
562 |
-
exit;
|
563 |
-
}else{
|
564 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_no_comments, $msg_no_comments );
|
565 |
-
exit;
|
566 |
-
}
|
567 |
-
}
|
568 |
-
//If no comments
|
569 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_no_comments, $msg_no_comments );
|
570 |
-
exit;
|
571 |
-
}
|
572 |
-
/**
|
573 |
-
* Fetch Likes by media id
|
574 |
-
* @global type $wpdb
|
575 |
-
*/
|
576 |
-
function rtmedia_api_process_get_likes_rtmedia_request(){
|
577 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
578 |
-
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
579 |
-
global $wpdb;
|
580 |
-
//Errors Fetching Likes
|
581 |
-
$ec_no_likes = 900003;
|
582 |
-
$msg_no_likes = __('no likes', 'buddypress-media' );
|
583 |
-
|
584 |
-
$ec_media_likes = 900004;
|
585 |
-
$msg_media_likes = __('media likes', 'buddypress-media' );
|
586 |
-
$media_like_users = array();
|
587 |
-
$media_likes = array();
|
588 |
-
$media_likes['user'] = array();
|
589 |
-
extract($_POST);
|
590 |
-
$media_like_users = $this->rtmediajsonapifunction->rtmedia_api_media_liked_by_user($media_id);
|
591 |
-
if ( !empty( $media_like_users ) ){
|
592 |
-
foreach ( $media_like_users as $like_details){
|
593 |
-
if ( !array_key_exists( $like_details->user_id, $media_likes['user'] ) ){
|
594 |
-
|
595 |
-
$user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $like_details->user_id );
|
596 |
-
$mysql_time = $wpdb->get_var('select CURRENT_TIMESTAMP()');
|
597 |
-
$like_time = human_time_diff( strtotime($like_details->action_date), strtotime( $mysql_time ) );
|
598 |
-
$media_likes['likes'][] = array(
|
599 |
-
'activity_time' => $like_time,
|
600 |
-
'user_id' => $like_details->user_id
|
601 |
-
);
|
602 |
-
$media_likes['user'][$like_details->user_id] = array(
|
603 |
-
'name' => $user_data['name'],
|
604 |
-
'avatar' => $user_data['avatar']
|
605 |
-
);
|
606 |
-
}
|
607 |
-
}
|
608 |
-
}
|
609 |
-
if( !empty ( $media_likes ) ){
|
610 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_media_likes, $msg_media_likes, $media_likes );
|
611 |
-
exit;
|
612 |
-
}else{
|
613 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_no_likes, $msg_no_likes );
|
614 |
-
exit;
|
615 |
-
}
|
616 |
-
}
|
617 |
-
/**
|
618 |
-
* Delete comment by activity id or media id
|
619 |
-
*/
|
620 |
-
function rtmedia_api_process_remove_comment_request(){
|
621 |
-
global $wpdb;
|
622 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
623 |
-
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
624 |
-
//Errors Deleting comment
|
625 |
-
|
626 |
-
$ec_comment_not_found = 800007;
|
627 |
-
$msg_comment_not_found = __('invalid comment/media id', 'buddypress-media' );
|
628 |
-
|
629 |
-
$ec_no_comment_id = 800008;
|
630 |
-
$msg_no_comment_id = __('no comment id', 'buddypress-media' );
|
631 |
-
|
632 |
-
$ec_comment_deleted = 800009;
|
633 |
-
$msg_comment_deleted = __('comment deleted', 'buddypress-media' );
|
634 |
-
extract($_POST);
|
635 |
-
|
636 |
-
if ( empty( $comment_id ) ){
|
637 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_no_comment_id, $msg_no_comment_id );
|
638 |
-
exit;
|
639 |
-
}
|
640 |
-
$id = rtmedia_media_id($media_id);
|
641 |
-
|
642 |
-
$sql = "SELECT * FROM {$wpdb->comments} WHERE comment_ID = " . $comment_id . " AND comment_post_ID = " . $id. " AND user_id = " . $this->user_id;
|
643 |
-
|
644 |
-
$comments = $wpdb->get_results ( $sql, ARRAY_A );
|
645 |
-
//Delete Comment
|
646 |
-
if ( !empty( $comments ) ) {
|
647 |
-
$comment = new RTMediaComment();
|
648 |
-
|
649 |
-
$activity_id = get_comment_meta($comment_id, 'activity_id',true);
|
650 |
-
|
651 |
-
if(!empty($activity_id)){
|
652 |
-
$activity_deleted = bp_activity_delete_comment ($activity_id, $comment_id);
|
653 |
-
|
654 |
-
$delete = bp_activity_delete( array( 'id' => $activity_id, 'type' => 'activity_comment' ) );
|
655 |
-
|
656 |
-
}
|
657 |
-
$comment_deleted = $comment->rtmedia_comment_model->delete($comment_id);;
|
658 |
-
|
659 |
-
if ( $comment_deleted ){
|
660 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_comment_deleted, $msg_comment_deleted );
|
661 |
-
exit;
|
662 |
-
}else{
|
663 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $this->ec_server_error, $this->msg_server_error );
|
664 |
-
exit;
|
665 |
-
}
|
666 |
-
|
667 |
-
}else{
|
668 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_comment_not_found, $msg_comment_not_found );
|
669 |
-
exit;
|
670 |
-
}
|
671 |
-
}
|
672 |
-
function rtmedia_api_process_bp_get_profile_request(){
|
673 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
674 |
-
//Errors
|
675 |
-
$ec_no_fields = 400001;
|
676 |
-
$msg_no_fields = __('no profile found', 'buddypress-media' );
|
677 |
-
|
678 |
-
$ec_profile_fields = 400002;
|
679 |
-
$msg_profile_fields = __('profile fields', 'buddypress-media' );
|
680 |
-
|
681 |
-
$profile_fields = array();
|
682 |
-
$user_id = $loggedin_user_id = '';
|
683 |
-
extract($_REQUEST);
|
684 |
-
if(empty($user_id)){
|
685 |
-
$user_id = $this->user_id;
|
686 |
-
}else{
|
687 |
-
$loggedin_user_id = $this->user_id;
|
688 |
-
}
|
689 |
-
$user = get_userdata($user_id);
|
690 |
-
if(empty($user)){
|
691 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_no_fields, $msg_no_fields);
|
692 |
-
exit;
|
693 |
-
}
|
694 |
-
$user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($user_id, 250, 250, 'full' );
|
695 |
-
$profile_fields['id'] = $user_id;
|
696 |
-
$profile_fields['avatar']['src'] = $user_data['avatar'];
|
697 |
-
$profile_fields['avatar']['width'] = 250;
|
698 |
-
$profile_fields['avatar']['height'] = 250;
|
699 |
-
|
700 |
-
if ( bp_has_profile(array('user_id' => $user_id) ) ) :
|
701 |
-
while ( bp_profile_groups() ) : bp_the_profile_group();
|
702 |
-
|
703 |
-
if ( bp_profile_group_has_fields() ) :
|
704 |
-
|
705 |
-
while ( bp_profile_fields() ) : bp_the_profile_field();
|
706 |
-
|
707 |
-
if ( bp_field_has_data() ) :
|
708 |
-
|
709 |
-
$profile_fields['fields'][bp_get_the_profile_field_name()] = array(
|
710 |
-
'value' => strip_tags( bp_get_the_profile_field_value() ),
|
711 |
-
'privacy' => bp_get_the_profile_field_visibility_level()
|
712 |
-
);
|
713 |
-
endif;
|
714 |
-
|
715 |
-
endwhile;
|
716 |
-
endif;
|
717 |
-
endwhile;
|
718 |
-
else:
|
719 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_no_fields, $msg_no_fields);
|
720 |
-
exit;
|
721 |
-
endif;
|
722 |
-
//If followers plugin exists
|
723 |
-
if( function_exists('rtmedia_api_followers') ){
|
724 |
-
$followers = rtmedia_api_followers($user_id);
|
725 |
-
$following = rtmedia_api_following($user_id);
|
726 |
-
|
727 |
-
foreach ( $followers as $follower ){
|
728 |
-
$follower_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $follower, 66, 66 );
|
729 |
-
$profile_fields['follower'][] = array(
|
730 |
-
'id' => $follower,
|
731 |
-
'name' => $follower_data['name'],
|
732 |
-
'avatar' => $follower_data['avatar'],
|
733 |
-
);
|
734 |
-
}
|
735 |
-
|
736 |
-
foreach ( $following as $follow ){
|
737 |
-
$follow_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $follow, 66, 66 );
|
738 |
-
$profile_fields['following'][] = array(
|
739 |
-
'id' => $follow,
|
740 |
-
'name' => $follow_data['name'],
|
741 |
-
'avatar' => $follow_data['avatar'],
|
742 |
-
);
|
743 |
-
}
|
744 |
-
}
|
745 |
-
if(!empty($_REQUEST['user_id']) && $loggedin_user_id != $user_id ){
|
746 |
-
$args = array(
|
747 |
-
'leader_id' => $user_id,
|
748 |
-
'follower_id' => $loggedin_user_id
|
749 |
-
);
|
750 |
-
if(function_exists('bp_follow_is_following')){
|
751 |
-
$profile_fields['loggedin_user']['following'] = 'FALSE';
|
752 |
-
if (bp_follow_is_following( $args )){
|
753 |
-
$profile_fields['loggedin_user']['following'] = 'TRUE';
|
754 |
-
}
|
755 |
-
|
756 |
-
$args = array(
|
757 |
-
'leader_id' => $loggedin_user_id,
|
758 |
-
'follower_id' => $user_id
|
759 |
-
);
|
760 |
-
$profile_fields['loggedin_user']['followed'] = 'FALSE';
|
761 |
-
if (bp_follow_is_following( $args )){
|
762 |
-
$profile_fields['loggedin_user']['followed'] = 'TRUE';
|
763 |
-
}
|
764 |
-
}
|
765 |
-
}
|
766 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_profile_fields, $msg_profile_fields, $profile_fields);
|
767 |
-
exit;
|
768 |
-
}
|
769 |
-
|
770 |
-
function rtmedia_api_process_follow_request(){
|
771 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
772 |
-
$ec_empty_follow_id = 400003;
|
773 |
-
$msg_empty_follow_id = __('follow user id missing', 'buddypress-media' );
|
774 |
-
|
775 |
-
$ec_started_following = 400004;
|
776 |
-
$msg_started_following = __('started following', 'buddypress-media' );
|
777 |
-
|
778 |
-
$ec_already_following = 400005;
|
779 |
-
$msg_already_following = __('already following', 'buddypress-media' );
|
780 |
-
|
781 |
-
extract($_POST);
|
782 |
-
|
783 |
-
if ( empty( $follow_id ) ){
|
784 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_empty_follow_id, $msg_empty_follow_id );
|
785 |
-
exit;
|
786 |
-
}
|
787 |
-
$args = array(
|
788 |
-
'leader_id' => $follow_id,
|
789 |
-
'follower_id' => $this->user_id
|
790 |
-
);
|
791 |
-
$already_following = bp_follow_is_following($args);
|
792 |
-
if( !$already_following ){
|
793 |
-
$follow_user = bp_follow_start_following($args);
|
794 |
-
if ( $follow_user ){
|
795 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_started_following, $msg_started_following );
|
796 |
-
exit;
|
797 |
-
}
|
798 |
-
else{
|
799 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $this->ec_server_error, $this->msg_server_error );
|
800 |
-
exit;
|
801 |
-
}
|
802 |
-
}else{
|
803 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_already_following, $msg_already_following );
|
804 |
-
exit;
|
805 |
-
}
|
806 |
-
}
|
807 |
-
function rtmedia_api_process_unfollow_request(){
|
808 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
809 |
-
|
810 |
-
$ec_empty_unfollow_id = 400006;
|
811 |
-
$msg_empty_unfollow_id = __('unfollow id missing', 'buddypress-media' );
|
812 |
-
|
813 |
-
$ec_stopped_following = 400007;
|
814 |
-
$msg_stopped_following = __('stopped following', 'buddypress-media' );
|
815 |
-
|
816 |
-
$ec_not_following = 400008;
|
817 |
-
$msg_not_following = __('not following', 'buddypress-media' );
|
818 |
-
|
819 |
-
extract($_POST);
|
820 |
-
|
821 |
-
if ( empty( $unfollow_id ) ){
|
822 |
-
echo $this->rtmedia_api_response_object( 'FALSE', $ec_empty_unfollow_id, $msg_empty_unfollow_id );
|
823 |
-
exit;
|
824 |
-
}
|
825 |
-
|
826 |
-
$args = array(
|
827 |
-
'leader_id' => $unfollow_id,
|
828 |
-
'follower_id' => $this->user_id
|
829 |
-
);
|
830 |
-
$following = bp_follow_is_following($args);
|
831 |
-
if( $following ){
|
832 |
-
$unfollow_user = bp_follow_stop_following($args);
|
833 |
-
if ( $unfollow_user ){
|
834 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_stopped_following, $msg_stopped_following );
|
835 |
-
exit;
|
836 |
-
}
|
837 |
-
else{
|
838 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $this->ec_server_error, $this->msg_server_error );
|
839 |
-
exit;
|
840 |
-
}
|
841 |
-
}else{
|
842 |
-
echo $this->rtmedia_api_response_object( 'TRUE', $ec_not_following, $msg_not_following );
|
843 |
-
exit;
|
844 |
-
}
|
845 |
-
}
|
846 |
-
function rtmedia_api_process_update_profile_request(){
|
847 |
-
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
848 |
-
$ec_empty_name_loca
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* File Description
|
5 |
* @author Umesh Kumar <umeshsingla05@gmail.com>
|
6 |
*/
|
7 |
+
class RTMediaJsonApi {
|
8 |
+
|
9 |
+
var $ec_method_missing = 600001,
|
10 |
+
$msg_method_missing = 'no method specified',
|
11 |
+
$ec_token_missing = 600002,
|
12 |
+
$msg_token_missing = 'token empty',
|
13 |
+
$ec_token_invalid = 600003,
|
14 |
+
$msg_token_invalid = 'token invalid',
|
15 |
+
$ec_server_error = 600004,
|
16 |
+
$msg_server_error = 'server error',
|
17 |
+
$ec_media_activity_id_missing = 600005,
|
18 |
+
$msg_media_activity_id_missing = 'media/activity id missing',
|
19 |
+
$ec_invalid_media_id = 600006,
|
20 |
+
$msg_invalid_media_id = 'invalid media id',
|
21 |
+
$ec_invalid_request_type = 600007,
|
22 |
+
$msg_invalid_request_type = 'invalid request type',
|
23 |
+
$ec_bp_missing = 600008,
|
24 |
+
$msg_bp_missing = 'buddypress not found',
|
25 |
+
$ec_api_disabled = 600009,
|
26 |
+
$msg_api_disabled = 'API disabled by site administrator',
|
27 |
+
$rtmediajsonapifunction,
|
28 |
+
$user_id = '';
|
29 |
+
|
30 |
+
function __construct() {
|
31 |
+
if ( ! class_exists( 'RTMediaApiLogin' ) || ! class_exists( 'RTMediaJsonApiFunctions' ) ) {
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
add_action( 'wp_ajax_nopriv_rtmedia_api', array( $this, 'rtmedia_api_process_request' ) );
|
36 |
+
add_action( 'wp_ajax_rtmedia_api', array( $this, 'rtmedia_api_process_request' ) );
|
37 |
+
}
|
38 |
+
|
39 |
+
function rtmedia_api_process_request() {
|
40 |
+
$rtmedia_enable_json_api = false;
|
41 |
+
if ( function_exists( 'rtmedia_get_site_option' ) ) {
|
42 |
+
$rtmedia_options = rtmedia_get_site_option( 'rtmedia-options' );
|
43 |
+
if ( ! empty( $rtmedia_options ) ) {
|
44 |
+
if ( $rtmedia_options['rtmedia_enable_api'] ) {
|
45 |
+
$rtmedia_enable_json_api = true;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
if ( ! $rtmedia_enable_json_api ) {
|
50 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_api_disabled, $this->msg_api_disabled ) );
|
51 |
+
}
|
52 |
+
$method = filter_input( INPUT_POST, 'method', FILTER_SANITIZE_STRING );
|
53 |
+
if ( empty( $method ) ) {
|
54 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_method_missing, $this->msg_method_missing ) );
|
55 |
+
}
|
56 |
+
if ( ! class_exists( 'BuddyPress' ) ) {
|
57 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_bp_missing, $this->msg_bp_missing ) );
|
58 |
+
}
|
59 |
+
$this->rtmediajsonapifunction = new RTMediaJsonApiFunctions();
|
60 |
+
$token = filter_input( INPUT_POST, 'token', FILTER_SANITIZE_STRING );
|
61 |
+
|
62 |
+
if ( ! empty( $token ) ) {
|
63 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
64 |
+
$this->user_id = $this->rtmediajsonapifunction->rtmedia_api_get_user_id_from_token( $token );
|
65 |
+
//add filter
|
66 |
+
add_filter( 'rtmedia_current_user', array( $this->rtmediajsonapifunction, 'rtmedia_api_set_user_id' ) );
|
67 |
+
}
|
68 |
+
//Process Request
|
69 |
+
|
70 |
+
switch ( $method ) {
|
71 |
+
|
72 |
+
case 'wp_login':
|
73 |
+
$this->rtmedia_api_process_wp_login_request();
|
74 |
+
break;
|
75 |
+
case 'wp_logout':
|
76 |
+
//todo implement this function rtmedia_api_process_wp_logout_request if needed
|
77 |
+
//$this->rtmedia_api_process_wp_logout_request();
|
78 |
+
break;
|
79 |
+
case 'wp_register':
|
80 |
+
$this->rtmedia_api_process_wp_register_request();
|
81 |
+
break;
|
82 |
+
case 'wp_forgot_password':
|
83 |
+
$this->rtmedia_api_process_wp_forgot_password_request();
|
84 |
+
break;
|
85 |
+
case 'bp_get_profile':
|
86 |
+
$this->rtmedia_api_process_bp_get_profile_request();
|
87 |
+
break;
|
88 |
+
case 'bp_get_activities':
|
89 |
+
$this->rtmedia_api_process_bp_get_activities_request();
|
90 |
+
break;
|
91 |
+
case 'add_rtmedia_comment':
|
92 |
+
$this->rtmedia_api_process_add_rtmedia_comment_request();
|
93 |
+
break;
|
94 |
+
case 'like_media':
|
95 |
+
$this->rtmedia_api_process_like_media_request();
|
96 |
+
break;
|
97 |
+
case 'get_rtmedia_comments':
|
98 |
+
$this->rtmedia_api_process_get_rtmedia_comments_request();
|
99 |
+
break;
|
100 |
+
case 'get_likes_rtmedia':
|
101 |
+
$this->rtmedia_api_process_get_likes_rtmedia_request();
|
102 |
+
break;
|
103 |
+
case 'remove_comment':
|
104 |
+
$this->rtmedia_api_process_remove_comment_request();
|
105 |
+
break;
|
106 |
+
case 'update_profile':
|
107 |
+
$this->rtmedia_api_process_update_profile_request();
|
108 |
+
break;
|
109 |
+
case 'rtmedia_upload_media':
|
110 |
+
$this->rtmedia_api_process_rtmedia_upload_media_request();
|
111 |
+
break;
|
112 |
+
case 'rtmedia_gallery':
|
113 |
+
$this->rtmedia_api_process_rtmedia_gallery_request();
|
114 |
+
break;
|
115 |
+
case 'rtmedia_get_media_details':
|
116 |
+
$this->rtmedia_api_process_rtmedia_get_media_details_request();
|
117 |
+
break;
|
118 |
+
default:
|
119 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_invalid_request_type, $this->msg_invalid_request_type ) );
|
120 |
+
}
|
121 |
+
|
122 |
+
wp_die();
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Returns a json object
|
127 |
+
*
|
128 |
+
* @param string $status
|
129 |
+
* @param int $status_code
|
130 |
+
* @param string $message
|
131 |
+
* @param bool|array $data
|
132 |
+
*
|
133 |
+
* @return bool
|
134 |
+
*/
|
135 |
+
function rtmedia_api_response_object( $status, $status_code, $message, $data = false ) {
|
136 |
+
if ( '' === $status || empty( $status_code ) || empty( $message ) ) {
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
if ( ob_get_contents() ) {
|
141 |
+
ob_end_clean();
|
142 |
+
}
|
143 |
+
global $wpdb;
|
144 |
+
$rtmapilogin = new RTMediaApiLogin();
|
145 |
+
$token = filter_input( INPUT_POST, 'token', FILTER_SANITIZE_STRING );
|
146 |
+
$login_details = array( 'last_access' => current_time( 'mysql' ) );
|
147 |
+
if ( ! empty( $token ) ) {
|
148 |
+
$where = array( 'user_id' => $this->user_id, 'token' => $token );
|
149 |
+
}
|
150 |
+
if ( ! empty( $where ) ) {
|
151 |
+
$rtmapilogin->update( $login_details, $where );
|
152 |
+
}
|
153 |
+
$response_object = array();
|
154 |
+
$response_object['status'] = $status;
|
155 |
+
$response_object['status_code'] = $status_code;
|
156 |
+
$response_object['message'] = $message;
|
157 |
+
$response_object['data'] = $data;
|
158 |
+
|
159 |
+
return $response_object;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Takes username and password, if succesful returns a access token
|
164 |
+
*/
|
165 |
+
function rtmedia_api_process_wp_login_request() {
|
166 |
+
//Login Errors and Messages
|
167 |
+
$ec_user_pass_missing = 200001;
|
168 |
+
$msg_user_pass_missing = esc_html__( 'username/password empty', 'buddypress-media' );
|
169 |
+
|
170 |
+
$ec_incorrect_username = 200002;
|
171 |
+
$msg_incorrect_username = esc_html__( 'incorrect username', 'buddypress-media' );
|
172 |
+
|
173 |
+
$ec_incorrect_pass = 200003;
|
174 |
+
$msg_incorrect_pass = esc_html__( 'incorrect password', 'buddypress-media' );
|
175 |
+
|
176 |
+
$ec_login_success = 200004;
|
177 |
+
$msg_login_success = esc_html__( 'login success', 'buddypress-media' );
|
178 |
+
$username = filter_input( INPUT_POST, 'username', FILTER_SANITIZE_STRING );
|
179 |
+
$password = filter_input( INPUT_POST, 'password', FILTER_SANITIZE_STRING );
|
180 |
+
|
181 |
+
if ( empty( $username ) || empty( $password ) ) {
|
182 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_user_pass_missing, $msg_user_pass_missing ) );
|
183 |
+
} else {
|
184 |
+
$user_login = wp_authenticate( trim( $username ), trim( $password ) );
|
185 |
+
if ( is_wp_error( $user_login ) ) {
|
186 |
+
|
187 |
+
$incorrect_password = ! empty( $user_login->errors['incorrect_password'] ) ? true : false;
|
188 |
+
$incorrect_username = ! empty( $user_login->errors['invalid_username'] ) ? true : false;
|
189 |
+
if ( $incorrect_password ) {
|
190 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_incorrect_pass, $msg_incorrect_pass ) );
|
191 |
+
} elseif ( $incorrect_username ) {
|
192 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_incorrect_username, $msg_incorrect_username ) );
|
193 |
+
}
|
194 |
+
} else {
|
195 |
+
$access_token = $this->rtmediajsonapifunction->rtmedia_api_get_user_token( $user_login->ID, $user_login->data->user_login );
|
196 |
+
$data = array(
|
197 |
+
'access_token' => $access_token,
|
198 |
+
);
|
199 |
+
$rtmapilogin = new RTMediaApiLogin();
|
200 |
+
|
201 |
+
//update all tokens for user to exired on each login
|
202 |
+
$rtmapilogin->update( array( 'status' => 'FALSE' ), array( 'user_id' => $user_login->ID ) );
|
203 |
+
$remote_addr = filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );
|
204 |
+
$login_details = array(
|
205 |
+
'user_id' => intval( $user_login->ID ),
|
206 |
+
'ip' => $remote_addr,
|
207 |
+
'token' => sanitize_text_field( $access_token ),
|
208 |
+
'token_time' => date( 'Y-m-d H:i:s' ),
|
209 |
+
);
|
210 |
+
$rtmapilogin->insert( $login_details );
|
211 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_login_success, $msg_login_success, $data ) );
|
212 |
+
}
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* register a user through api request
|
218 |
+
* requires signup_* => display_name, username, password, confirm password, location,
|
219 |
+
*/
|
220 |
+
function rtmedia_api_process_wp_register_request() {
|
221 |
+
//Registration errors and messages
|
222 |
+
$ec_register_fields_missing = 300001;
|
223 |
+
$msg_register_fields_missing = esc_html__( 'fields empty', 'buddypress-media' );
|
224 |
+
|
225 |
+
$ec_invalid_email = 300002;
|
226 |
+
$msg_invalid_email = esc_html__( 'invalid email', 'buddypress-media' );
|
227 |
+
|
228 |
+
$ec_pass_do_not_match = 300003;
|
229 |
+
$msg_pass_do_not_match = esc_html__( 'password do not match', 'buddypress-media' );
|
230 |
+
|
231 |
+
$ec_username_exists = 300004;
|
232 |
+
$msg_username_exists = esc_html__( 'username already registered', 'buddypress-media' );
|
233 |
+
|
234 |
+
$ec_email_exists = 300005;
|
235 |
+
$msg_email_existsh = esc_html__( 'email already exists', 'buddypress-media' );
|
236 |
+
|
237 |
+
$ec_user_insert_success = 300007;
|
238 |
+
$msg_user_insert_success = esc_html__( 'new user created', 'buddypress-media' );
|
239 |
+
|
240 |
+
$registration_fields = array( 'username', 'email', 'password', 'password_confirm' );
|
241 |
+
//fields empty field_1, field_4
|
242 |
+
$field_1 = filter_input( INPUT_POST, 'field_1', FILTER_SANITIZE_STRING );
|
243 |
+
|
244 |
+
if ( empty( $field_1 ) ) {
|
245 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_register_fields_missing, $msg_register_fields_missing ) );
|
246 |
+
}
|
247 |
+
foreach ( $registration_fields as $field_name ) {
|
248 |
+
$field_signup = filter_input( INPUT_POST, 'signup_' . $field_name, FILTER_SANITIZE_STRING );
|
249 |
+
if ( empty( $field_signup ) ) {
|
250 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_register_fields_missing, $msg_register_fields_missing ) );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
$signup_email = filter_input( INPUT_POST, 'signup_email', FILTER_VALIDATE_EMAIL );
|
254 |
+
$signup_username = filter_input( INPUT_POST, 'signup_username', FILTER_SANITIZE_STRING );
|
255 |
+
$signup_password = filter_input( INPUT_POST, 'signup_password', FILTER_SANITIZE_STRING );
|
256 |
+
$signup_password_confirm = filter_input( INPUT_POST, 'signup_password_confirm', FILTER_SANITIZE_STRING );
|
257 |
+
|
258 |
+
//incorrect email
|
259 |
+
if ( ! is_email( $signup_email ) ) {
|
260 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_invalid_email, $msg_invalid_email ) );
|
261 |
+
} //Passwords do not match
|
262 |
+
elseif ( $signup_password !== $signup_password_confirm ) {
|
263 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_pass_do_not_match, $msg_pass_do_not_match ) );
|
264 |
+
} //Username already registered
|
265 |
+
elseif ( username_exists( $signup_username ) ) {
|
266 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_username_exists, $msg_username_exists ) );
|
267 |
+
} //email already registered
|
268 |
+
elseif ( email_exists( $signup_email ) ) {
|
269 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_email_exists, $msg_email_existsh ) );
|
270 |
+
} else {
|
271 |
+
$userdata = array(
|
272 |
+
'user_login' => sanitize_user( $signup_username ),
|
273 |
+
'user_pass' => $signup_password,
|
274 |
+
'display_name' => sanitize_text_field( $field_1 ),
|
275 |
+
);
|
276 |
+
|
277 |
+
$user_id = wp_insert_user( $userdata );
|
278 |
+
if ( ! is_wp_error( $user_id ) ) {
|
279 |
+
echo esc_html( xprofile_get_field_id_from_name( 'field_1' ) );
|
280 |
+
xprofile_set_field_data( 1, $user_id, sanitize_text_field( $field_1 ) );
|
281 |
+
//todo user attr
|
282 |
+
update_user_meta( $user_id, 'register_source', 'site_api' );
|
283 |
+
echo wp_json_encode( $this->rtmedia_api_response_object( 'TRUE', $ec_user_insert_success, $msg_user_insert_success ) );
|
284 |
+
wp_die();
|
285 |
+
} else {
|
286 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_server_error, $this->msg_server_error ) );
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Sends a reset link to user email
|
293 |
+
* @global type $wpdb
|
294 |
+
*/
|
295 |
+
function rtmedia_api_process_wp_forgot_password_request() {
|
296 |
+
global $wpdb;
|
297 |
+
//Registration errors and messages
|
298 |
+
$ec_email_missing = 500001;
|
299 |
+
$msg_email_missing = esc_html__( 'email empty', 'buddypress-media' );
|
300 |
+
|
301 |
+
$ec_username_email_not_registered = 500002;
|
302 |
+
$msg_username_email_not_registered = esc_html__( 'username/email not registered', 'buddypress-media' );
|
303 |
+
|
304 |
+
$ec_email_sent = 500003;
|
305 |
+
$msg_email_sent = esc_html__( 'reset link sent', 'buddypress-media' );
|
306 |
+
$user_login = filter_input( INPUT_POST, 'user_login', FILTER_SANITIZE_STRING );
|
307 |
+
|
308 |
+
if ( empty( $user_login ) ) {
|
309 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_email_missing, $msg_email_missing ) );
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( username_exists( $user_login ) ) {
|
313 |
+
$user_exists = true;
|
314 |
+
$user = get_user_by( 'login', sanitize_user( $user_login ) );
|
315 |
+
} // Then, by e-mail address
|
316 |
+
elseif ( email_exists( $user_login ) ) {
|
317 |
+
$user_exists = true;
|
318 |
+
$user = get_user_by( 'email', sanitize_email( $user_login ) );
|
319 |
+
} else {
|
320 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_username_email_not_registered, $msg_username_email_not_registered ) );
|
321 |
+
}
|
322 |
+
$user_login = $user->data->user_login;
|
323 |
+
$user_email = $user->data->user_email;
|
324 |
+
|
325 |
+
// Generate something random for a key...
|
326 |
+
$key = wp_generate_password( 20, false );
|
327 |
+
do_action( 'retrieve_password_key', $user_login, $key );
|
328 |
+
// Now insert the new md5 key into the db
|
329 |
+
// Now insert the key, hashed, into the DB.
|
330 |
+
if ( empty( $wp_hasher ) ) {
|
331 |
+
require_once ABSPATH . 'wp-includes/class-phpass.php';
|
332 |
+
$wp_hasher = new PasswordHash( 8, true );
|
333 |
+
}
|
334 |
+
$hashed = $wp_hasher->HashPassword( $key );
|
335 |
+
$wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => sanitize_user( $user_login ) ) );
|
336 |
+
|
337 |
+
//create email message
|
338 |
+
$message = esc_html__( 'Someone has asked to reset the password for the following site and username.', 'buddypress-media' ) . "\r\n\r\n";
|
339 |
+
$message .= esc_url( get_option( 'siteurl' ) ) . "\r\n\r\n";
|
340 |
+
$message .= sprintf( esc_html__( 'Username: %s', 'buddypress-media' ), $user_login ) . "\r\n\r\n";
|
341 |
+
$message .= esc_html__( 'To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'buddypress-media' ) . "\r\n\r\n";
|
342 |
+
$message .= '<' . esc_url( network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) ) . ">\r\n";
|
343 |
+
//send email meassage
|
344 |
+
if ( false === wp_mail( $user_email, sprintf( esc_html__( '[%s] Password Reset', 'buddypress-media' ), get_option( 'blogname' ) ), $message ) ) {
|
345 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_server_error, $this->msg_server_error ) );
|
346 |
+
} else {
|
347 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_email_sent, $msg_email_sent ) );
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Sends a reset link to user email
|
353 |
+
* @global type $wpdb
|
354 |
+
*/
|
355 |
+
function rtmedia_api_process_bp_get_activities_request() {
|
356 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
357 |
+
//Feed Errors
|
358 |
+
$ec_latest_feed = 700001;
|
359 |
+
$msg_latest_feed = esc_html__( 'bp activities', 'buddypress-media' );
|
360 |
+
|
361 |
+
$ec_my_looks = 700002;
|
362 |
+
$msg_my_looks = esc_html__( 'user activities', 'buddypress-media' );
|
363 |
+
|
364 |
+
//Fetch user id from token
|
365 |
+
$activity_user_id = filter_input( INPUT_POST, 'activity_user_id', FILTER_VALIDATE_INT );
|
366 |
+
$per_page = filter_input( INPUT_POST, 'per_page', FILTER_VALIDATE_INT );
|
367 |
+
|
368 |
+
$per_page = ! empty( $per_page ) ? $per_page : 10;
|
369 |
+
$activity_feed = $this->rtmediajsonapifunction->rtmedia_api_get_feed( $activity_user_id, '', $per_page );
|
370 |
+
if ( empty( $activity_feed ) ) {
|
371 |
+
$activity_feed = esc_html__( 'no updates', 'buddypress-media' );
|
372 |
+
}
|
373 |
+
if ( ! empty( $activity_user_id ) ) {
|
374 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_my_looks, $msg_my_looks, $activity_feed ) );
|
375 |
+
} else {
|
376 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_latest_feed, $msg_latest_feed, $activity_feed ) );
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Post comment on activity_id or media_id
|
382 |
+
* @global type $this ->msg_server_error
|
383 |
+
* @global int $this ->ec_server_error
|
384 |
+
* @global int $this ->ec_invalid_media_id
|
385 |
+
* @global type $this ->msg_invalid_media_id
|
386 |
+
*/
|
387 |
+
function rtmedia_api_process_add_rtmedia_comment_request() {
|
388 |
+
|
389 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
390 |
+
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
391 |
+
//Post comment errors
|
392 |
+
$ec_comment_content_missing = 800001;
|
393 |
+
$msg_comment_content_missing = esc_html__( 'comment content missing', 'buddypress-media' );
|
394 |
+
|
395 |
+
$ec_comment_posted = 800002;
|
396 |
+
$msg_comment_posted = esc_html__( 'comment posted', 'buddypress-media' );
|
397 |
+
|
398 |
+
//Fetch user id from token
|
399 |
+
$user_data = get_userdata( $this->user_id );
|
400 |
+
|
401 |
+
$content = filter_input( INPUT_POST, 'content', FILTER_SANITIZE_STRING );
|
402 |
+
|
403 |
+
if ( empty( $content ) ) {
|
404 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_comment_content_missing, $msg_comment_content_missing ) );
|
405 |
+
}
|
406 |
+
|
407 |
+
if ( empty( $activity_id ) && ! empty( $media_id ) ) {
|
408 |
+
$activity_id = $this->rtmediajsonapifunction->rtmedia_api_activityid_from_mediaid( $media_id );
|
409 |
+
}
|
410 |
+
if ( empty( $activity_id ) ) {
|
411 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_invalid_media_id, $this->msg_invalid_media_id ) );
|
412 |
+
}
|
413 |
+
$args = array(
|
414 |
+
'content' => $content,
|
415 |
+
'activity_id' => intval( $activity_id ),
|
416 |
+
'user_id' => intval( $this->user_id ),
|
417 |
+
'parent_id' => false,
|
418 |
+
);
|
419 |
+
if ( function_exists( 'bp_activity_new_comment' ) ) {
|
420 |
+
$comment_id = bp_activity_new_comment( $args );
|
421 |
+
}
|
422 |
+
if ( isset( $comment_id ) ) {
|
423 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_comment_posted, $msg_comment_posted ) );
|
424 |
+
} else {
|
425 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->msg_server_error, $this->ec_server_error ) );
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Like/Unlike by media_id or activity_id
|
431 |
+
* @global int $this ->ec_server_error
|
432 |
+
* @global type $this ->msg_server_error
|
433 |
+
* @global int $this ->ec_invalid_media_id
|
434 |
+
* @global type $this ->msg_invalid_media_id
|
435 |
+
*/
|
436 |
+
function rtmedia_api_process_like_media_request() {
|
437 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
438 |
+
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
439 |
+
|
440 |
+
//Like errors
|
441 |
+
$ec_already_liked = 900001;
|
442 |
+
$msg_already_liked = esc_html__( 'unliked media', 'buddypress-media' );
|
443 |
+
|
444 |
+
$ec_liked_media = 900002;
|
445 |
+
$msg_liked_media = esc_html__( 'liked media', 'buddypress-media' );
|
446 |
+
|
447 |
+
$media_id = filter_input( INPUT_POST, 'media_id', FILTER_SANITIZE_NUMBER_INT );
|
448 |
+
|
449 |
+
if ( class_exists( 'RTMediaInteractionModel' ) ) :
|
450 |
+
$rtmediainteraction = new RTMediaInteractionModel();
|
451 |
+
|
452 |
+
if ( class_exists( 'RTMediaLike' ) ) {
|
453 |
+
$rtmedialike = new RTMediaLike();
|
454 |
+
}
|
455 |
+
|
456 |
+
$action = 'like';
|
457 |
+
// Like or Unlike
|
458 |
+
if ( ! rtmedia_media_id( $media_id ) ) {
|
459 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_invalid_media_id, $this->msg_invalid_media_id ) );
|
460 |
+
}
|
461 |
+
|
462 |
+
$like_count_old = get_rtmedia_like( rtmedia_media_id( $media_id ) );
|
463 |
+
$check_action = $rtmediainteraction->check( $this->user_id, $media_id, $action );
|
464 |
+
if ( $check_action ) {
|
465 |
+
$results = $rtmediainteraction->get_row( $this->user_id, $media_id, $action );
|
466 |
+
$row = $results[0];
|
467 |
+
$curr_value = $row->value;
|
468 |
+
if ( 1 === intval( $curr_value ) ) {
|
469 |
+
$value = '0';
|
470 |
+
$increase = false;
|
471 |
+
} else {
|
472 |
+
$value = '1';
|
473 |
+
$increase = true;
|
474 |
+
}
|
475 |
+
$update_data = array( 'value' => $value );
|
476 |
+
$where_columns = array(
|
477 |
+
'user_id' => $this->user_id,
|
478 |
+
'media_id' => $media_id,
|
479 |
+
'action' => $action,
|
480 |
+
);
|
481 |
+
$update = $rtmediainteraction->update( $update_data, $where_columns );
|
482 |
+
} else {
|
483 |
+
$value = '1';
|
484 |
+
$columns = array(
|
485 |
+
'user_id' => $this->user_id,
|
486 |
+
'media_id' => $media_id,
|
487 |
+
'action' => $action,
|
488 |
+
'value' => $value,
|
489 |
+
);
|
490 |
+
$insert_id = $rtmediainteraction->insert( $columns );
|
491 |
+
$increase = true;
|
492 |
+
}
|
493 |
+
if ( $increase ) {
|
494 |
+
$like_count_old ++;
|
495 |
+
} elseif ( ! $increase ) {
|
496 |
+
$like_count_old --;
|
497 |
+
}
|
498 |
+
if ( $like_count_old < 0 ) {
|
499 |
+
$like_count_old = 0;
|
500 |
+
}
|
501 |
+
$data = array( 'like_count' => $like_count_old );
|
502 |
+
if ( ! empty( $insert_id ) && isset( $rtmedialike ) ) {
|
503 |
+
$rtmedialike->model->update( array( 'likes' => $like_count_old ), array( 'id' => $media_id ) );
|
504 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_liked_media, $msg_liked_media, $data ) );
|
505 |
+
} elseif ( ! empty( $update ) && isset( $rtmedialike ) ) {
|
506 |
+
$rtmedialike->model->update( array( 'likes' => $like_count_old ), array( 'id' => $media_id ) );
|
507 |
+
if ( 1 === intval( $value ) ) {
|
508 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_liked_media, $msg_liked_media, $data ) );
|
509 |
+
} elseif ( 0 === intval( $value ) ) {
|
510 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_already_liked, $msg_already_liked, $data ) );
|
511 |
+
}
|
512 |
+
} else {
|
513 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_server_error, $this->msg_server_error ) );
|
514 |
+
}
|
515 |
+
endif;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Fetch Comments by media id
|
520 |
+
* @global type $wpdb
|
521 |
+
*/
|
522 |
+
function rtmedia_api_process_get_rtmedia_comments_request() {
|
523 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
524 |
+
//Errors Fetching comment
|
525 |
+
$ec_no_comments = 800003;
|
526 |
+
$msg_no_comments = esc_html__( 'no comments', 'buddypress-media' );
|
527 |
+
|
528 |
+
$ec_media_comments = 800004;
|
529 |
+
$msg_media_comments = esc_html__( 'media comments', 'buddypress-media' );
|
530 |
+
|
531 |
+
$ec_my_comments = 800005;
|
532 |
+
$msg_my_comments = esc_html__( 'my comments', 'buddypress-media' );
|
533 |
+
|
534 |
+
$media_id = filter_input( INPUT_POST, 'media_id', FILTER_SANITIZE_NUMBER_INT );
|
535 |
+
|
536 |
+
global $wpdb;
|
537 |
+
if ( empty( $media_id ) ) {
|
538 |
+
$user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $this->user_id );
|
539 |
+
$comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE user_id = %d limit 100", $this->user_id ), ARRAY_A );
|
540 |
+
$my_comments = array();
|
541 |
+
if ( ! empty( $comments ) ) {
|
542 |
+
foreach ( $comments as $comment ) {
|
543 |
+
$my_comments['comments'][] = array(
|
544 |
+
'comment_ID' => $comment['comment_ID'],
|
545 |
+
'comment_content' => $comment['comment_content'],
|
546 |
+
'media_id' => $comment['comment_post_ID'],
|
547 |
+
);
|
548 |
+
}
|
549 |
+
$my_comments['user'] = array(
|
550 |
+
'user_id' => $this->user_id,
|
551 |
+
'name' => $user_data['name'],
|
552 |
+
'avatar' => $user_data['avatar'],
|
553 |
+
);
|
554 |
+
|
555 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_media_comments, $msg_media_comments, $my_comments ) );
|
556 |
+
}
|
557 |
+
} else {
|
558 |
+
$media_comments = $this->rtmediajsonapifunction->rtmedia_api_get_media_comments( $media_id );
|
559 |
+
if ( $media_comments ) {
|
560 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_media_comments, $msg_media_comments, $media_comments ) );
|
561 |
+
} else {
|
562 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_no_comments, $msg_no_comments ) );
|
563 |
+
}
|
564 |
+
}
|
565 |
+
//If no comments
|
566 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_no_comments, $msg_no_comments ) );
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Fetch Likes by media id
|
571 |
+
* @global type $wpdb
|
572 |
+
*/
|
573 |
+
function rtmedia_api_process_get_likes_rtmedia_request() {
|
574 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
575 |
+
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
576 |
+
global $wpdb;
|
577 |
+
//Errors Fetching Likes
|
578 |
+
$ec_no_likes = 900003;
|
579 |
+
$msg_no_likes = esc_html__( 'no likes', 'buddypress-media' );
|
580 |
+
|
581 |
+
$ec_media_likes = 900004;
|
582 |
+
$msg_media_likes = esc_html__( 'media likes', 'buddypress-media' );
|
583 |
+
$media_id = filter_input( INPUT_POST, 'media_id', FILTER_SANITIZE_NUMBER_INT );
|
584 |
+
$media_likes = filter_input( INPUT_POST, 'media_likes', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
585 |
+
$media_like_users = filter_input( INPUT_POST, 'media_like_users',FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
586 |
+
if ( isset( $media_likes['user'] ) && ! is_array( $media_likes['user'] ) ) {
|
587 |
+
$media_likes['user'] = array();
|
588 |
+
}
|
589 |
+
if ( empty( $media_likes ) || ! is_array( $media_likes ) ) {
|
590 |
+
$media_likes = array();
|
591 |
+
}
|
592 |
+
if ( empty( $media_like_users ) || ! is_array( $media_like_users ) ) {
|
593 |
+
$media_like_users = array();
|
594 |
+
}
|
595 |
+
|
596 |
+
$media_like_users = $this->rtmediajsonapifunction->rtmedia_api_media_liked_by_user( $media_id );
|
597 |
+
if ( ! empty( $media_like_users ) ) {
|
598 |
+
foreach ( $media_like_users as $like_details ) {
|
599 |
+
if ( ! array_key_exists( $like_details->user_id, $media_likes['user'] ) ) {
|
600 |
+
|
601 |
+
$user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $like_details->user_id );
|
602 |
+
$mysql_time = current_time( 'mysql' );
|
603 |
+
$like_time = human_time_diff( strtotime( $like_details->action_date ), strtotime( $mysql_time ) );
|
604 |
+
$media_likes['likes'][] = array(
|
605 |
+
'activity_time' => $like_time,
|
606 |
+
'user_id' => $like_details->user_id,
|
607 |
+
);
|
608 |
+
$media_likes['user'][ $like_details->user_id ] = array(
|
609 |
+
'name' => $user_data['name'],
|
610 |
+
'avatar' => $user_data['avatar'],
|
611 |
+
);
|
612 |
+
}
|
613 |
+
}
|
614 |
+
}
|
615 |
+
if ( ! empty( $media_likes ) ) {
|
616 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_media_likes, $msg_media_likes, $media_likes ) );
|
617 |
+
} else {
|
618 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_no_likes, $msg_no_likes ) );
|
619 |
+
}
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Delete comment by activity id or media id
|
624 |
+
*/
|
625 |
+
function rtmedia_api_process_remove_comment_request() {
|
626 |
+
global $wpdb;
|
627 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
628 |
+
$this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
|
629 |
+
//Errors Deleting comment
|
630 |
+
|
631 |
+
$ec_comment_not_found = 800007;
|
632 |
+
$msg_comment_not_found = esc_html__( 'invalid comment/media id', 'buddypress-media' );
|
633 |
+
|
634 |
+
$ec_no_comment_id = 800008;
|
635 |
+
$msg_no_comment_id = esc_html__( 'no comment id', 'buddypress-media' );
|
636 |
+
|
637 |
+
$ec_comment_deleted = 800009;
|
638 |
+
$msg_comment_deleted = esc_html__( 'comment deleted', 'buddypress-media' );
|
639 |
+
|
640 |
+
$media_id = filter_input( INPUT_POST, 'media_id', FILTER_SANITIZE_NUMBER_INT );
|
641 |
+
$comment_id = filter_input( INPUT_POST, 'comment_id', FILTER_SANITIZE_NUMBER_INT );
|
642 |
+
|
643 |
+
if ( empty( $comment_id ) ) {
|
644 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_no_comment_id, $msg_no_comment_id ) );
|
645 |
+
}
|
646 |
+
$id = rtmedia_media_id( $media_id );
|
647 |
+
$sql = $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d AND comment_post_ID = %d AND user_id = %d limit 100", $comment_id, $id, $this->user_id );
|
648 |
+
|
649 |
+
$comments = $wpdb->get_results( $sql, ARRAY_A ); // @codingStandardsIgnoreLine
|
650 |
+
//Delete Comment
|
651 |
+
if ( ! empty( $comments ) ) {
|
652 |
+
$comment = new RTMediaComment();
|
653 |
+
|
654 |
+
$activity_id = get_comment_meta( $comment_id, 'activity_id', true );
|
655 |
+
|
656 |
+
if ( ! empty( $activity_id ) ) {
|
657 |
+
$activity_deleted = bp_activity_delete_comment( $activity_id, $comment_id );
|
658 |
+
|
659 |
+
$delete = bp_activity_delete( array( 'id' => $activity_id, 'type' => 'activity_comment' ) );
|
660 |
+
|
661 |
+
}
|
662 |
+
$comment_deleted = $comment->rtmedia_comment_model->delete( $comment_id );
|
663 |
+
|
664 |
+
if ( $comment_deleted ) {
|
665 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_comment_deleted, $msg_comment_deleted ) );
|
666 |
+
} else {
|
667 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $this->ec_server_error, $this->msg_server_error ) );
|
668 |
+
}
|
669 |
+
} else {
|
670 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_comment_not_found, $msg_comment_not_found ) );
|
671 |
+
}
|
672 |
+
}
|
673 |
+
|
674 |
+
function rtmedia_api_process_bp_get_profile_request() {
|
675 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
676 |
+
//Errors
|
677 |
+
$ec_no_fields = 400001;
|
678 |
+
$msg_no_fields = esc_html__( 'no profile found', 'buddypress-media' );
|
679 |
+
|
680 |
+
$ec_profile_fields = 400002;
|
681 |
+
$msg_profile_fields = esc_html__( 'profile fields', 'buddypress-media' );
|
682 |
+
|
683 |
+
$profile_fields = array();
|
684 |
+
$user_id = $loggedin_user_id = '';
|
685 |
+
|
686 |
+
$user_id = filter_input( INPUT_POST, 'user_id', FILTER_SANITIZE_NUMBER_INT );
|
687 |
+
$loggedin_user_id = filter_input( INPUT_POST, 'loggedin_user_id', FILTER_SANITIZE_NUMBER_INT );
|
688 |
+
|
689 |
+
if ( empty( $user_id ) ) {
|
690 |
+
$user_id = $this->user_id;
|
691 |
+
} else {
|
692 |
+
$loggedin_user_id = $this->user_id;
|
693 |
+
}
|
694 |
+
$user = get_userdata( $user_id );
|
695 |
+
if ( empty( $user ) ) {
|
696 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_no_fields, $msg_no_fields ) );
|
697 |
+
}
|
698 |
+
$user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $user_id, 250, 250, 'full' );
|
699 |
+
$profile_fields['id'] = $user_id;
|
700 |
+
$profile_fields['avatar']['src'] = esc_url( $user_data['avatar'] );
|
701 |
+
$profile_fields['avatar']['width'] = 250;
|
702 |
+
$profile_fields['avatar']['height'] = 250;
|
703 |
+
|
704 |
+
if ( bp_has_profile( array( 'user_id' => $user_id ) ) ) :
|
705 |
+
while ( bp_profile_groups() ) : bp_the_profile_group();
|
706 |
+
|
707 |
+
if ( bp_profile_group_has_fields() ) :
|
708 |
+
|
709 |
+
while ( bp_profile_fields() ) : bp_the_profile_field();
|
710 |
+
|
711 |
+
if ( bp_field_has_data() ) :
|
712 |
+
|
713 |
+
$profile_fields['fields'][ bp_get_the_profile_field_name() ] = array(
|
714 |
+
'value' => strip_tags( bp_get_the_profile_field_value() ),
|
715 |
+
'privacy' => bp_get_the_profile_field_visibility_level(),
|
716 |
+
);
|
717 |
+
endif;
|
718 |
+
|
719 |
+
endwhile;
|
720 |
+
endif;
|
721 |
+
endwhile;
|
722 |
+
else :
|
723 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_no_fields, $msg_no_fields ) );
|
724 |
+
endif;
|
725 |
+
//If followers plugin exists
|
726 |
+
if ( function_exists( 'rtmedia_api_followers' ) ) {
|
727 |
+
$followers = rtmedia_api_followers( $user_id );
|
728 |
+
$following = $this->rtmediajsonapifunction->rtmedia_api_following( $user_id );
|
729 |
+
|
730 |
+
foreach ( $followers as $follower ) {
|
731 |
+
$follower_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $follower, 66, 66 );
|
732 |
+
$profile_fields['follower'][] = array(
|
733 |
+
'id' => $follower,
|
734 |
+
'name' => $follower_data['name'],
|
735 |
+
'avatar' => $follower_data['avatar'],
|
736 |
+
);
|
737 |
+
}
|
738 |
+
|
739 |
+
foreach ( $following as $follow ) {
|
740 |
+
$follow_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id( $follow, 66, 66 );
|
741 |
+
$profile_fields['following'][] = array(
|
742 |
+
'id' => $follow,
|
743 |
+
'name' => $follow_data['name'],
|
744 |
+
'avatar' => $follow_data['avatar'],
|
745 |
+
);
|
746 |
+
}
|
747 |
+
}
|
748 |
+
if ( ! empty( $user_id ) && intval( $loggedin_user_id ) !== intval( $user_id ) ) {
|
749 |
+
$args = array(
|
750 |
+
'leader_id' => $user_id,
|
751 |
+
'follower_id' => $loggedin_user_id,
|
752 |
+
);
|
753 |
+
if ( function_exists( 'bp_follow_is_following' ) ) {
|
754 |
+
$profile_fields['loggedin_user']['following'] = 'FALSE';
|
755 |
+
if ( bp_follow_is_following( $args ) ) {
|
756 |
+
$profile_fields['loggedin_user']['following'] = 'TRUE';
|
757 |
+
}
|
758 |
+
|
759 |
+
$args = array(
|
760 |
+
'leader_id' => $loggedin_user_id,
|
761 |
+
'follower_id' => $user_id,
|
762 |
+
);
|
763 |
+
$profile_fields['loggedin_user']['followed'] = 'FALSE';
|
764 |
+
if ( bp_follow_is_following( $args ) ) {
|
765 |
+
$profile_fields['loggedin_user']['followed'] = 'TRUE';
|
766 |
+
}
|
767 |
+
}
|
768 |
+
}
|
769 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_profile_fields, $msg_profile_fields, $profile_fields ) );
|
770 |
+
}
|
771 |
+
|
772 |
+
function rtmedia_api_process_follow_request() {
|
773 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
774 |
+
$ec_empty_follow_id = 400003;
|
775 |
+
$msg_empty_follow_id = esc_html__( 'follow user id missing', 'buddypress-media' );
|
776 |
+
|
777 |
+
$ec_started_following = 400004;
|
778 |
+
$msg_started_following = esc_html__( 'started following', 'buddypress-media' );
|
779 |
+
|
780 |
+
$ec_already_following = 400005;
|
781 |
+
$msg_already_following = esc_html__( 'already following', 'buddypress-media' );
|
782 |
+
|
783 |
+
$follow_id = filter_input( INPUT_POST, 'follow_id', FILTER_SANITIZE_NUMBER_INT );
|
784 |
+
|
785 |
+
if ( empty( $follow_id ) ) {
|
786 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_empty_follow_id, $msg_empty_follow_id ) );
|
787 |
+
}
|
788 |
+
$args = array(
|
789 |
+
'leader_id' => $follow_id,
|
790 |
+
'follower_id' => $this->user_id,
|
791 |
+
);
|
792 |
+
$already_following = bp_follow_is_following( $args );
|
793 |
+
if ( ! $already_following ) {
|
794 |
+
$follow_user = bp_follow_start_following( $args );
|
795 |
+
if ( $follow_user ) {
|
796 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_started_following, $msg_started_following ) );
|
797 |
+
} else {
|
798 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $this->ec_server_error, $this->msg_server_error ) );
|
799 |
+
}
|
800 |
+
} else {
|
801 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_already_following, $msg_already_following ) );
|
802 |
+
}
|
803 |
+
}
|
804 |
+
|
805 |
+
function rtmedia_api_process_unfollow_request() {
|
806 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
807 |
+
|
808 |
+
$ec_empty_unfollow_id = 400006;
|
809 |
+
$msg_empty_unfollow_id = esc_html__( 'unfollow id missing', 'buddypress-media' );
|
810 |
+
|
811 |
+
$ec_stopped_following = 400007;
|
812 |
+
$msg_stopped_following = esc_html__( 'stopped following', 'buddypress-media' );
|
813 |
+
|
814 |
+
$ec_not_following = 400008;
|
815 |
+
$msg_not_following = esc_html__( 'not following', 'buddypress-media' );
|
816 |
+
|
817 |
+
$unfollow_id = filter_input( INPUT_POST, 'unfollow_id', FILTER_SANITIZE_NUMBER_INT );
|
818 |
+
|
819 |
+
if ( empty( $unfollow_id ) ) {
|
820 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_empty_unfollow_id, $msg_empty_unfollow_id ) );
|
821 |
+
}
|
822 |
+
|
823 |
+
$args = array(
|
824 |
+
'leader_id' => $unfollow_id,
|
825 |
+
'follower_id' => $this->user_id,
|
826 |
+
);
|
827 |
+
$following = bp_follow_is_following( $args );
|
828 |
+
if ( $following ) {
|
829 |
+
$unfollow_user = bp_follow_stop_following( $args );
|
830 |
+
if ( $unfollow_user ) {
|
831 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_stopped_following, $msg_stopped_following ) );
|
832 |
+
} else {
|
833 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $this->ec_server_error, $this->msg_server_error ) );
|
834 |
+
}
|
835 |
+
} else {
|
836 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_not_following, $msg_not_following ) );
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
function rtmedia_api_process_update_profile_request() {
|
841 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
842 |
+
$ec_empty_name_location = 120001;
|
843 |
+
$msg_empty_name_location = esc_html__( 'name/location empty', 'buddypress-media' );
|
844 |
+
|
845 |
+
$ec_profile_updated = 120002;
|
846 |
+
$msg_profile_updated = esc_html__( 'profile updated', 'buddypress-media' );
|
847 |
+
|
848 |
+
for ( $i = 1; $i <= 12; $i ++ ) {
|
849 |
+
$field_str = 'field_';
|
850 |
+
$field_str .= $i;
|
851 |
+
$field_str_privacy = $field_str . '_privacy';
|
852 |
+
$$field_str = filter_input( INPUT_POST, $field_str, FILTER_SANITIZE_STRING );
|
853 |
+
$$field_str_privacy = filter_input( INPUT_POST, $field_str_privacy, FILTER_SANITIZE_STRING );
|
854 |
+
! empty( $$field_str ) ? $$field_str : '';
|
855 |
+
! empty( $$field_str_privacy ) ? $$field_str_privacy : 'public';
|
856 |
+
if ( 1 === $i || 4 === $i ) {
|
857 |
+
$field_str_privacy = 'public';
|
858 |
+
if ( empty( $field_str ) ) {
|
859 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_empty_name_location, $msg_empty_name_location ) );
|
860 |
+
}
|
861 |
+
}
|
862 |
+
xprofile_set_field_data( $i, $this->user_id, $$field_str );
|
863 |
+
xprofile_set_field_visibility_level( $i, $this->user_id, $$field_str_privacy );
|
864 |
+
}
|
865 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_profile_updated, $msg_profile_updated ) );
|
866 |
+
}
|
867 |
+
|
868 |
+
function rtmedia_api_process_update_avatar_request() {
|
869 |
+
|
870 |
+
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
|
871 |
+
$ec_no_file = 130001;
|
872 |
+
$msg_no_file = esc_html__( 'no file', 'buddypress-media' );
|
873 |
+
|
874 |
+
$ec_invalid_image = 130002;
|
875 |
+
$msg_invalid_image = esc_html__( 'upload failed, check size and file type', 'buddypress-media' );
|
876 |
+
|
877 |
+
$ec_avatar_updated = 130003;
|
878 |
+
$msg_avatar_updated = esc_html__( 'avatar updated', 'buddypress-media' );
|
879 |
+
if ( empty( $_FILES['file'] ) ) {
|
880 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_no_file, $msg_no_file ) );
|
881 |
+
}
|
882 |
+
$uploaded = bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' );
|
883 |
+
if ( ! $uploaded ) {
|
884 |
+
wp_send_json( $this->rtmedia_api_response_object( 'FALSE', $ec_invalid_image, $msg_invalid_image ) );
|
885 |
+
} else {
|
886 |
+
wp_send_json( $this->rtmedia_api_response_object( 'TRUE', $ec_avatar_updated, $msg_avatar_updated ) );
|
887 |
+
}
|
888 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|