From a3bd10e27e742c8b6aad4b015f1525da16c7187a Mon Sep 17 00:00:00 2001 From: vaishali Date: Wed, 20 Jun 2018 13:36:39 +0530 Subject: [PATCH 001/181] phpcs fixes in admin folder and assets/db folder files --- app/admin/RTMediaAdmin.php | 580 ++++++++++++++++--------------- app/admin/RTMediaFormHandler.php | 531 ++++++++++++++-------------- app/helper/db/RTDBModel.php | 80 +++-- app/helper/db/RTDBUpdate.php | 78 +++-- app/helper/db/rt_plugin_info.php | 119 +++++-- 5 files changed, 773 insertions(+), 615 deletions(-) diff --git a/app/admin/RTMediaAdmin.php b/app/admin/RTMediaAdmin.php index d8e6ced82..b35b118a9 100755 --- a/app/admin/RTMediaAdmin.php +++ b/app/admin/RTMediaAdmin.php @@ -1,11 +1,13 @@ rtmedia_support, 'submit_request' ), 1 ); - add_action( 'wp_ajax_rtmedia_linkback', array( $this, 'linkback' ), 1 ); //fixme : is it being used ? + add_action( 'wp_ajax_rtmedia_linkback', array( $this, 'linkback' ), 1 ); // fixme : is it being used ? add_action( 'wp_ajax_rtmedia_rt_album_deactivate', 'BPMediaAlbumimporter::bp_album_deactivate', 1 ); add_action( 'wp_ajax_rtmedia_rt_album_import', 'BPMediaAlbumimporter::bpmedia_ajax_import_callback', 1 ); add_action( 'wp_ajax_rtmedia_rt_album_import_favorites', 'BPMediaAlbumimporter::bpmedia_ajax_import_favorites', 1 ); add_action( 'wp_ajax_rtmedia_rt_album_import_step_favorites', 'BPMediaAlbumimporter::bpmedia_ajax_import_step_favorites', 1 ); add_action( 'wp_ajax_rtmedia_rt_album_cleanup', 'BPMediaAlbumimporter::cleanup_after_install' ); - add_action( 'wp_ajax_rtmedia_convert_videos_form', array( $this, 'convert_videos_mailchimp_send' ), 1 ); //fixme : is it being used ? + add_action( 'wp_ajax_rtmedia_convert_videos_form', array( $this, 'convert_videos_mailchimp_send' ), 1 ); // fixme : is it being used ? add_action( 'wp_ajax_rtmedia_correct_upload_filetypes', array( $this, 'correct_upload_filetypes' ), 1 ); add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_premium_addon_link' ), 1, 2 ); add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widgets' ), 0 ); @@ -111,7 +142,7 @@ public function __construct() { ), 1 ); add_action( 'wp_ajax_rtmedia_hide_premium_addon_notice', array( $this, 'rtmedia_hide_premium_addon_notice' ), 1 ); - new RTMediaMediaSizeImporter(); // do not delete this line. We only need to create object of this class if we are in admin section + new RTMediaMediaSizeImporter(); // do not delete this line. We only need to create object of this class if we are in admin section. if ( class_exists( 'BuddyPress' ) ) { new RTMediaActivityUpgrade(); } @@ -131,7 +162,7 @@ public function __construct() { /** * Display admin notice. */ - function install_transcoder_admin_notice() { + public function install_transcoder_admin_notice() { $show_notice = get_site_option( 'install_transcoder_admin_notice', 1 ); if ( '1' === $show_notice || 1 === $show_notice ) : ?> @@ -140,10 +171,10 @@ function install_transcoder_admin_notice() {

array( - 'href' => array(), - 'target' => array(), - ), + 'a' => array( + 'href' => array(), + 'target' => array(), + ), ); echo wp_kses( __( 'Install Transcoder plugin to convert audio/video files and thumbnails generation.', 'buddypress-media' ), $allowed_tags ); ?> @@ -165,17 +196,21 @@ function install_transcoder_admin_notice() { + if ( $display ) { + ?> ID ); if ( $rtm_id ) { - $link = get_rtmedia_permalink( $rtm_id ); - $title = _draft_or_post_title( $post->post_parent ); + $link = get_rtmedia_permalink( $rtm_id ); + $title = _draft_or_post_title( $post->post_parent ); + + // translators: Title. $action['view'] = '' . esc_html__( 'View', 'buddypress-media' ) . ''; } return $action; } - function rtmedia_migration() { + /** + * Rtmedia migration. + */ + public function rtmedia_migration() { new RTMediaMigration(); } - function rtmedia_addon_license_save_hook() { + /** + * Addon License save hook. + */ + public function rtmedia_addon_license_save_hook() { do_action( 'rtmedia_addon_license_save_hook' ); } @@ -231,8 +283,6 @@ function rtmedia_addon_license_save_hook() { * * @access public * - * @param void - * * @return void */ public function rtmedia_network_admin_notices() { @@ -246,8 +296,6 @@ public function rtmedia_network_admin_notices() { * * @access public * - * @param void - * * @return void */ public function rtmedia_admin_notices() { @@ -263,8 +311,8 @@ public function rtmedia_admin_notices() { } } - /* - * rtMedia Pro split release admin notice + /** + * For rtMedia Pro split release admin notice */ public function rtmedia_premium_addon_notice() { $site_option = rtmedia_get_site_option( 'rtmedia_premium_addon_notice' ); @@ -276,17 +324,15 @@ public function rtmedia_premium_addon_notice() {

store.', 'buddypress-media' ), $product_page - ); + $product_page = 'https://rtmedia.io/products/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media'; + + // translators: Product page link. + $message = sprintf( __( 'Check 30+ premium rtMedia add-ons on our store.', 'buddypress-media' ), $product_page ); ?> - Dismiss + Dismiss


- + flush_rules( true ); } $this->return_migration(); } - function migrate_encoding_options() { + /** + * Migrate encoding options. + */ + public function migrate_encoding_options() { $encoding_mnigration_array = array( 'bp-media-encoding-api-key' => 'rtmedia-encoding-api-key', 'bp-media-encoding-usage-limit-mail' => 'rtmedia-encoding-usage-limit-mail', @@ -580,7 +680,15 @@ function migrate_encoding_options() { } } - function migrate_single_media( $result, $album = false ) { + /** + * Migrate single media. + * + * @param string $result Result. + * @param bool $album Album. + * + * @return mixed + */ + public function migrate_single_media( $result, $album = false ) { $blog_id = get_current_blog_id(); $old = $result; if ( function_exists( 'bp_core_get_table_prefix' ) ) { @@ -635,7 +743,7 @@ function migrate_single_media( $result, $album = false ) { } $old_type = ''; - if ( 'attachment' != $result->post_type ) { + if ( 'attachment' !== $result->post_type ) { $media_type = 'album'; } else { $mime_type = strtolower( $result->post_mime_type ); @@ -659,12 +767,12 @@ function migrate_single_media( $result, $album = false ) { } $activity_data = $wpdb->get_row( $wpdb->prepare( "select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id ) ); // @codingStandardsIgnoreLine - if ( 'album' != $media_type ) { + if ( 'album' !== $media_type ) { $this->importmedia( $media_id, $prefix ); } if ( $this->table_exists( $bp_prefix . 'bp_activity' ) && class_exists( 'BP_Activity_Activity' ) ) { - $bp_activity = new BP_Activity_Activity(); + $bp_activity = new BP_Activity_Activity(); // @codingStandardsIgnoreStart $activity_sql = $wpdb->prepare( "SELECT * @@ -705,22 +813,24 @@ function migrate_single_media( $result, $album = false ) { $likes = 0; } - $wpdb->insert( $this->bmp_table, array( - 'blog_id' => $blog_id, - 'media_id' => $media_id, - 'media_type' => $media_type, - 'context' => $media_context, - 'context_id' => abs( intval( $result->context_id ) ), - 'activity_id' => $result->activity_id, - 'privacy' => intval( $result->privacy ) * 10, - 'media_author' => $result->media_author, - 'media_title' => $result->media_title, - 'album_id' => $album_id, - 'likes' => $likes, - ), array( '%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d' ) ); + $wpdb->insert( + $this->bmp_table, array( + 'blog_id' => $blog_id, + 'media_id' => $media_id, + 'media_type' => $media_type, + 'context' => $media_context, + 'context_id' => abs( intval( $result->context_id ) ), + 'activity_id' => $result->activity_id, + 'privacy' => intval( $result->privacy ) * 10, + 'media_author' => $result->media_author, + 'media_title' => $result->media_title, + 'album_id' => $album_id, + 'likes' => $likes, + ), array( '%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d' ) + ); $last_id = $wpdb->insert_id; - if ( 'album' != $media_type && function_exists( 'bp_core_get_user_domain' ) && $activity_data ) { + if ( 'album' !== $media_type && function_exists( 'bp_core_get_user_domain' ) && $activity_data ) { if ( function_exists( 'bp_core_get_table_prefix' ) ) { $bp_prefix = bp_core_get_table_prefix(); } else { @@ -740,11 +850,13 @@ function migrate_single_media( $result, $album = false ) { $activity_data->content = str_replace( $last_baseurl, $replace_img, $activity_data->content ); } global $wpdb; - $wpdb->update( $bp_prefix . 'bp_activity', array( - 'primary_link' => $activity_data->primary_link, - 'action' => $activity_data->action, - 'content' => $activity_data->content, - ), array( 'id' => $activity_data->id ) ); + $wpdb->update( + $bp_prefix . 'bp_activity', array( + 'primary_link' => $activity_data->primary_link, + 'action' => $activity_data->action, + 'content' => $activity_data->content, + ), array( 'id' => $activity_data->id ) + ); } else { if ( 'group' == $media_context ) { $activity_data->old_primary_link = $activity_data->primary_link; @@ -760,8 +872,8 @@ function migrate_single_media( $result, $album = false ) { $this->search_and_replace( $activity_data->old_primary_link, $activity_data->primary_link ); } } - if ( '' != $old_type ) { - if ( 'group' == $media_context ) { + if ( '' !== $old_type ) { + if ( 'group' === $media_context ) { $parent_link = get_rtmedia_group_link( abs( intval( $result->context_id ) ) ); $parent_link = trailingslashit( $parent_link ); $this->search_and_replace( trailingslashit( $parent_link . $old_type . '/' . $media_id ), trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id ) ); @@ -776,10 +888,12 @@ function migrate_single_media( $result, $album = false ) { } /** - * @param $id - * @param $prefix + * Import media. + * + * @param int $id Id. + * @param string $prefix Prefix. */ - function importmedia( $id, $prefix ) { + public function importmedia( $id, $prefix ) { $delete = false; $attached_file = get_attached_file( $id ); @@ -790,7 +904,7 @@ function importmedia( $id, $prefix ) { $siteurl = get_option( 'siteurl' ); $upload_path = trim( get_option( 'upload_path' ) ); - if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) { + if ( empty( $upload_path ) || 'wp-content/uploads' === $upload_path ) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { // $dir is absolute, $upload_path is (maybe) relative to ABSPATH @@ -800,7 +914,7 @@ function importmedia( $id, $prefix ) { } if ( ! $url = get_option( 'upload_url_path' ) ) { - if ( empty( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) { + if ( empty( $upload_path ) || ( 'wp-content/uploads' === $upload_path ) || ( $upload_path == $dir ) ) { $url = WP_CONTENT_URL . '/uploads'; } else { $url = trailingslashit( $siteurl ) . $upload_path; @@ -814,7 +928,7 @@ function importmedia( $id, $prefix ) { $url = trailingslashit( $siteurl ) . UPLOADS; } - // If multisite (and if not the main site in a post-MU network) + // If multisite (and if not the main site in a post-MU network). if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! rtmedia_get_site_option( 'ms_files_rewriting' ) ) { @@ -822,8 +936,7 @@ function importmedia( $id, $prefix ) { // Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory // prevents a four-digit ID from conflicting with a year-based directory for the main site. // But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra - // directory, as they never had wp-content/uploads for the main site.) - + // directory, as they never had wp-content/uploads for the main site.). if ( defined( 'MULTISITE' ) ) { $ms_dir = '/sites/' . get_current_blog_id(); } else { @@ -835,16 +948,15 @@ function importmedia( $id, $prefix ) { } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { // Handle the old-form ms-files.php rewriting if the network still has that enabled. // When ms-files rewriting is enabled, then we only listen to UPLOADS when: - // 1) we are not on the main site in a post-MU network, - // as wp-content/uploads is used there, and - // 2) we are not switched, as ms_upload_constants() hardcodes - // these constants to reflect the original blog ID. + // 1) we are not on the main site in a post-MU network, + // as wp-content/uploads is used there, and + // 2) we are not switched, as ms_upload_constants() hardcodes + // these constants to reflect the original blog ID. // // Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute. // (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as // as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files - // rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) - + // rewriting in multisite, the resulting URL is /files. (#WP22702 for background.). if ( defined( 'BLOGUPLOADDIR' ) ) { $dir = untrailingslashit( BLOGUPLOADDIR ); } else { @@ -1009,7 +1121,13 @@ function importmedia( $id, $prefix ) { } } - function search_and_replace( $old, $new ) { + /** + * Search and replace. + * + * @param string $old Old. + * @param string $new New. + */ + public function search_and_replace( $old, $new ) { global $wpdb; if ( function_exists( 'bp_core_get_table_prefix' ) ) { $bp_prefix = bp_core_get_table_prefix(); @@ -1020,7 +1138,14 @@ function search_and_replace( $old, $new ) { $wpdb->get_row( $sql );// @codingStandardsIgnoreLine } - function format_seconds( $seconds_left ) { + /** + * Format seconds. + * + * @param float $seconds_left Seconds. + * + * @return string + */ + public function format_seconds( $seconds_left ) { $minute_in_seconds = 60; $hour_in_seconds = $minute_in_seconds * 60; @@ -1039,7 +1164,7 @@ function format_seconds( $seconds_left ) { $time_components = array(); if ( $days > 0 ) { - $time_components[] = $days .esc_html__( ' day', 'buddypress-media' ) . ( $days > 1 ? 's' : '' ); + $time_components[] = $days . esc_html__( ' day', 'buddypress-media' ) . ( $days > 1 ? 's' : '' ); } if ( $hours > 0 ) { @@ -1063,7 +1188,15 @@ function format_seconds( $seconds_left ) { return $formatted_time_remaining; } - function insert_comment( $media_id, $data, $exclude, $parent_commnet_id = 0 ) { + /** + * Insert comment. + * + * @param int $media_id media id. + * @param array $data data. + * @param string $exclude Exclude. + * @param int $parent_commnet_id parent comment id. + */ + public function insert_comment( $media_id, $data, $exclude, $parent_commnet_id = 0 ) { foreach ( $data as $cmnt ) { $comment_id = 0; if ( ! key_exists( strval( $cmnt->id ), $exclude ) ) { From b8d75fcd062c3e48e13440b6fa6545276ed7610f Mon Sep 17 00:00:00 2001 From: vaishali Date: Fri, 22 Jun 2018 14:07:09 +0530 Subject: [PATCH 004/181] wp_kses added --- app/admin/RTMediaAdmin.php | 21 +++++- app/admin/RTMediaFormHandler.php | 126 +++++++++++++++++-------------- 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/app/admin/RTMediaAdmin.php b/app/admin/RTMediaAdmin.php index b35b118a9..260a8ba6e 100755 --- a/app/admin/RTMediaAdmin.php +++ b/app/admin/RTMediaAdmin.php @@ -330,7 +330,13 @@ public function rtmedia_premium_addon_notice() { $message = sprintf( __( 'Check 30+ premium rtMedia add-ons on our store.', 'buddypress-media' ), $product_page ); ?> - + array( + 'href' => array(), + ), + ) ); + ?> Dismiss

@@ -1930,13 +1936,20 @@ public function removable_query_args( $removable_query_args ) { */ public function rtm_addon_license_notice() { - if ( ! empty( $_GET['page'] ) && 'rtmedia-license' === $_GET['page'] ) { + $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ); + $args = array( + 'a' => array( + 'href' => array(), + ), + ); + + if ( ! empty( $page ) && 'rtmedia-license' === $page ) { $my_account = 'https://rtmedia.io/my-account'; $license_doc = 'https://rtmedia.io/docs/license/'; // translators: Account page and link. $message = sprintf( __( 'Your license keys can be found on my-account page. For more details, please refer to License documentation page.', 'buddypress-media' ), $my_account, $license_doc ); - echo '

' . $message . '

'; + echo '

' . wp_kses( $message, $args ) . '

'; return; } @@ -1955,7 +1968,7 @@ public function rtm_addon_license_notice() { __( 'We found an invalid or expired license key for an rtMedia add-on. Please go to the Licenses page to fix this issue.', 'buddypress-media' ), admin_url( 'admin.php?page=rtmedia-license' ) ); - echo '

' . $message . '

'; + echo '

' . wp_kses( $message, $args ) . '

'; break; } } diff --git a/app/admin/RTMediaFormHandler.php b/app/admin/RTMediaFormHandler.php index 5cdcb133f..7fcfa8dfa 100755 --- a/app/admin/RTMediaFormHandler.php +++ b/app/admin/RTMediaFormHandler.php @@ -19,7 +19,7 @@ class RTMediaFormHandler { * * @param array $args Arguments. */ - public static function selectBox( $args ) { + public static function selectBox( $args ) { // @codingStandardsIgnoreLine $defaults = array( 'key' => '', 'desc' => '', @@ -124,7 +124,12 @@ public static function checkbox( $args, $echo = true ) { $args['name'] = 'rtmedia-options[' . $key . ']'; } - $args['rtForm_options'] = array( array( '' => 1, 'checked' => $value ) ); + $args['rtForm_options'] = array( + array( + '' => 1, + 'checked' => $value, + ), + ); $chk_obj = new rtForm(); @@ -133,6 +138,7 @@ public static function checkbox( $args, $echo = true ) { } else { return $chk_obj->get_switch( $args ); } + return; } @@ -839,7 +845,7 @@ public static function types_content() { 'key' => 'allowedTypes_' . $key . '_enabled', 'value' => $section['enabled'], ); - $allow_upload_checkbox = self::checkbox( $uplaod_args, $echo = false ); + $allow_upload_checkbox = self::checkbox( $uplaod_args, false ); $allow_upload_checkbox = apply_filters( 'rtmedia_filter_allow_upload_checkbox', $allow_upload_checkbox, $key, $uplaod_args ); // allow featured. @@ -847,7 +853,7 @@ public static function types_content() { 'key' => 'allowedTypes_' . $key . '_featured', 'value' => $section['featured'], ); - $featured_checkbox = self::checkbox( $featured_args, $echo = false ); + $featured_checkbox = self::checkbox( $featured_args, false ); $featured_checkbox = apply_filters( 'rtmedia_filter_featured_checkbox', $featured_checkbox, $key ); if ( ! isset( $section['extn'] ) || ! is_array( $section['extn'] ) ) { @@ -881,7 +887,36 @@ public static function types_content() { array( + 'class' => array(), + 'data-on' => array(), + 'data-off' => array(), + ), + 'label' => array( + 'for' => array(), + 'class' => array(), + ), + 'input' => array( + 'type' => array(), + 'checked' => array(), + 'data-toggle' => array(), + 'id' => array(), + 'name' => array(), + 'value' => array(), + ), + ) + ); + ?> + + + + + array( 'class' => array(), 'data-on' => array(), @@ -899,33 +934,8 @@ public static function types_content() { 'name' => array(), 'value' => array(), ), - ) ); - ?> - - - - - array( - 'class' => array(), - 'data-on' => array(), - 'data-off' => array(), - ), - 'label' => array( - 'for' => array(), - 'class' => array(), - ), - 'input' => array( - 'type' => array(), - 'checked' => array(), - 'data-toggle' => array(), - 'id' => array(), - 'name' => array(), - 'value' => array(), - ), - ) ); + ) + ); ?> @@ -1469,7 +1479,7 @@ public static function rtForm_do_settings_fields( $page, $section ) { // @coding /** * Render each tab content * - * @param array $option Options. + * @param array $options Options. * @param array $groups Groups. * @param int $default_group Default group. */ @@ -1530,13 +1540,15 @@ public static function render_option_content( $option ) { array( - 'id' => array(), - 'href' => array(), - 'target' => array(), - ), - ) ); + echo wp_kses( + $option['title'], array( + 'a' => array( + 'id' => array(), + 'href' => array(), + 'target' => array(), + ), + ) + ); ?> @@ -1547,13 +1559,15 @@ class="rtm-field-wrap"> array( - 'id' => array(), - 'href' => array(), - 'target' => array(), - ), - ) ); + echo wp_kses( + ( isset( $option['args']['desc'] ) ) ? $option['args']['desc'] : 'NA', array( + 'a' => array( + 'id' => array(), + 'href' => array(), + 'target' => array(), + ), + ) + ); ?> @@ -1567,14 +1581,16 @@ class="rtm-field-wrap">
array( - 'id' => array(), - 'href' => array(), - 'target' => array(), - ), - 'p' => array(), - ) ); + echo wp_kses( + wpautop( $option['after_content'] ), array( + 'a' => array( + 'id' => array(), + 'href' => array(), + 'target' => array(), + ), + 'p' => array(), + ) + ); ?>
Date: Fri, 22 Jun 2018 14:34:05 +0530 Subject: [PATCH 005/181] remove extract from selectBox --- app/admin/RTMediaFormHandler.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/admin/RTMediaFormHandler.php b/app/admin/RTMediaFormHandler.php index 7fcfa8dfa..fbdf98c7b 100755 --- a/app/admin/RTMediaFormHandler.php +++ b/app/admin/RTMediaFormHandler.php @@ -28,18 +28,17 @@ public static function selectBox( $args ) { // @codingStandardsIgnoreLine 'selects' => array(), ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( ! empty( $key ) ) { - $args['name'] = 'rtmedia-options[' . $key . ']'; + if ( ! empty( $args['key'] ) ) { + $args['name'] = 'rtmedia-options[' . $args['key'] . ']'; } $args['rtForm_options'] = array(); - if ( ! empty( $selects ) ) { - foreach ( $selects as $value => $key ) { + if ( ! empty( $args['selects'] ) ) { + foreach ( $args['selects'] as $value => $key ) { $args['rtForm_options'][] = array( $key => $value, - 'selected' => ( $default === $value ) ? true : false, + 'selected' => ( $args['default'] === $value ) ? true : false, ); } } @@ -139,7 +138,7 @@ public static function checkbox( $args, $echo = true ) { return $chk_obj->get_switch( $args ); } - return; + return ''; } /** From 25e770ec38d4119ee0bca02dad26db92b8bdd39c Mon Sep 17 00:00:00 2001 From: vaishali Date: Fri, 22 Jun 2018 14:44:00 +0530 Subject: [PATCH 006/181] remove extract from textarea --- app/admin/RTMediaFormHandler.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/admin/RTMediaFormHandler.php b/app/admin/RTMediaFormHandler.php index fbdf98c7b..dfd0354b5 100755 --- a/app/admin/RTMediaFormHandler.php +++ b/app/admin/RTMediaFormHandler.php @@ -64,22 +64,21 @@ public static function textarea( $args, $echo = true ) { 'show_desc' => false, ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( ! isset( $value ) ) { + if ( ! isset( $args['value'] ) ) { trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return ''; } - if ( ! empty( $key ) ) { - $args['name'] = 'rtmedia-options[' . $key . ']'; + if ( ! empty( $args['key'] ) ) { + $args['name'] = 'rtmedia-options[' . $args['key'] . ']'; } $args['rtForm_options'] = array( array( '' => 1, - 'checked' => $value, + 'checked' => $args['value'], ), ); From 006c0c67ba95bca21a10bf3ffc1fafdd4fa0122c Mon Sep 17 00:00:00 2001 From: vaishali Date: Fri, 22 Jun 2018 14:48:00 +0530 Subject: [PATCH 007/181] remove extract from checkbox --- app/admin/RTMediaFormHandler.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/admin/RTMediaFormHandler.php b/app/admin/RTMediaFormHandler.php index dfd0354b5..64efff867 100755 --- a/app/admin/RTMediaFormHandler.php +++ b/app/admin/RTMediaFormHandler.php @@ -110,22 +110,21 @@ public static function checkbox( $args, $echo = true ) { 'show_desc' => false, ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( ! isset( $value ) ) { + if ( ! isset( $args['value'] ) ) { trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return; } - if ( ! empty( $key ) ) { - $args['name'] = 'rtmedia-options[' . $key . ']'; + if ( ! empty( $args['key'] ) ) { + $args['name'] = 'rtmedia-options[' . $args['key'] . ']'; } $args['rtForm_options'] = array( array( '' => 1, - 'checked' => $value, + 'checked' => $args['value'], ), ); From 0edd7b184a1d40d52592bc525ce2bde3a7f5c3ea Mon Sep 17 00:00:00 2001 From: vaishali Date: Fri, 22 Jun 2018 14:52:12 +0530 Subject: [PATCH 008/181] remove extract from radio --- app/admin/RTMediaFormHandler.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/admin/RTMediaFormHandler.php b/app/admin/RTMediaFormHandler.php index 64efff867..9f8554100 100755 --- a/app/admin/RTMediaFormHandler.php +++ b/app/admin/RTMediaFormHandler.php @@ -156,23 +156,22 @@ public static function radio( $args ) { 'show_desc' => false, ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( 2 > count( $radios ) ) { + if ( 2 > count( $args['radios'] ) ) { trigger_error( esc_html__( 'Need to specify atleast two radios, else use a checkbox instead', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return; } - if ( ! empty( $key ) ) { - $args['name'] = 'rtmedia-options[' . $key . ']'; + if ( ! empty( $args['key'] ) ) { + $args['name'] = 'rtmedia-options[' . $args['key'] . ']'; } $args['rtForm_options'] = array(); - foreach ( $radios as $value => $key ) { + foreach ( $args['radios'] as $value => $key ) { $args['rtForm_options'][] = array( $key => $value, - 'checked' => ( $default === $value ) ? true : false, + 'checked' => ( $args['default'] === $value ) ? true : false, ); } From 1de654979f7777aa141de64ef9690f6605d95262 Mon Sep 17 00:00:00 2001 From: vaishali Date: Fri, 22 Jun 2018 15:36:34 +0530 Subject: [PATCH 009/181] remove extract from number, textbox and link --- app/admin/RTMediaFormHandler.php | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/app/admin/RTMediaFormHandler.php b/app/admin/RTMediaFormHandler.php index 9f8554100..56f125705 100755 --- a/app/admin/RTMediaFormHandler.php +++ b/app/admin/RTMediaFormHandler.php @@ -210,20 +210,17 @@ public static function number( $args ) { 'desc' => '', ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( ! isset( $value ) ) { + if ( ! isset( $args['value'] ) ) { trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return; } - if ( ! empty( $key ) ) { - $args['name'] = 'rtmedia-options[' . $key . ']'; + if ( ! empty( $args['key'] ) ) { + $args['name'] = 'rtmedia-options[' . $args['key'] . ']'; } - $args['value'] = $value; - $num_obj = new rtForm(); $num_obj->display_number( $args ); } @@ -245,20 +242,17 @@ public static function textbox( $args ) { 'desc' => '', ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( ! isset( $value ) ) { + if ( ! isset( $args['value'] ) ) { trigger_error( esc_html__( 'Please provide a "value" in the argument.', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return; } - if ( ! empty( $key ) ) { - $args['name'] = 'rtmedia-options[' . $key . ']'; + if ( ! empty( $args['key'] ) ) { + $args['name'] = 'rtmedia-options[' . $args['key'] . ']'; } - $args['value'] = $value; - $num_obj = new rtForm(); $num_obj->display_textbox( $args ); } @@ -282,22 +276,21 @@ public static function link( $args, $echo = true ) { 'desc' => '', ); $args = wp_parse_args( $args, $defaults ); - extract( $args ); - if ( ! isset( $href ) ) { + if ( ! isset( $args['href'] ) ) { trigger_error( esc_html__( 'Please provide a "href" in the argument.', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return ''; } - if ( ! isset( $text ) ) { + if ( ! isset( $args['text'] ) ) { trigger_error( esc_html__( 'Please provide a "text" in the argument.', 'buddypress-media' ) ); // @codingStandardsIgnoreLine return ''; } - if ( isset( $target ) && ! empty( $target ) ) { - $args['misc'] = array( 'target' => $target ); + if ( isset( $args['target'] ) && ! empty( $args['target'] ) ) { + $args['misc'] = array( 'target' => $args['target'] ); } $link_obj = new rtForm(); From b8a45fc5569e3dbe72b40003e40550918d36f42a Mon Sep 17 00:00:00 2001 From: vaishali Date: Fri, 22 Jun 2018 19:41:52 +0530 Subject: [PATCH 010/181] phpcs fixes in main/contexts and main/controllers/activity folder --- app/main/contexts/RTMediaContext.php | 41 +- .../controllers/activity/RTMediaActivity.php | 83 ++- .../activity/RTMediaBuddyPressActivity.php | 541 ++++++++++-------- 3 files changed, 399 insertions(+), 266 deletions(-) diff --git a/app/main/contexts/RTMediaContext.php b/app/main/contexts/RTMediaContext.php index 337ef8c91..2f8d7c8e7 100755 --- a/app/main/contexts/RTMediaContext.php +++ b/app/main/contexts/RTMediaContext.php @@ -1,8 +1,9 @@ set_context(); return $this; @@ -38,7 +46,7 @@ function __construct() { /** * Set current request context */ - function set_context() { + public function set_context() { if ( class_exists( 'BuddyPress' ) ) { $this->set_bp_context(); } else { @@ -48,9 +56,10 @@ function set_context() { /** * Set WordPress context - * @global type $post + * + * @global object $post */ - function set_wp_context() { + public function set_wp_context() { global $post; global $bp; if ( is_author() ) { @@ -61,7 +70,8 @@ function set_wp_context() { $this->id = $post->ID; } else { $wp_default_context = array( 'page', 'post' ); - if ( isset( $_REQUEST['context'] ) && in_array( $_REQUEST['context'], $wp_default_context ) ) { + + if ( isset( $_REQUEST['context'] ) && in_array( $_REQUEST['context'], $wp_default_context ) ) { $this->type = $_REQUEST['context']; $this->id = $_REQUEST['context_id']; } else { @@ -76,7 +86,7 @@ function set_wp_context() { /** * Set BuddyPress context */ - function set_bp_context() { + public function set_bp_context() { if ( bp_is_blog_page() && ! is_home() ) { $this->set_wp_context(); } else { @@ -87,7 +97,7 @@ function set_bp_context() { /** * Set BuddyPress component context */ - function set_bp_component_context() { + public function set_bp_component_context() { if ( bp_displayed_user_id() && ! bp_is_group() ) { $this->type = 'profile'; } else { @@ -106,9 +116,10 @@ function set_bp_component_context() { /** * Get current bp component id + * * @return int/null */ - function get_current_bp_component_id() { + public function get_current_bp_component_id() { switch ( bp_current_component() ) { case 'groups': if ( function_exists( 'bp_get_current_group_id' ) ) { @@ -116,10 +127,8 @@ function get_current_bp_component_id() { } return null; - break; default: return bp_displayed_user_id(); - break; } } } diff --git a/app/main/controllers/activity/RTMediaActivity.php b/app/main/controllers/activity/RTMediaActivity.php index bd9b89fe9..dbd88c07c 100755 --- a/app/main/controllers/activity/RTMediaActivity.php +++ b/app/main/controllers/activity/RTMediaActivity.php @@ -1,8 +1,9 @@ privacy = $privacy; } - function create_activity_html( $type = 'activity' ) { + /** + * Create activity html. + * + * @param string $type Type. + * + * @return mixed + */ + public function create_activity_html( $type = 'activity' ) { $html = ''; - $html .= '
'; + $html .= '
'; if ( ! empty( $this->activity_text ) ) { - $html .= '
'; + $html .= '
'; $html .= $this->activity_text; $html .= '
'; } @@ -53,13 +80,13 @@ function create_activity_html( $type = 'activity' ) { $limit_activity_feed = 0; } - $mediaObj = new RTMediaModel(); - $media_details = $mediaObj->get( array( 'id' => $this->media ) ); + $media_obj = new RTMediaModel(); + $media_details = $media_obj->get( array( 'id' => $this->media ) ); if ( intval( $limit_activity_feed ) > 0 ) { $media_details = array_slice( $media_details, 0, $limit_activity_feed, true ); } - $rtmedia_activity_ul_class = apply_filters( 'rtmedia_'.$type.'_ul_class', 'rtm-activity-media-list' ); + $rtmedia_activity_ul_class = apply_filters( 'rtmedia_' . $type . '_ul_class', 'rtm-activity-media-list' ); $li_content = ''; $count = 0; foreach ( $media_details as $media ) { @@ -93,10 +120,10 @@ function create_activity_html( $type = 'activity' ) { $count ++; } - if( 'activity' == $type ){ + if ( 'activity' == $type ) { $html .= '