PluginProbe
WP Docs / 2.3.4
WP Docs v2.3.4
2.3.4 2.3.3 2.3.2 trunk 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1
← All changes | inc/functions.php +691 -219 2.2.82.3.4 View file →
@@ -1,6 +1,18 @@
1 1 <?php
2 -
2 + if(!function_exists('wpdocs_secure_url')){
3 + function wpdocs_secure_url($file_id=''){
4 +
5 + $ret = add_query_arg(
6 + array(
7 + 'wpdocs_dl' => $file_id,
8 + 'wpdocs_nonce' => wp_create_nonce('wpdocs_dl_'.$file_id),
9 + ),
10 + home_url('/')
11 + );
12 + return $ret;
13 + }
14 + }
3 15 if(!function_exists('wp_docs_get_memphis_dir_option_id')){
4 16 function wp_docs_get_option_id($option_name){
5 17 global $wpdb;
6 18 $option_name = esc_sql( $option_name );
@@ -44,8 +56,10 @@
44 56 function wpdocs_admin_enqueue_script()
45 57 {
46 58 if (isset($_GET['page']) && $_GET['page'] == 'wpdocs') {
47 59
60 + //pree(get_option('mdocs-list'));exit;
61 +
48 62 global $wpdocs_pro, $wpdocs_options;
49 63
50 64 wp_enqueue_script('wpdocs_boostrap', plugin_dir_url(dirname(__FILE__)) . 'js/bootstrap.min.js', array('jquery'));
51 65 wp_enqueue_style('wpdocs-boostrap', plugins_url('css/bootstrap.min.css', dirname(__FILE__)));
@@ -65,8 +79,9 @@
65 79 wp_enqueue_style('wpdocs-common', plugins_url('css/common-styles.css', dirname(__FILE__)), array(), date('Ymdhi'));
66 80 wp_enqueue_style('wpdocs-admin', plugins_url('css/admin-styles.css', dirname(__FILE__)), array(), date('Ymdhi'));
67 81
68 82 wp_enqueue_script('wpdocs_admin_scripts', plugin_dir_url(dirname(__FILE__)) . 'js/admin-scripts.js', array('jquery', 'jquery-ui-dialog'), time());
83 + wp_enqueue_script('wpdocs_verify_scripts', plugin_dir_url(dirname(__FILE__)) . 'js/verify-scripts.js', array('jquery', 'jquery-ui-dialog'), time());
69 84
70 85 if($wpdocs_pro){
71 86 wp_enqueue_script('wpdocs_pro_scripts', plugin_dir_url(dirname(__FILE__)) . 'pro/wp-docs-admin.js?t='.time(), array('jquery'));
72 87 }
@@ -83,8 +98,9 @@
83 98 'wpdocs_admin_scripts',
84 99 'wpdocs_ajax_object',
85 100 array(
86 101 'ajax_url' => admin_url('admin-ajax.php'),
102 + 'nonce' => wp_create_nonce('wpdocs_update_options_nonce'),
87 103 'url' => admin_url('options-general.php?page=wpdocs'),
88 104 'wpdocs_pro' => $wpdocs_pro,
89 105 'wpdocs_delete_msg' => __('Do you want to delete this directory and data as well?', 'wp-docs'),
90 106 'wpdocs_delete_shortcut_msg' => __('Do you want to delete this shortcut?', 'wp-docs'),
@@ -100,9 +116,9 @@
100 116 'undo_import_confirm' => __('Do you want to rollback the import?', 'wp-docs'),
101 117 'select_role_str' => __('Select roles to allow upload', 'wp-docs'),
102 118 'rename_confirm' => __('Do you want to rename this directory?', 'wp-docs'),
103 119 'reset_confirm' => __('Do you want to reset all settings and clear directories?', 'wp-docs'),
104 - 'nonce' => wp_create_nonce('wpdocs_update_options_nonce'),
120 +
105 121 'empty_settings' => empty($wpdocs_options),
106 122 'wc_os_pg' => (isset($_GET['pg'])?esc_attr($_GET['pg']):'0'),
107 123 'wc_os_tab' => (isset($_GET['t'])?esc_attr($_GET['t']):'0'),
108 124 'all_dirs' => $dir_id_to_titles,
@@ -109,8 +125,55 @@
109 125 'rename_confirm' => __('Please enter new folder name:', 'wp-docs'),
110 126
111 127 )
112 128 );
129 +
130 + wp_localize_script(
131 + 'wpdocs_verify_scripts',
132 + 'wpdocs_vars',
133 + array(
134 + 'ajax_url' => admin_url('admin-ajax.php'),
135 + 'url' => admin_url('options-general.php?page=wpdocs'),
136 + 'nonce' => wp_create_nonce('wpdocs_verify_nonce'),
137 + 'preparing_queue' => __('Preparing verification queue...', 'wp-docs'),
138 + 'unable_to_start' => __('Unable to start verification.', 'wp-docs'),
139 + 'ajax_error' => __('AJAX error.', 'wp-docs'),
140 + 'verification_failed' => __('Verification failed.', 'wp-docs'),
141 + 'verification_completed' => __('Verification completed.', 'wp-docs'),
142 + 'verification_interrupted' => __('Verification interrupted.', 'wp-docs'),
143 + 'checking_folder' => __('Checking Folder:', 'wp-docs'),
144 + 'checking_file' => __('Checking File:', 'wp-docs'),
145 + 'unknown_file' => __('Unknown File', 'wp-docs'),
146 + 'items_processed' => __('items processed', 'wp-docs'),
147 + 'total_folders' => __('Total Folders', 'wp-docs'),
148 + 'verified_folders' => __('Verified Folders', 'wp-docs'),
149 + 'missing_folders' => __('Missing Folders', 'wp-docs'),
150 + 'total_files' => __('Total Files', 'wp-docs'),
151 + 'verified_files' => __('Verified Files', 'wp-docs'),
152 + 'missing_files' => __('Missing Files', 'wp-docs'),
153 + 'missing_folder' => __('MISSING FOLDER', 'wp-docs'),
154 + 'missing_file' => __('MISSING FILE', 'wp-docs'),
155 + 'no_items_display' => __('No items to display.', 'wp-docs'),
156 + 'import_in_progress' => __('Import is already in progress. Please wait.', 'wp-docs'),
157 + 'import_missing_confirm' => __('This will import only missing folders and files. Do you want to continue?', 'wp-docs'),
158 + 'initializing' => __('Initializing...', 'wp-docs'),
159 + 'preparing_import_queue' => __('Preparing import queue...', 'wp-docs'),
160 + 'unable_to_start_import' => __('Unable to start import.', 'wp-docs'),
161 + 'import_failed' => __('Import failed.', 'wp-docs'),
162 + 'import_completed' => __('Import completed!', 'wp-docs'),
163 + 'refreshing_results' => __('Refreshing verification results...', 'wp-docs'),
164 + 'import_interrupted' => __('Import interrupted. Please try again.', 'wp-docs'),
165 + 'creating_folder' => __('Creating Folder:', 'wp-docs'),
166 + 'importing_file' => __('Importing File:', 'wp-docs'),
167 + 'path' => __('Path:', 'wp-docs'),
168 + 'target' => __('Target:', 'wp-docs'),
169 + 'folders_imported' => __('Folders imported:', 'wp-docs'),
170 + 'files_imported' => __('Files imported:', 'wp-docs'),
171 + 'failed' => __('Failed:', 'wp-docs'),
172 + 'please_wait' => __('Please wait...', 'wp-docs'),
173 + 'import_missing_items' => __('Import Missing Items Only', 'wp-docs'),
174 + )
175 + );
113 176 }
114 177 }
115 178
116 179 add_filter( 'ajax_query_attachments_args', 'wpdocs_filter_media');
@@ -420,8 +483,10 @@
420 483 $dir_id = (!$dir_id && array_key_exists('dir', $_GET)?sanitize_wpdocs_data($_GET['dir']):0);
421 484
422 485 $params_array = array(
423 486 'dir_id' => $dir_id,
487 +
488 + 'nonce' => wp_create_nonce('wpdocs_update_options_nonce'),
424 489 'parent_dir' => get_permalink($post->ID).'/?dir=',
425 490 'wpdocs_pro' => $wpdocs_pro,
426 491 'details_view_sorting' => $details_view_sorting,
427 492 'ajax_based_deep_search' => $ajax_based_deep_search,
@@ -437,9 +502,8 @@
437 502 'block_ui' => __('Please wait...', 'wp-docs'),
438 503 'is_ajax' => $is_ajax,
439 504 'is_ajax_url' => $is_ajax_url,
440 505 'del_from_front' => array_key_exists('del_from_front', $wpdocs_options),
441 - 'nonce' => wp_create_nonce('wpdocs_update_options_nonce'),
442 506 'restriction_load' => isset($_GET['wpdocs_restriction']),
443 507 'restriction_id' => isset($_GET['wpdocs_restriction']) ? $_GET['wpdocs_restriction'] : '',
444 508 'restriction_container' => isset($_GET['wpdocs_container']) ? $_GET['wpdocs_container'] : '',
445 509 'current_user_id' => get_current_user_id(),
@@ -602,10 +666,30 @@
602 666 //pree($ret);
603 667
604 668 return $ret;
605 669 }
670 + function wpdocs_create_folder_post( $post_parent, $post_title = "New Folder" ) {
671 +
672 + if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
673 + return 0;
674 + }
606 675
607 - function wpdocs_create_folder_post($post_parent, $post_title = "New Folder")
676 + $post_parent = absint( $post_parent );
677 + $post_title = sanitize_text_field( $post_title );
678 +
679 + $my_post = array(
680 + 'post_title' => $post_title,
681 + 'post_content' => '',
682 + 'post_status' => 'hidden',
683 + 'post_author' => get_current_user_id(),
684 + 'post_type' => 'wpdocs_folder',
685 + 'post_parent' => ( ( $post_parent > 0 && wpdocs_folder_exists( $post_parent ) ) ? $post_parent : 0 ),
686 + 'post_category' => array(),
687 + );
688 +
689 + return wp_insert_post( $my_post );
690 + }
691 + /*function wpdocs_create_folder_post($post_parent, $post_title = "New Folder")
608 692 {
609 693
610 694 $my_post = array(
611 695 'post_title' => $post_title,
@@ -619,14 +703,19 @@
619 703
620 704 $dir_id = wp_insert_post($my_post);
621 705
622 706 return $dir_id;
623 - }
707 + }*/
624 708
625 709 add_action('wp_ajax_wpdocs_create_folder', 'wpdocs_create_folder');
626 710
627 711 function wpdocs_create_folder()
628 712 {
713 + if ( ! current_user_can( 'manage_options' ) ) {
714 + wp_send_json_error( __("Unauthorized user", 'wp-docs') );
715 + wp_die();
716 + }
717 +
629 718 $nonce = sanitize_wpdocs_data(wp_unslash($_POST['nonce']));
630 719
631 720 if (!empty($_POST) && isset($_POST['nonce']) && ! wp_verify_nonce( $nonce, 'wpdocs_update_options_nonce' ) )
632 721 die (__("Sorry, your nonce did not verify.", 'wp-docs'));
@@ -640,9 +729,29 @@
640 729 $list = array('id'=>$list_obj->ID, 'content'=>$list_obj->post_content, 'title'=>$list_obj->post_title, 'type'=>$list_obj->post_type, 'guid'=>$list_obj->guid);
641 730
642 731 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
643 732
644 - echo '<li class="ab-dir ab-new" data-id="'.$dir_id.'" data-resource='.base64_encode($dir_id).'" data-linked="'.$list['content'].'" data-guid="'.($is_shortcut?$list['guid']:'').'"><a class="folder fa fa-folder"></a><a class="dtitle" title="'.__('Click here to rename', 'wp-docs').'">'.__('New Folder', 'wp-docs').'</a><span class="wpd_action_span"><a class="wpd-edit" title="'.__('Click here to edit', 'wp-docs').'"></a><span class="wpd_action_span_inner"><a class="wpd-copy" title="'.__('Click here to copy', 'wp-docs').'"></a><a class="wpd-move" title="'.__('Click here to move', 'wp-docs').'"></a></span><a class="wpd-trash" title="'.__('Click here to delete', 'wp-docs').'"></a></span></li>';
733 + echo '<li class="ab-dir ab-new"
734 + data-id="' . esc_attr($dir_id) . '"
735 + data-resource="' . esc_attr(base64_encode($dir_id)) . '"
736 + data-linked="' . esc_attr($list['content']) . '"
737 + data-guid="' . ($is_shortcut ? esc_attr($list['guid']) : '') . '">
738 +
739 + <a class="folder fa fa-folder"></a>
740 +
741 + <a class="dtitle" title="' . esc_attr(__('Click here to rename', 'wp-docs')) . '">
742 + ' . esc_html__('New Folder', 'wp-docs') . '
743 + </a>
744 +
745 + <span class="wpd_action_span">
746 + <a class="wpd-edit" title="' . esc_attr(__('Click here to edit', 'wp-docs')) . '"></a>
747 + <span class="wpd_action_span_inner">
748 + <a class="wpd-copy" title="' . esc_attr(__('Click here to copy', 'wp-docs')) . '"></a>
749 + <a class="wpd-move" title="' . esc_attr(__('Click here to move', 'wp-docs')) . '"></a>
750 + </span>
751 + <a class="wpd-trash" title="' . esc_attr(__('Click here to delete', 'wp-docs')) . '"></a>
752 + </span>
753 + </li>';
645 754
646 755 exit;
647 756 }
648 757
@@ -719,25 +828,81 @@
719 828 }
720 829
721 830
722 831
832 + return array(
833 + 'file_id' => $item,
834 + 'file_url' => esc_url($file_url),
835 + 'ext' => esc_attr($ext),
836 + 'filename' => esc_attr($filename),
837 + 'title' => esc_html($filename),
838 + 'icon_url' => esc_url($icon_url)
839 + );
723 840
724 - return array(
725 841
726 - 'file_url' => $file_url,
727 - 'ext' => $ext,
728 - 'filename' => $filename,
729 - 'title' => $filename,
730 - 'icon_url' => $icon_url
731 - );
842 + }
843 + }
732 844
845 + /**
846 + * Centralize the "can this user edit this folder?" decision.
847 + * Admins always pass; otherwise require the folder to be owned by the user.
848 + */
849 + function wpdocs_user_can_edit_folder( $dir_id ) {
850 + if ( current_user_can( 'manage_options' ) ) {
851 + return true;
852 + }
733 853
854 + $dir = get_post( $dir_id );
855 + if ( ! $dir || 'wpdocs_folder' !== $dir->post_type ) { // adjust CPT slug
856 + return false;
734 857 }
858 +
859 + return (int) $dir->post_author === get_current_user_id();
735 860 }
736 861
737 862 add_action('wp_ajax_wpdocs_add_files', 'wpdocs_add_files');
738 863
739 - function wpdocs_add_files(){
864 + function wpdocs_add_files() {
865 +
866 + // 1) Capability FIRST — before nonce, before anything.
867 + if ( ! is_user_logged_in() || ! current_user_can( 'upload_files' ) ) {
868 + wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'wp-docs' ) ), 403 );
869 + }
870 +
871 + // 2) Nonce check.
872 + if ( empty( $_POST['nonce'] )
873 + || ! wp_verify_nonce(
874 + sanitize_wpdocs_data( wp_unslash( $_POST['nonce'] ) ),
875 + 'wpdocs_update_options_nonce'
876 + )
877 + ) {
878 + wp_send_json_error( array( 'message' => __( 'Sorry, your nonce did not verify.', 'wp-docs' ) ), 403 );
879 + }
880 +
881 + // 3) Input validation.
882 + $dir_id = isset( $_POST['dir_id'] ) ? absint( $_POST['dir_id'] ) : 0;
883 + if ( ! $dir_id ) {
884 + wp_send_json_error( array( 'message' => __( 'Invalid folder.', 'wp-docs' ) ), 400 );
885 + }
886 +
887 + // 4) Per-folder ownership / capability gate.
888 + if ( ! wpdocs_user_can_edit_folder( $dir_id ) ) {
889 + wp_send_json_error( array( 'message' => __( 'You cannot modify this folder.', 'wp-docs' ) ), 403 );
890 + }
891 +
892 + $files = isset( $_POST['files'] ) ? sanitize_wpdocs_data( $_POST['files'] ) : array();
893 + $files = is_array( $files ) ? $files : array( $files );
894 + $files = array_filter( array_map( 'absint', $files ) );
895 +
896 + wpdocs_update_files_meta( $dir_id, $files );
897 +
898 + $ret = ! empty( $files ) ? wpdocs_list_added_items( $dir_id ) : '';
899 +
900 + echo $ret;
901 + exit;
902 + }
903 +
904 + /*function wpdocs_add_files_old(){
740 905
741 906 $nonce = sanitize_wpdocs_data(wp_unslash($_POST['nonce']));
742 907
743 908 if (!empty($_POST) && isset($_POST['nonce']) && ! wp_verify_nonce( $nonce, 'wpdocs_update_options_nonce' ) )
@@ -763,9 +928,9 @@
763 928 }
764 929
765 930 echo $ret;
766 931 exit;
767 - }
932 + }*/
768 933 function wpdocs_list_added_items($dir)
769 934 {
770 935
771 936 global $wpdocs_options, $icon_sub_path, $wpdocs_url;
@@ -788,12 +953,12 @@
788 953
789 954 $item_data = wpd_get_item_type_icon_url($item);
790 955 extract($item_data);
791 956
792 - //pree($item_data);
957 + //pree($item_data);exit;
793 958 //pree($wp_uploads_path);exit;
794 959
795 - $icon_str = '<img src="'.$icon_url.'" style="">';
960 + $icon_str = '<img src="' . esc_url($icon_url) . '" style="" alt="' . esc_attr($title) . '">';
796 961
797 962 switch ($ext) {
798 963 case 'png':
799 964 case 'jpg':
@@ -839,9 +1004,9 @@
839 1004
840 1005
841 1006 }
842 1007
843 - $icon_str = '<img src="'.$file_url_thumb.'" style="">';
1008 + $icon_str = '<img src="' . esc_url( $file_url_thumb ) . '" style="" alt="' . esc_attr( $title ) . '">';
844 1009
845 1010 }
846 1011
847 1012 }
@@ -852,21 +1017,24 @@
852 1017 //$class .= 'fa-file';
853 1018 break;
854 1019 }
855 1020 $class = '';
856 - $files_list[$title] = '<li data-id="' . $item . '" data-dir="'.$dir. '" title="'.esc_attr($filename).'">
857 - <a href="' . $file_url . '" target="_blank" class="file ' . $class . '"> '.$icon_str.' </a>
858 - <a class="ftitle" title="' . $title . '">' . $title . '</a>
859 - <span class="wpd_action_span">
860 - <a href="upload.php?item='.$item.'" target="_blank" class="wpd-edit" title="'.__('Click here to edit', 'wp-docs').'"></a>
861 - <span class="wpd_action_span_inner">
862 - <a class="wpd-copy" title="'.__('Click here to copy', 'wp-docs').'"></a>
863 - <a class="wpd-move" title="'.__('Click here to move', 'wp-docs').'"></a>
864 - </span>
865 -
866 - <a href="upload.php?search='.esc_attr($filename).'" target="_blank" class="wpd-trash" title="'.__('Click here to delete', 'wp-docs').'"></a>
867 - </span>
868 - </li>';
1021 +
1022 +
1023 + $secured_file_url = wpdocs_secure_url($file_id);
1024 +
1025 + $files_list[ $title ] = '<li data-id="' . esc_attr( $item ) . '" data-dir="' . esc_attr( $dir ) . '" title="' . esc_attr( $filename ) . '">
1026 + <a href="' . esc_url( $secured_file_url ) . '" target="_blank" class="file ' . esc_attr( $class ) . '"> ' . $icon_str . ' </a>
1027 + <a class="ftitle" title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '</a>
1028 + <span class="wpd_action_span">
1029 + <a href="' . esc_url( 'upload.php?item=' . $item ) . '" target="_blank" class="wpd-edit" title="' . esc_attr__( 'Click here to edit', 'wp-docs' ) . '"></a>
1030 + <span class="wpd_action_span_inner">
1031 + <a class="wpd-copy" title="' . esc_attr__( 'Click here to copy', 'wp-docs' ) . '"></a>
1032 + <a class="wpd-move" title="' . esc_attr__( 'Click here to move', 'wp-docs' ) . '"></a>
1033 + </span>
1034 + <a href="' . esc_url( 'upload.php?search=' . rawurlencode( $filename ) ) . '" target="_blank" class="wpd-trash" title="' . esc_attr__( 'Click here to delete', 'wp-docs' ) . '"></a>
1035 + </span>
1036 +</li>';
869 1037 }
870 1038 }
871 1039
872 1040 ksort($files_list);
@@ -1135,12 +1303,19 @@
1135 1303
1136 1304 ?>
1137 1305
1138 1306
1139 - <div class="container-fluid wpdoc_container" data-dir_restrictions = "<?php echo wpdocs_get_dir_restrictions($dir, 'base64'); ?>" data-del_from_front="<?php echo $is_del_from_front; ?>" data-dir="<?php echo $dir; ?>" data-home="<?php echo $home_id; ?>">
1140 - <?php wp_nonce_field( 'wpdocs_front_list_nonce', 'wpdocs_front_list_nonce_field' ); ?>
1141 - <input type="hidden" class="wpd_home_id" value="<?php echo esc_html($home_id); ?>" />
1142 - <input type="hidden" class="wpd_del_file_id" value="" />
1307 +<div class="container-fluid wpdoc_container"
1308 + data-dir_restrictions="<?php echo esc_attr( wpdocs_get_dir_restrictions( $dir, 'base64' ) ); ?>"
1309 + data-del_from_front="<?php echo esc_attr( $is_del_from_front ); ?>"
1310 + data-dir="<?php echo esc_attr( $dir ); ?>"
1311 + data-home="<?php echo esc_attr( $home_id ); ?>">
1312 +
1313 + <?php wp_nonce_field( 'wpdocs_front_list_nonce', 'wpdocs_front_list_nonce_field' ); ?>
1314 +
1315 + <input type="hidden" class="wpd_home_id" value="<?php echo esc_attr( $home_id ); ?>" />
1316 + <input type="hidden" class="wpd_del_file_id" value="" />
1317 +
1143 1318 <?php
1144 1319
1145 1320 $wpdocs_view = array_key_exists($home_id, $wpdocs_view) ? $wpdocs_view[$home_id] : trim($default_view);
1146 1321
@@ -1152,9 +1327,13 @@
1152 1327 <ol class="breadcrumb bg-light" style="border-bottom:1px solid #dee2e6;border-radius: 0; min-height: 40px;">
1153 1328
1154 1329 <?php if (!empty($breadcrumb_array)) { ?>
1155 1330
1156 - <li class="breadcrumb-item bread_home_url"><a class="wpd_bread_item" href="<?php echo $get_permalink ?>" data-id="0"><?php _e('Home', 'wp-docs'); ?></a></li>
1331 + <li class="breadcrumb-item bread_home_url">
1332 + <a class="wpd_bread_item" href="<?php echo esc_url($get_permalink); ?>" data-id="0">
1333 + <?php echo esc_html__('Home', 'wp-docs'); ?>
1334 + </a>
1335 +</li>
1157 1336 <?php
1158 1337
1159 1338 foreach (array_reverse($breadcrumb_array) as $bread_key => $bread_value) {
1160 1339 $active = '';
@@ -1160,9 +1339,9 @@
1160 1339 $active = '';
1161 1340 $page = '';
1162 1341 $permalink = stripos($get_permalink, '?');
1163 1342 $permalink_c = ($permalink!='' && is_numeric($permalink) && $permalink>=0);
1164 - $link = '<a class="wpd_bread_item" href="' . $get_permalink . ($permalink_c?'&':'?').'dir=' . $bread_value . '" data-id="'.$bread_value.'" >' . get_the_title($bread_value) . '</a>';
1343 + $link = '<a class="wpd_bread_item" href="' . esc_url($get_permalink . ($permalink_c ? '&' : '?') . 'dir=' . $bread_value) . '" data-id="' . esc_attr($bread_value) . '">' . (get_the_title($bread_value)) . '</a>';
1165 1344 if ($bread_value == 0) {
1166 1345 continue;
1167 1346 }
1168 1347 if ($bread_value == $dir) {
@@ -1172,9 +1351,11 @@
1172 1351 }
1173 1352
1174 1353
1175 1354 ?>
1176 - <li class="breadcrumb-item <?php echo $active ?>" aria-current="<?php echo $page; ?>"><?php echo $link; ?></li>
1355 + <li class="breadcrumb-item <?php echo esc_attr($active); ?>" aria-current="<?php echo esc_attr($page); ?>">
1356 + <?php echo wp_kses_post($link); ?>
1357 +</li>
1177 1358
1178 1359 <?php } ?>
1179 1360 <?php
1180 1361 }
@@ -1183,16 +1364,21 @@
1183 1364
1184 1365 </ol>
1185 1366
1186 1367 <?php if($is_del_from_front):?>
1368 +<i style="opacity: 0.5;"
1369 + class="fa fa-trash fa-1x position-absolute wp_docs_del_file <?php echo esc_attr(is_user_logged_in() ? 'logged_in' : 'logged_out'); ?>"
1370 + title="<?php echo esc_attr__('Click here to delete selected files', 'wp-docs'); ?>">
1371 +</i>
1187 1372
1188 - <i style="opacity: 0.5;" class="fa fa-trash fa-1x position-absolute wp_docs_del_file <?php echo (is_user_logged_in()?'logged_in':'logged_out'); ?>" title="<?php _e('Click here to delete selected files', 'wp-docs'); ?>"></i>
1189 -
1190 1373 <?php endif; ?>
1191 1374
1192 1375 <?php if($wpdocs_pro && $dir != 0 && wpdocs_can_current_user_upload_file($dir) && $is_file):?>
1193 1376
1194 - <i class="fa fa-upload fa-1x wpdocs-front-add-media position-absolute" id="wpdocs_front_file_add_<?php echo $dir; ?>" title="<?php _e('Click here to add files', 'wp-docs'); ?>"></i>
1377 +<i class="fa fa-upload fa-1x wpdocs-front-add-media position-absolute"
1378 + id="wpdocs_front_file_add_<?php echo esc_attr( $dir ); ?>"
1379 + title="<?php echo esc_attr__( 'Click here to add files', 'wp-docs' ); ?>">
1380 +</i>
1195 1381
1196 1382 <?php endif; ?>
1197 1383 </nav>
1198 1384 <?php
@@ -1225,10 +1411,9 @@
1225 1411 pree($posts_array);
1226 1412 */
1227 1413 ?>
1228 1414
1229 - <?php echo $warning_msg?'<div class="card-body">'.$warning_msg.'</div>':''; ?>
1230 -
1415 + <?php echo $warning_msg ? '<div class="card-body">' . wp_kses_post( $warning_msg ) . '</div>' : ''; ?>
1231 1416 <?php if($is_searchbox || $ajax_based_deep_search): ?>
1232 1417 <div class="wpdocs-searchbox">
1233 1418 <input type="text" placeholder="<?php echo ($ajax_based_deep_search?__('Type here to search...', 'wp-docs'):__('Type here to filter...', 'wp-docs')); ?>" />
1234 1419 </div>
@@ -1250,14 +1435,22 @@
1250 1435 //$wpdocs_child_files_list = wpdocs_added_items($list['id']);
1251 1436 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
1252 1437 ?>
1253 1438
1254 - <div class="col-4 col-md-3 file_wrapper is_dir" style="cursor: pointer;" data-id="<?php echo $list['id']; ?>" data-resource="<?php echo base64_encode($list['id']); ?>" data-linked="<?php echo $list['content']; ?>" data-guid="<?php echo $is_shortcut?$list['link']:''; ?>">
1255 - <figure class="figure file_view p-0">
1256 - <span class="fa fa-folder text-warning" style="<?php echo $customize_icon_size; ?>"></span>
1257 - <figcaption class="figure-caption text-center" style="<?php echo $customize_font_size; ?>"><?php echo $list['title']; ?></figcaption>
1258 - </figure>
1259 - </div>
1439 +<div class="col-4 col-md-3 file_wrapper is_dir" style="cursor: pointer;"
1440 + data-id="<?php echo esc_attr($list['id']); ?>"
1441 + data-resource="<?php echo esc_attr(base64_encode($list['id'])); ?>"
1442 + data-linked="<?php echo esc_attr($list['content']); ?>"
1443 + data-guid="<?php echo esc_attr($is_shortcut ? $list['link'] : ''); ?>">
1444 +
1445 + <figure class="figure file_view p-0">
1446 + <span class="fa fa-folder text-warning" style="<?php echo esc_attr($customize_icon_size); ?>"></span>
1447 + <figcaption class="figure-caption text-center" style="<?php echo esc_attr($customize_font_size); ?>">
1448 + <?php echo esc_html($list['title']); ?>
1449 + </figcaption>
1450 + </figure>
1451 +
1452 +</div>
1260 1453 <?php
1261 1454 }
1262 1455 } else {
1263 1456 $no_dir_found = true;
@@ -1274,14 +1467,23 @@
1274 1467 $list = array('id'=>$list_obj->ID, 'content'=>$list_obj->post_content, 'title'=>$list_obj->post_title, 'type'=>$list_obj->post_type, 'guid'=>$list_obj->guid);
1275 1468 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
1276 1469
1277 1470 ?>
1278 - <div class="col-4 col-md-3 file_wrapper is_dir is_deep" style="cursor: pointer;" data-id="<?php echo $list['id']; ?>" data-resource="<?php echo base64_encode($list['id']); ?>" data-linked="<?php echo $list['content']; ?>" data-guid="<?php echo $is_shortcut?$list['guid']:''; ?>">
1279 - <figure class="figure file_view p-0">
1280 - <span class="fa fa-folder text-warning" style="<?php echo $customize_icon_size; ?>"></span>
1281 - <figcaption class="figure-caption text-center" style="<?php echo $customize_font_size; ?>"><?php echo $list['title']; ?></figcaption>
1282 - </figure>
1283 - </div>
1471 +<div class="col-4 col-md-3 file_wrapper is_dir is_deep" style="cursor: pointer;"
1472 + data-id="<?php echo esc_attr($list['id']); ?>"
1473 + data-resource="<?php echo esc_attr(base64_encode($list['id'])); ?>"
1474 + data-linked="<?php echo esc_attr($list['content']); ?>"
1475 + data-guid="<?php echo esc_attr($is_shortcut ? $list['guid'] : ''); ?>">
1476 +
1477 + <figure class="figure file_view p-0">
1478 + <span class="fa fa-folder text-warning" style="<?php echo esc_attr($customize_icon_size); ?>"></span>
1479 +
1480 + <figcaption class="figure-caption text-center" style="<?php echo esc_attr($customize_font_size); ?>">
1481 + <?php echo esc_html($list['title']); ?>
1482 + </figcaption>
1483 + </figure>
1484 +
1485 +</div>
1284 1486 <?php
1285 1487 }
1286 1488 }
1287 1489 }
@@ -1358,21 +1560,23 @@
1358 1560 default:
1359 1561 //$class .= 'fa-file';
1360 1562 break;
1361 1563 }
1564 +
1565 + $secured_file_url = wpdocs_secure_url($file_id);
1362 1566
1363 1567 $file_list_row = '
1364 -
1365 -
1366 - <div title="'.esc_attr($filename).'" class="col-4 col-md-3 is_file text-center is_shallow" style="cursor: pointer;" data-id="'.$file.'">
1367 - <figure class="figure file_view p-1">
1368 - <a href="'.$file_url.'" target="_blank" class="file" ><img class="my-3" src="'.$icon_url.'" /></a>
1369 - <figcaption class="figure-caption text-center">'.$title.'</figcaption>
1370 - </figure>
1371 - </div>
1372 -
1373 -
1374 - ';
1568 +
1569 +<div title="'.esc_attr($filename).'" class="col-4 col-md-3 is_file text-center is_shallow" style="cursor: pointer;" data-id="'.esc_attr($file).'">
1570 + <figure class="figure file_view p-1">
1571 + <a href="'.esc_url($secured_file_url).'" target="_blank" class="file">
1572 + <img class="my-3" src="'.esc_url($icon_url).'" />
1573 + </a>
1574 + <figcaption class="figure-caption text-center">'.esc_html($title).'</figcaption>
1575 + </figure>
1576 +</div>
1577 +
1578 +';
1375 1579 $list = wpdocs_list_population($list, $file_data, $file_list_row, $default_orderby);
1376 1580
1377 1581 }
1378 1582
@@ -1443,21 +1647,23 @@
1443 1647 default:
1444 1648 //$class .= 'fa-file';
1445 1649 break;
1446 1650 }
1651 +
1652 + $secured_file_url = wpdocs_secure_url($file_id);
1447 1653
1448 1654 $file_list_row = '
1449 -
1450 -
1451 - <div title="'.esc_attr($filename).'" class="col-4 col-md-3 is_file text-center is_deep" style="cursor: pointer;" data-id="'.$file.'">
1452 - <figure class="figure file_view p-1">
1453 - <a href="'.$file_url.'" target="_blank" class="file" ><img class="my-3" src="'.$icon_url.'" /></a>
1454 - <figcaption class="figure-caption text-center">'.$title.'</figcaption>
1455 - </figure>
1456 - </div>
1457 -
1458 -
1459 - ';
1655 +
1656 +<div title="'.esc_attr($filename).'" class="col-4 col-md-3 is_file text-center is_deep" style="cursor: pointer;" data-id="'.esc_attr($file).'">
1657 + <figure class="figure file_view p-1">
1658 + <a href="'.esc_url($secured_file_url).'" target="_blank" class="file">
1659 + <img class="my-3" src="'.esc_url($icon_url).'" />
1660 + </a>
1661 + <figcaption class="figure-caption text-center">'.esc_html($title).'</figcaption>
1662 + </figure>
1663 +</div>
1664 +
1665 +';
1460 1666 $list = wpdocs_list_population($list, $file_data, $file_list_row, $default_orderby);
1461 1667
1462 1668 }
1463 1669
@@ -1492,12 +1698,16 @@
1492 1698 foreach ($wpdocs_list as $list) {
1493 1699 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
1494 1700 ?>
1495 1701
1496 - <div class="col-12 file_wrapper is_dir" style="cursor: pointer;" data-id="<?php echo $list['id']; ?>" data-resource="<?php echo base64_encode($list['id']); ?>" data-linked="<?php echo $list['content']; ?>" data-guid="<?php echo $is_shortcut?$list['link']:''; ?>">
1702 +<div class="col-12 file_wrapper is_dir" style="cursor: pointer;"
1703 + data-id="<?php echo esc_attr($list['id']); ?>"
1704 + data-resource="<?php echo esc_attr(base64_encode($list['id'])); ?>"
1705 + data-linked="<?php echo esc_attr($list['content']); ?>"
1706 + data-guid="<?php echo esc_attr($is_shortcut ? $list['link'] : ''); ?>">
1497 1707 <figure class="figure file_view p-2">
1498 1708 <span class="fa fa-folder text-warning" style="font-size:25px"></span>
1499 - <small class="text-center"><?php echo $list['title']; ?></small>
1709 + <small class="text-center"><?php echo esc_html($list['title']); ?></small>
1500 1710 </figure>
1501 1711 </div>
1502 1712 <?php
1503 1713 }
@@ -1514,12 +1724,16 @@
1514 1724 $list = array('id'=>$list_obj->ID, 'content'=>$list_obj->post_content, 'title'=>$list_obj->post_title, 'type'=>$list_obj->post_type, 'guid'=>$list_obj->guid);
1515 1725 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
1516 1726
1517 1727 ?>
1518 - <div class="col-12 file_wrapper is_dir is_deep" style="cursor: pointer;" data-id="<?php echo $list['id']; ?>" data-resource="<?php echo base64_encode($list['id']); ?>" data-linked="<?php echo $list['content']; ?>" data-guid="<?php echo $is_shortcut?$list['guid']:''; ?>">
1728 + <div class="col-12 file_wrapper is_dir is_deep" style="cursor: pointer;"
1729 + data-id="<?php echo esc_attr($list['id']); ?>"
1730 + data-resource="<?php echo esc_attr(base64_encode($list['id'])); ?>"
1731 + data-linked="<?php echo esc_attr($list['content']); ?>"
1732 + data-guid="<?php echo esc_attr($is_shortcut ? $list['guid'] : ''); ?>">
1519 1733 <figure class="figure file_view p-2">
1520 1734 <span class="fa fa-folder text-warning" style="font-size:25px"></span>
1521 - <small class="text-center"><?php echo $list['title']; ?></small>
1735 + <small class="text-center"><?php echo esc_html($list['title']); ?></small>
1522 1736 </figure>
1523 1737 </div>
1524 1738 <?php
1525 1739 }
@@ -1535,13 +1749,15 @@
1535 1749 extract($file_data);
1536 1750
1537 1751
1538 1752 if(trim($file_url)){
1753 +
1754 + $secured_file_url = wpdocs_secure_url($file_id);
1539 1755
1540 1756 $file_list_row = '
1541 1757 <div title="'.esc_attr($filename).'" class="col-12 file_wrapper is_file" style="cursor: pointer;" data-id="'.$file.'">
1542 1758 <figure class="figure file_view p-3">
1543 - <a href="'.$file_url.'" target="_blank" class="file" ><img class="mb-2" src="'.$icon_url.'" style="width: 25px; height: 25px"></a>
1759 + <a href="'.$secured_file_url.'" target="_blank" class="file" ><img class="mb-2" src="'.$icon_url.'" style="width: 25px; height: 25px"></a>
1544 1760 <small class="text-center">'.$title.'</small>
1545 1761 </figure>
1546 1762 </div>';
1547 1763
@@ -1615,14 +1831,27 @@
1615 1831 <div class="table-responsive" style="zoom:70%">
1616 1832 <table class="table">
1617 1833 <thead class="thead">
1618 1834 <tr>
1619 - <th><?php _e('Name', 'wp-docs'); ?> <?php echo $d_v_caret; ?></th>
1620 - <?php if($details_date_created): ?> <th><?php _e('Created Date', 'wp-docs'); ?> <?php echo $d_v_caret; ?></th><?php endif; ?>
1621 - <?php if($details_date): ?> <th><?php _e('Modified Date', 'wp-docs'); ?> <?php echo $d_v_caret; ?></th><?php endif; ?>
1622 - <?php if($details_type): ?> <th><?php _e('Type', 'wp-docs'); ?> <?php echo $d_v_caret; ?></th><?php endif; ?>
1623 - <?php if($details_size): ?> <th><?php _e('Size', 'wp-docs'); ?> <?php echo $d_v_caret; ?></th><?php endif; ?>
1624 - </tr>
1835 + <th><?php esc_html_e('Name', 'wp-docs'); ?> <?php echo wp_kses_post($d_v_caret); ?></th>
1836 +
1837 +<?php if ( $details_date_created ) : ?>
1838 + <th><?php esc_html_e('Created Date', 'wp-docs'); ?> <?php echo wp_kses_post($d_v_caret); ?></th>
1839 +<?php endif; ?>
1840 +
1841 +<?php if ( $details_date ) : ?>
1842 + <th><?php esc_html_e('Modified Date', 'wp-docs'); ?> <?php echo wp_kses_post($d_v_caret); ?></th>
1843 +<?php endif; ?>
1844 +
1845 +<?php if ( $details_type ) : ?>
1846 + <th><?php esc_html_e('Type', 'wp-docs'); ?> <?php echo wp_kses_post($d_v_caret); ?></th>
1847 +<?php endif; ?>
1848 +
1849 +<?php if ( $details_size ) : ?>
1850 + <th><?php esc_html_e('Size', 'wp-docs'); ?> <?php echo wp_kses_post($d_v_caret); ?></th>
1851 +<?php endif; ?>
1852 +
1853 +</tr>
1625 1854 </thead>
1626 1855 <?php
1627 1856 $no_dir_found = false;
1628 1857 $no_file_found = false;
@@ -1629,13 +1858,13 @@
1629 1858 if (!empty($wpdocs_list)) {
1630 1859 foreach ($wpdocs_list as $list) {
1631 1860 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
1632 1861 ?>
1633 - <tr title="<?php echo $list['id']; ?>" class="file_wrapper file_view is_dir" style="cursor: pointer;" data-id="<?php echo $list['id']; ?>" data-resource="<?php echo base64_encode($list['id']); ?>" data-linked="<?php echo $list['content']; ?>" data-guid="<?php echo $is_shortcut?$list['link']:''; ?>">
1862 + <tr title="<?php echo esc_attr($list['id']); ?>" class="file_wrapper file_view is_dir" style="cursor: pointer;" data-id="<?php echo esc_attr($list['id']); ?>" data-resource="<?php echo esc_attr(base64_encode($list['id'])); ?>" data-linked="<?php echo esc_attr($list['content']); ?>" data-guid="<?php echo $is_shortcut?esc_url($list['link']):''; ?>">
1634 1863 <td>
1635 1864 <figure class="figure ">
1636 1865 <span class="fa fa-folder text-warning" style="font-size:25px"></span>
1637 - <small class="text-center mb-1"><?php echo $list['title']; ?></small>
1866 + <small class="text-center mb-1"><?php echo esc_html($list['title']); ?></small>
1638 1867 </figure>
1639 1868 </td>
1640 1869
1641 1870 <?php if($details_date_created): ?> <td data-time="<?php get_post_time('U', false, $list['id']) ?>"><small><?php echo get_the_date(get_option( 'date_format' ), $list['id']) . ' ' . get_the_time(get_option( 'time_format' ), $list['id']) ?></small></td><?php endif; ?>
@@ -1673,13 +1902,13 @@
1673 1902 $list = array('id'=>$list_obj->ID, 'content'=>$list_obj->post_content, 'title'=>$list_obj->post_title, 'type'=>$list_obj->post_type, 'guid'=>$list_obj->guid);
1674 1903 $is_shortcut = ($list['type']==$wpdocs_post_types['shortcut']);
1675 1904
1676 1905 ?>
1677 - <tr title="<?php echo $list['id']; ?>" class="file_wrapper file_view is_dir is_deep" style="cursor: pointer;" data-id="<?php echo $list['id']; ?>" data-resource="<?php echo base64_encode($list['id']); ?>" data-linked="<?php echo $list['content']; ?>" data-guid="<?php echo $is_shortcut?$list['guid']:''; ?>">
1906 + <tr title="<?php echo esc_attr($list['id']); ?>" class="file_wrapper file_view is_dir is_deep" style="cursor: pointer;" data-id="<?php echo esc_attr($list['id']); ?>" data-resource="<?php echo esc_attr(base64_encode($list['id'])); ?>" data-linked="<?php echo esc_attr($list['content']); ?>" data-guid="<?php echo $is_shortcut?esc_attr($list['guid']):''; ?>">
1678 1907 <td>
1679 1908 <figure class="figure ">
1680 1909 <span class="fa fa-folder text-warning" style="font-size:25px"></span>
1681 - <small class="text-center mb-1"><?php echo $list['title']; ?></small>
1910 + <small class="text-center mb-1"><?php echo esc_html($list['title']); ?></small>
1682 1911 </figure>
1683 1912 </td>
1684 1913
1685 1914 <?php if($details_date_created): ?> <td data-time="<?php get_post_time('U', false, $list['id']) ?>"><small><?php echo get_the_date(get_option( 'date_format' ), $list['id']) . ' ' . get_the_time(get_option( 'time_format' ), $list['id']) ?></small></td><?php endif; ?>
@@ -1719,11 +1948,11 @@
1719 1948 extract($file_data);
1720 1949 //pree($ts);
1721 1950
1722 1951 if(trim($icon_url)){
1723 -
1952 + $secured_file_url = wpdocs_secure_url($file_id);
1724 1953 $files_list_row = '
1725 - <tr title="'.esc_attr($filename).'" data-url="'.$file_url.'" class="file_view file_link is_file" style="cursor: pointer;" data-id="'.$file.'">
1954 + <tr title="'.esc_attr($filename).'" data-url="'.$secured_file_url.'" class="file_view file_link is_file" style="cursor: pointer;" data-id="'.$file.'">
1726 1955
1727 1956 <td>
1728 1957
1729 1958 <figure class="figure file_view">
@@ -1776,11 +2005,13 @@
1776 2005 extract($file_data);
1777 2006 //pree($ts);
1778 2007
1779 2008 if(trim($icon_url)){
2009 +
2010 + $secured_file_url = wpdocs_secure_url($file_id);
1780 2011
1781 2012 $files_list_row = '
1782 - <tr title="'.esc_attr($filename).'" data-url="'.$file_url.'" class="file_view file_link is_file is_deep" style="cursor: pointer;" data-id="'.$file.'">
2013 + <tr title="'.esc_attr($filename).'" data-url="'.$secured_file_url.'" class="file_view file_link is_file is_deep" style="cursor: pointer;" data-id="'.$file.'">
1783 2014
1784 2015 <td>
1785 2016
1786 2017 <figure class="figure file_view">
@@ -1846,9 +2077,9 @@
1846 2077 </div>
1847 2078 <?php if($is_bootstrap): ?>
1848 2079 <div class="wpdocs_loader wpd_modal d-none">
1849 2080 <div class="modal_content">
1850 - <img src="<?php echo $wpdocs_url.'img/loader.gif' ?>" width="50px" height="50px">
2081 + <img src="<?php echo esc_url($wpdocs_url.'img/loader.gif'); ?>" width="50px" height="50px">
1851 2082 </div>
1852 2083 </div>
1853 2084 <?php endif; ?>
1854 2085
@@ -1964,8 +2195,53 @@
1964 2195 add_action('wp_ajax_wpdocs_update_folder', 'wpdocs_update_folder');
1965 2196
1966 2197 function wpdocs_update_folder() {
1967 2198
2199 + if ( ! current_user_can( 'manage_options' ) ) {
2200 + wp_send_json_error( array( 'msg' => __( 'Unauthorized access.', 'wp-docs' ) ), 403 );
2201 + }
2202 +
2203 + if (
2204 + empty( $_POST['nonce'] ) ||
2205 + ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'wpdocs_update_options_nonce' )
2206 + ) {
2207 + wp_send_json_error( array( 'msg' => __( 'Sorry, your nonce did not verify.', 'wp-docs' ) ), 403 );
2208 + }
2209 +
2210 + $dir_id = absint( $_POST['dir_id'] ?? 0 );
2211 + $resource_id = base64_decode( sanitize_text_field( $_POST['resource_id'] ?? '' ) );
2212 + $new_name = sanitize_text_field( $_POST['new_name'] ?? '' );
2213 +
2214 + if ( ! $dir_id || $resource_id != $dir_id || ! wpdocs_folder_exists( $dir_id ) ) {
2215 + wp_send_json_error( array( 'msg' => __( 'Invalid folder ID or resource mismatch.', 'wp-docs' ) ), 400 );
2216 + }
2217 +
2218 + global $wpdb, $wpdocs_post_types, $wpdocs_post_status;
2219 +
2220 + $updated = $wpdb->query(
2221 + $wpdb->prepare(
2222 + "UPDATE $wpdb->posts
2223 + SET post_title = %s
2224 + WHERE ID = %d
2225 + AND post_type IN ('" . implode( "','", array_map( 'esc_sql', $wpdocs_post_types ) ) . "')
2226 + AND post_status = %s",
2227 + htmlspecialchars_decode( $new_name ),
2228 + $dir_id,
2229 + $wpdocs_post_status
2230 + )
2231 + );
2232 +
2233 + wp_send_json_success(
2234 + array(
2235 + 'msg' => $updated
2236 + ? __( 'Successfully updated.', 'wp-docs' )
2237 + : __( 'No changes were made. Input seems the same as before.', 'wp-docs' ),
2238 + )
2239 + );
2240 + }
2241 +
2242 + /*function wpdocs_update_folder() {
2243 +
1968 2244
1969 2245 if ( ! current_user_can('edit_posts') ) {
1970 2246 wp_send_json_error(['msg' => __('Unauthorized access.', 'wp-docs')]);
1971 2247 }
@@ -2011,15 +2287,42 @@
2011 2287 $ret['msg'] = __('Invalid folder ID or resource mismatch.', 'wp-docs');
2012 2288 }
2013 2289
2014 2290 wp_send_json_success($ret);
2015 - }
2291 + }*/
2016 2292
2017 2293
2018 2294 add_action('wp_ajax_wpdocs_delete_folder', 'wpdocs_delete_folder');
2019 2295
2020 - function wpdocs_delete_folder()
2296 + function wpdocs_delete_folder() {
2297 +
2298 + if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
2299 + wp_send_json_error( array( 'msg' => __( 'Unauthorized user', 'wp-docs' ) ), 403 );
2300 + }
2301 +
2302 + if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_wpdocs_data( wp_unslash( $_POST['nonce'] ) ), 'wpdocs_update_options_nonce' ) ) {
2303 + wp_send_json_error( array( 'msg' => __( 'Sorry, your nonce did not verify.', 'wp-docs' ) ), 403 );
2304 + }
2305 +
2306 + $dir_id = isset( $_POST['dir_id'] ) ? absint( $_POST['dir_id'] ) : 0;
2307 + $resource_id = base64_decode( sanitize_wpdocs_data( $_POST['resource_id'] ?? '' ) );
2308 +
2309 + if ( ! $dir_id || $dir_id != $resource_id || ! wpdocs_folder_exists( $dir_id ) ) {
2310 + wp_send_json_error( array( 'msg' => __( 'Invalid folder.', 'wp-docs' ) ), 400 );
2311 + }
2312 +
2313 + wpdocs_recursive_delete_folder( $dir_id );
2314 +
2315 + wp_send_json_success();
2316 + }
2317 + /*function wpdocs_delete_folder()
2021 2318 {
2319 +
2320 + if ( ! current_user_can( 'manage_options' ) ) {
2321 + wp_send_json_error( __( 'Unauthorized user', 'wp-docs' ) );
2322 + wp_die();
2323 + }
2324 +
2022 2325 $nonce = sanitize_wpdocs_data(wp_unslash($_POST['nonce']));
2023 2326
2024 2327 if (!empty($_POST) && isset($_POST['nonce']) && ! wp_verify_nonce( $nonce, 'wpdocs_update_options_nonce' ) )
2025 2328 die (__("Sorry, your nonce did not verify.", 'wp-docs'));
@@ -2031,9 +2334,9 @@
2031 2334 wpdocs_recursive_delete_folder($dir_id);
2032 2335 }
2033 2336
2034 2337 exit;
2035 - }
2338 + } */
2036 2339
2037 2340
2038 2341
2039 2342 add_action('wp_ajax_wpdocs_delete_files', 'wpdocs_delete_files');
@@ -2113,11 +2416,59 @@
2113 2416 return update_post_meta($dir_id, 'wpdocs_items', $wpdocs_items);
2114 2417 }
2115 2418 }
2116 2419 }
2420 +
2421 + function wpdocs_delete_files() {
2422 + if ( ! is_user_logged_in() || ! current_user_can( 'delete_posts' ) ) {
2423 + wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'wp-docs' ) ), 403 );
2424 + }
2425 +
2426 + if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_wpdocs_data( wp_unslash( $_POST['nonce'] ) ), 'wpdocs_update_options_nonce' ) ) {
2427 + wp_send_json_error( array( 'message' => __( 'Sorry, your nonce did not verify.', 'wp-docs' ) ), 403 );
2428 + }
2429 +
2430 + $dir_id = isset( $_POST['dir_id'] ) ? absint( $_POST['dir_id'] ) : 0;
2431 + $files = isset( $_POST['files'] ) ? (array) $_POST['files'] : array();
2432 + $files = array_values( array_unique( array_filter( array_map( 'absint', $files ) ) ) );
2433 +
2434 + if ( ! $dir_id || ! wpdocs_folder_exists( $dir_id ) || empty( $files ) ) {
2435 + wp_send_json_error( array( 'message' => __( 'Invalid request.', 'wp-docs' ) ), 400 );
2436 + }
2437 +
2438 + $is_admin = current_user_can( 'manage_options' );
2439 + $is_owner = wpdocs_user_can_edit_folder( $dir_id );
2440 +
2441 + if ( ! $is_admin && ! $is_owner ) {
2442 + wp_send_json_error( array( 'message' => __( 'You cannot delete files from this folder.', 'wp-docs' ) ), 403 );
2443 + }
2444 +
2445 + $allowed = array();
2446 + foreach ( $files as $file_id ) {
2447 + $attachment = get_post( $file_id );
2448 + if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
2449 + continue;
2450 + }
2451 + if ( $is_admin || current_user_can( 'edit_post', $file_id ) ) {
2452 + $allowed[] = $file_id;
2453 + }
2454 + }
2455 +
2456 + if ( empty( $allowed ) ) {
2457 + wp_send_json_error( array( 'message' => __( 'None of the specified files can be deleted by you.', 'wp-docs' ) ), 403 );
2458 + }
2459 +
2460 + wpdocs_del_items_by_user( $dir_id, $allowed, get_current_user_id() );
2461 +
2462 + $wpdocs_items = wpdocs_added_items( $dir_id );
2463 + $wpdocs_items = array_values( array_unique( array_diff( (array) $wpdocs_items, $allowed ) ) );
2464 +
2465 + update_post_meta( $dir_id, 'wpdocs_items', $wpdocs_items );
2466 +
2467 + wp_send_json_success( array( 'dir_id' => $dir_id, 'files' => $allowed ) );
2468 + }
2117 2469
2118 -
2119 -
2470 + /*
2120 2471 function wpdocs_delete_files()
2121 2472 {
2122 2473
2123 2474 $dir_id = sanitize_wpdocs_data($_POST['dir_id']);
@@ -2141,9 +2492,9 @@
2141 2492 }
2142 2493
2143 2494
2144 2495 exit;
2145 - }
2496 + } */
2146 2497
2147 2498 function wpd_admin_footer(){
2148 2499
2149 2500 ?>
@@ -2159,152 +2510,157 @@
2159 2510 add_action('wp_ajax_wpdocs_update_option', 'wpdocs_update_option');
2160 2511
2161 2512 if(!function_exists('wpdocs_update_option')){
2162 2513 function wpdocs_update_option(){
2514 +
2515 + if ( ! current_user_can('manage_options') ) {
2516 + wp_send_json_error('Insufficient permissions.');
2517 + }
2163 2518
2519 + if (
2520 + ! isset($_POST['wpdocs_update_option_nonce']) ||
2521 + ! wp_verify_nonce($_POST['wpdocs_update_option_nonce'], 'wpdocs_update_options_nonce')
2522 + ) {
2523 + wp_send_json_error('Invalid nonce '.$_POST['wpdocs_update_option_nonce']);
2524 + } else {
2525 + //wp_send_json_success('Nonce valid!');
2526 + }
2164 2527
2528 + $return = array(
2165 2529
2166 - if(isset($_POST['wpdocs_update_option_nonce'])){
2530 + 'option_update' => false,
2531 + 'dir_move' => false,
2532 + );
2167 2533
2168 - $nonce = sanitize_wpdocs_data(wp_unslash($_POST['wpdocs_update_option_nonce']));
2534 +
2169 2535
2170 - $return = array(
2536 + if(isset($_POST['wpdocs_options'])){
2171 2537
2172 - 'option_update' => false,
2173 - 'dir_move' => false,
2174 - );
2538 + $wpdocs_options = isset($_POST['wpdocs_options']) ? sanitize_wpdocs_data($_POST['wpdocs_options']) : array();
2175 2539
2176 - if (!empty($_POST) && isset($_POST['nonce']) && ! wp_verify_nonce( $nonce, 'wpdocs_update_options_nonce' ) )
2177 - die (__("Sorry, your nonce did not verify.", 'wp-docs'));
2540 + $wpdocs_dir_id = isset($_POST['wpdocs_dir_id']) ? sanitize_wpdocs_data($_POST['wpdocs_dir_id']) : 0;
2178 2541
2179 - if(isset($_POST['wpdocs_options'])){
2180 2542
2181 - $wpdocs_options = isset($_POST['wpdocs_options']) ? sanitize_wpdocs_data($_POST['wpdocs_options']) : array();
2543 + $sanitized_option = sanitize_wpdocs_data($wpdocs_options);
2544 + $sanitized_option['allowed_role'] = $sanitized_option['allowed_role'] !== 'empty' ? $sanitized_option['allowed_role'] : array();
2182 2545
2183 - $wpdocs_dir_id = isset($_POST['wpdocs_dir_id']) ? sanitize_wpdocs_data($_POST['wpdocs_dir_id']) : 0;
2184 2546
2547 + if($wpdocs_dir_id == 0){
2185 2548
2186 - $sanitized_option = sanitize_wpdocs_data($wpdocs_options);
2187 - $sanitized_option['allowed_role'] = $sanitized_option['allowed_role'] !== 'empty' ? $sanitized_option['allowed_role'] : array();
2549 + $update = update_option('wpdocs_options', $sanitized_option);
2188 2550
2551 + }else{
2189 2552
2190 - if($wpdocs_dir_id == 0){
2553 + $update = update_post_meta($wpdocs_dir_id, '_wpdocs_dir_options', $sanitized_option);
2554 + $child_dir_list = wpdoc_get_dir_children($wpdocs_dir_id);
2555 + if(!empty($child_dir_list)){
2556 + foreach ($child_dir_list as $child_dir) {
2191 2557
2192 - $update = update_option('wpdocs_options', $sanitized_option);
2558 + $update = update_post_meta($child_dir, '_wpdocs_dir_options', $sanitized_option);
2193 2559
2194 - }else{
2195 -
2196 - $update = update_post_meta($wpdocs_dir_id, '_wpdocs_dir_options', $sanitized_option);
2197 - $child_dir_list = wpdoc_get_dir_children($wpdocs_dir_id);
2198 - if(!empty($child_dir_list)){
2199 - foreach ($child_dir_list as $child_dir) {
2200 -
2201 - $update = update_post_meta($child_dir, '_wpdocs_dir_options', $sanitized_option);
2202 -
2203 - # code...
2204 - }
2560 + # code...
2205 2561 }
2562 + }
2206 2563
2207 -
2564 +
2208 2565
2209 - }
2210 - }
2566 + }
2567 + }
2211 2568
2212 2569
2213 2570
2214 - if(isset($_POST['wpdocs_move_selected_dir'])){
2571 + if(isset($_POST['wpdocs_move_selected_dir'])){
2215 2572
2216 - $wpdocs_move_selected_dir = sanitize_wpdocs_data($_POST['wpdocs_move_selected_dir']);
2217 - $action_type = $wpdocs_move_selected_dir['action_type'];
2218 -
2573 + $wpdocs_move_selected_dir = sanitize_wpdocs_data($_POST['wpdocs_move_selected_dir']);
2574 + $action_type = $wpdocs_move_selected_dir['action_type'];
2575 +
2219 2576
2220 - $is_file = array_key_exists('is_file', $wpdocs_move_selected_dir) ? $wpdocs_move_selected_dir['is_file']: false;
2221 - $is_file = $is_file == 'false' ? false: true;
2577 + $is_file = array_key_exists('is_file', $wpdocs_move_selected_dir) ? $wpdocs_move_selected_dir['is_file']: false;
2578 + $is_file = $is_file == 'false' ? false: true;
2222 2579
2223 2580
2224 - if(!$is_file && array_key_exists('dir_selected', $wpdocs_move_selected_dir) &&
2225 - array_key_exists('dir_id', $wpdocs_move_selected_dir)){
2581 + if(!$is_file && array_key_exists('dir_selected', $wpdocs_move_selected_dir) &&
2582 + array_key_exists('dir_id', $wpdocs_move_selected_dir)){
2583 +
2584 + switch($action_type){
2585 + default:
2586 + case 'move':
2587 +
2588 +
2589 + $update = wp_update_post(
2590 + array(
2591 + 'ID' => $wpdocs_move_selected_dir['dir_selected'],
2592 + 'post_parent' => $wpdocs_move_selected_dir['dir_id']
2593 + )
2594 + );
2226 2595
2227 - switch($action_type){
2228 - default:
2229 - case 'move':
2596 + if($update == $wpdocs_move_selected_dir['dir_selected']){
2597 + $return['dir_move'] = true;
2598 + }
2230 2599
2231 -
2232 - $update = wp_update_post(
2233 - array(
2234 - 'ID' => $wpdocs_move_selected_dir['dir_selected'],
2235 - 'post_parent' => $wpdocs_move_selected_dir['dir_id']
2236 - )
2237 - );
2600 + break;
2601 +
2602 + case 'copy':
2603 + $existing_dir = get_post($wpdocs_move_selected_dir['dir_selected']);
2604 + $existing_dir = (is_object($existing_dir)?(array)$existing_dir:array());
2605 + if(!empty($existing_dir) && array_key_exists('ID', $existing_dir) && function_exists('wpdocs_recursive_copy_folder')){
2238 2606
2239 - if($update == $wpdocs_move_selected_dir['dir_selected']){
2240 - $return['dir_move'] = true;
2241 - }
2607 + wpdocs_recursive_copy_folder($wpdocs_move_selected_dir['dir_id'], $existing_dir);
2242 2608
2243 - break;
2609 + $return['dir_move'] = true;
2610 +
2611 + }
2244 2612
2245 - case 'copy':
2246 - $existing_dir = get_post($wpdocs_move_selected_dir['dir_selected']);
2247 - $existing_dir = (is_object($existing_dir)?(array)$existing_dir:array());
2248 - if(!empty($existing_dir) && array_key_exists('ID', $existing_dir) && function_exists('wpdocs_recursive_copy_folder')){
2249 -
2250 - wpdocs_recursive_copy_folder($wpdocs_move_selected_dir['dir_id'], $existing_dir);
2251 -
2252 - $return['dir_move'] = true;
2253 -
2254 - }
2255 -
2256 -
2257 - break;
2258 - }
2259 -
2260 -
2261 -
2262 - }
2263 - //exit;
2613 +
2614 + break;
2615 + }
2616 +
2617 +
2618 +
2619 + }
2620 + //exit;
2264 2621
2265 - if($is_file){
2622 + if($is_file){
2266 2623
2267 - $file_id = $wpdocs_move_selected_dir['files'];
2268 -
2269 - $current_dir = $wpdocs_move_selected_dir['file_dir'];
2624 + $file_id = $wpdocs_move_selected_dir['files'];
2625 +
2626 + $current_dir = $wpdocs_move_selected_dir['file_dir'];
2627 +
2628 + $new_dir = $wpdocs_move_selected_dir['dir_id'];
2629 +
2630 + $files = wpdocs_added_items($current_dir);
2631 +
2632 + $file_id = is_array($file_id) ? $file_id : array($file_id);
2633 + $files = array_diff($files, $file_id);
2634 +
2635 +
2636 + switch($action_type){
2637 + default:
2638 + case 'move':
2639 +
2640 + update_post_meta($current_dir, 'wpdocs_items', $files);
2641 +
2642 + break;
2270 2643
2271 - $new_dir = $wpdocs_move_selected_dir['dir_id'];
2272 -
2273 - $files = wpdocs_added_items($current_dir);
2274 -
2275 - $file_id = is_array($file_id) ? $file_id : array($file_id);
2276 - $files = array_diff($files, $file_id);
2277 -
2278 -
2279 - switch($action_type){
2280 - default:
2281 - case 'move':
2282 -
2283 - update_post_meta($current_dir, 'wpdocs_items', $files);
2284 -
2285 - break;
2644 + case 'copy':
2286 2645
2287 - case 'copy':
2288 -
2289 - break;
2290 -
2291 - }
2646 + break;
2647 +
2648 + }
2292 2649
2293 - $update = wpdocs_update_files_meta($new_dir, $file_id);
2294 -
2295 - if($update === true){
2296 - $return['dir_move'] = true;
2297 - }
2650 + $update = wpdocs_update_files_meta($new_dir, $file_id);
2651 +
2652 + if($update === true){
2653 + $return['dir_move'] = true;
2654 + }
2298 2655
2299 - }
2300 - }
2656 + }
2657 + }
2301 2658
2302 - echo wp_json_encode($return);
2659 + echo wp_json_encode($return);
2303 2660
2304 - }
2305 2661
2306 - wp_die();
2662 + wp_die();
2307 2663
2308 2664 }
2309 2665 }
2310 2666
@@ -2361,9 +2717,9 @@
2361 2717
2362 2718 if(!array_key_exists('id', $wp_dir)) continue;
2363 2719 $wpdocs_list_child = wpdocs_list($wp_dir['id']);
2364 2720
2365 - $option .= '<option value="'.$wp_dir['id'].'" data-parent="'.$dir.'">'.str_repeat(str_replace(' ', '&nbsp;', $str), $level).$wp_dir['title'].'</option>';
2721 + $option .= '<option value="'.esc_attr($wp_dir['id']).'" data-parent="'.esc_attr($dir).'">'.str_repeat(str_replace(' ', '&nbsp;', $str), $level).esc_html($wp_dir['title']).'</option>';
2366 2722
2367 2723
2368 2724 if(!empty($wpdocs_list_child)){
2369 2725
@@ -2397,9 +2753,9 @@
2397 2753
2398 2754 <nav aria-label="breadcrumb" class="wpdocs-nav">
2399 2755 <ol class="breadcrumb bg-light" style="border-bottom:1px solid #dee2e6;border-radius: 0;">
2400 2756
2401 - <li class="breadcrumb-item bread_home_url"><a class="wpd_bread_item" href="<?php echo $get_permalink ?>" data-id="0"><?php _e('Home', 'wp-docs'); ?></a></li>
2757 + <li class="breadcrumb-item bread_home_url"><a class="wpd_bread_item" href="<?php echo esc_url($get_permalink); ?>" data-id="0"><?php _e('Home', 'wp-docs'); ?></a></li>
2402 2758 <?php
2403 2759
2404 2760 foreach (array_reverse($breadcrumb_array) as $bread_key => $bread_value) {
2405 2761 $active = '';
@@ -2416,9 +2772,9 @@
2416 2772 }
2417 2773
2418 2774
2419 2775 ?>
2420 - <li class="breadcrumb-item <?php echo $active ?>" aria-current="<?php echo $page; ?>"><?php echo $link ?></li>
2776 + <li class="breadcrumb-item <?php echo esc_attr($active); ?>" aria-current="<?php echo esc_attr($page); ?>"><?php echo ($link); ?></li>
2421 2777
2422 2778 <?php
2423 2779 }
2424 2780
@@ -2434,11 +2790,46 @@
2434 2790 }
2435 2791 }
2436 2792
2437 2793 add_action('wp_ajax_wpdocs_update_view', 'wpdocs_update_view');
2438 - add_action('wp_ajax_nopriv_wpdocs_update_view', 'wpdocs_update_view');
2439 -
2440 - if(!function_exists('wpdocs_update_view')){
2794 +
2795 +
2796 + if ( ! function_exists( 'wpdocs_update_view' ) ) {
2797 + function wpdocs_update_view() {
2798 +
2799 + if ( ! is_user_logged_in() || ! current_user_can( 'read' ) ) {
2800 + wp_send_json_error( array( 'msg' => __( 'Unauthorized access.', 'wp-docs' ) ), 403 );
2801 + }
2802 +
2803 + if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_wpdocs_data( wp_unslash( $_POST['nonce'] ) ), 'wpdocs_update_options_nonce' ) ) {
2804 + wp_send_json_error( array( 'msg' => __( 'Sorry, your nonce did not verify.', 'wp-docs' ) ), 403 );
2805 + }
2806 +
2807 + $uid = get_current_user_id();
2808 + $key = 'wpdocs_view_rl_' . $uid;
2809 + $hits = (int) get_transient( $key );
2810 +
2811 + if ( $hits >= 60 ) {
2812 + wp_send_json_error( array( 'msg' => __( 'Too many requests.', 'wp-docs' ) ), 429 );
2813 + }
2814 + set_transient( $key, $hits + 1, MINUTE_IN_SECONDS );
2815 +
2816 + if ( isset( $_POST['update_view'] ) ) {
2817 +
2818 + $wpdocs_view = get_option( 'wpdocs_view', array() );
2819 + $wpdocs_view = is_array( $wpdocs_view ) ? $wpdocs_view : array();
2820 +
2821 + $parent_dir = sanitize_wpdocs_data( $_POST['parent_dir'] ?? '' );
2822 + $view_val = sanitize_wpdocs_data( $_POST['update_view'] );
2823 +
2824 + $wpdocs_view[ $parent_dir ] = $view_val;
2825 + update_option( 'wpdocs_view', $wpdocs_view );
2826 + }
2827 +
2828 + wp_send_json_success();
2829 + }
2830 + }
2831 + /*if(!function_exists('wpdocs_update_view')){
2441 2832 function wpdocs_update_view(){
2442 2833
2443 2834 $nonce = sanitize_wpdocs_data(wp_unslash($_POST['nonce']));
2444 2835
@@ -2456,9 +2847,9 @@
2456 2847
2457 2848 }
2458 2849 exit;
2459 2850 }
2460 - }
2851 + }*/
2461 2852 function wpdocs_init_session() {
2462 2853 if(!session_id()) {
2463 2854 session_start();
2464 2855 }
@@ -2654,13 +3045,91 @@
2654 3045 return $ret;
2655 3046
2656 3047 }
2657 3048 }
3049 + if(!function_exists('wpdocs_file_download')){
3050 + function wpdocs_file_download(){
3051 +
3052 + if(empty($_GET['wpdocs_dl'])){
3053 + return;
3054 + }
3055 +
3056 + $file_id = absint(
3057 + wp_unslash($_GET['wpdocs_dl'])
3058 + );
3059 +
3060 + if(!$file_id){
3061 + status_header(404);
3062 + exit;
3063 + }
3064 +
3065 + $nonce = isset($_GET['wpdocs_nonce'])
3066 + ? sanitize_text_field(
3067 + wp_unslash($_GET['wpdocs_nonce'])
3068 + )
3069 + : '';
3070 +
3071 + if(
3072 + !wp_verify_nonce(
3073 + $nonce,
3074 + 'wpdocs_dl_' . $file_id
3075 + )
3076 + ){
3077 + status_header(403);
3078 + exit;
3079 + }
3080 +
3081 + // Adjust this according to where you store the file
3082 + $file = get_attached_file($file_id);
3083 +
3084 + if(
3085 + !$file ||
3086 + !file_exists($file)
3087 + ){
3088 + status_header(404);
3089 + exit;
3090 + }
3091 +
3092 + $uploads = wp_get_upload_dir();
3093 + $base_real = realpath($uploads['basedir']);
3094 + $file_real = realpath($file);
3095 +
3096 + if(
3097 + !$base_real ||
3098 + !$file_real ||
3099 + strpos(
3100 + $file_real,
3101 + $base_real . DIRECTORY_SEPARATOR
3102 + ) !== 0
3103 + ){
3104 + status_header(403);
3105 + exit;
3106 + }
3107 +
3108 + $mime = wp_check_filetype($file_real);
3109 + $mime = !empty($mime['type'])
3110 + ? $mime['type']
3111 + : 'application/octet-stream';
3112 +
3113 + header('Content-Type: ' . $mime);
3114 + header('Content-Length: ' . filesize($file_real));
3115 + header(
3116 + 'Content-Disposition: inline; filename="' .
3117 + basename($file_real) .
3118 + '"'
3119 + );
3120 +
3121 + readfile($file_real);
3122 + exit;
3123 + }
3124 + }
2658 3125
2659 3126 add_action('init', 'wpdocs_dir_actions');
2660 3127 if(!function_exists('wpdocs_dir_actions')){
2661 3128 function wpdocs_dir_actions(){
2662 3129
3130 + wpdocs_file_download();
3131 +
2663 3132 if(is_admin() && get_option('wpdocs_memphis_uninstall')){
2664 3133 if(wp_docs_memphis_folder_preserve('mdocs_2', 'mdocs')){
2665 3134 update_option('wpdocs_memphis_uninstall', false);
2666 3135 }
@@ -3174,8 +3643,10 @@
3174 3643
3175 3644 if(!empty($dir_list)){
3176 3645 foreach($dir_list as $dir_id){
3177 3646 update_post_meta($attachment_id, '_wpdocs_memphis_media_file', true);
3647 + update_post_meta($attachment_id, '_wpdocs_memphis_file_id', $file_data['id']);
3648 +
3178 3649 $wpdocs_imported_files[] = $attachment_id;
3179 3650 wpdocs_update_files_meta($dir_id, $files);
3180 3651 }
3181 3652 unset($memphis_files_array[$file_index]);
@@ -3356,15 +3827,15 @@
3356 3827 $default_ext = '';
3357 3828
3358 3829 $breadcrumb = get_the_title($dir);
3359 3830 ?>
3360 - <small class="alert alert-success d-block"><i class="fas fa-chevron-right"></i> <?php echo $breadcrumb; ?></small>
3831 + <small class="alert alert-success d-block"><i class="fas fa-chevron-right"></i> <?php echo esc_html($breadcrumb); ?></small>
3361 3832 <?php
3362 3833
3363 3834 }
3364 3835 ?>
3365 3836 <label for="wpdocs_options_file">
3366 - <input <?php checked($is_file); ?> type="checkbox" class="<?php echo $dir_option_class; ?>" name="wpdocs_options[file_upload]" value="file_upload" id="wpdocs_options_file" />
3837 + <input <?php checked($is_file); ?> type="checkbox" class="<?php echo esc_attr($dir_option_class); ?>" name="wpdocs_options[file_upload]" value="file_upload" id="wpdocs_options_file" />
3367 3838 <?php echo __('File Upload Front-end', 'wp-docs'); ?> <small><?php echo $wpdocs_pro?__('(Optional)', 'wp-docs'):__('(Premium)', 'wp-docs'); ?></small> <i title="<?php echo __('This icon will appear on front-end for users', 'wp-docs'); ?>" class="fa fa-upload" style="color:#ffc107"></i>
3368 3839 <a href="https://www.youtube.com/embed/flFmqpJCwYk" target="_blank"><?php echo __('Video Tutorial', 'wp-docs'); ?></a>
3369 3840 </label>
3370 3841
@@ -3372,9 +3843,9 @@
3372 3843
3373 3844 <ul class="ml-4 <?php echo $is_file ? '' : 'd-none'?>">
3374 3845 <li>
3375 3846 <label for="wpdocs_options_current_user_files">
3376 - <input class="<?php echo $dir_option_class; ?>" <?php checked($is_file && $is_current_user_files); ?> type="checkbox" name="wpdocs_options[current_user_files]" value="current_user_files" id="wpdocs_options_current_user_files" />
3847 + <input class="<?php echo esc_attr($dir_option_class); ?>" <?php checked($is_file && $is_current_user_files); ?> type="checkbox" name="wpdocs_options[current_user_files]" value="current_user_files" id="wpdocs_options_current_user_files" />
3377 3848 <?php echo __('Do not make files public uploaded by users', 'wp-docs'); ?> <small><?php echo $wpdocs_pro?__('(Optional)', 'wp-docs'):__('(Premium)', 'wp-docs'); ?></small>
3378 3849 </label>
3379 3850 </li>
3380 3851
@@ -3379,9 +3850,9 @@
3379 3850 </li>
3380 3851
3381 3852 <li>
3382 3853 <label for="wpdocs_options_del_from_front">
3383 - <input class="<?php echo $dir_option_class; ?>" <?php checked($is_file && $is_del_from_front); ?> type="checkbox" name="wpdocs_options[del_from_front]" value="del_from_front" id="wpdocs_options_del_from_front" />
3854 + <input class="<?php echo esc_attr($dir_option_class); ?>" <?php checked($is_file && $is_del_from_front); ?> type="checkbox" name="wpdocs_options[del_from_front]" value="del_from_front" id="wpdocs_options_del_from_front" />
3384 3855 <?php echo __('User can delete the files from front-end?', 'wp-docs'); ?> <small><?php echo $wpdocs_pro?__('(Optional)', 'wp-docs'):__('(Premium)', 'wp-docs'); ?></small> <i class="fas fa-trash-alt" style="color:#ffc107"></i>
3385 3856 </label>
3386 3857 </li>
3387 3858
@@ -3391,9 +3862,9 @@
3391 3862 </label>
3392 3863
3393 3864
3394 3865
3395 - <select class="wpdocs_options_allowed_role <?php echo $dir_option_class; ?>" name="wpdocs_options[allowed_role]" data-name="allowed_role" id="wpdocs_options_allowed_role" multiple placeholder="<?php echo __('Select roles to allow upload', 'wp-docs'); ?>">
3866 + <select class="wpdocs_options_allowed_role <?php echo esc_attr($dir_option_class); ?>" name="wpdocs_options[allowed_role]" data-name="allowed_role" id="wpdocs_options_allowed_role" multiple placeholder="<?php echo __('Select roles to allow upload', 'wp-docs'); ?>">
3396 3867
3397 3868 <?php echo wpdocs_get_user_roles_options($allowed_role) ?>
3398 3869
3399 3870 </select>
@@ -3404,9 +3875,9 @@
3404 3875 <li>
3405 3876 <label for="wpdocs_options_allowed_ext">
3406 3877 <?php echo __('Allowed File Types', 'wp-docs'); ?> <?php echo ($wpdocs_pro?'':'<small>'.__('(Premium)', 'wp-docs').'</small> '); ?> <i class="fas fa-photo-video" style="color:#ffc107"></i>
3407 3878 </label>
3408 - <input type="text" class="form-control <?php echo $dir_option_class; ?>" name="wpdocs_options[allowed_ext]" data-name="allowed_ext" value="<?php echo $allowed_ext; ?>" id="wpdocs_options_allowed_ext" title="<?php _e('Leave blank if you want to allow all type of files', 'wp-docs'); ?>" placeholder="<?php echo $default_ext; ?>" />
3879 + <input type="text" class="form-control <?php echo esc_attr($dir_option_class); ?>" name="wpdocs_options[allowed_ext]" data-name="allowed_ext" value="<?php echo esc_attr($allowed_ext); ?>" id="wpdocs_options_allowed_ext" title="<?php _e('Leave blank if you want to allow all type of files', 'wp-docs'); ?>" placeholder="<?php echo esc_attr($default_ext); ?>" />
3409 3880
3410 3881 </li>
3411 3882
3412 3883 </ul>
@@ -3571,4 +4042,5 @@
3571 4042 function wpdoc_humanize($str){
3572 4043 return ucwords(str_replace(array('-', '_'), ' ', $str));
3573 4044 }
3574 4045 }
4046 + include_once('functions-verify.php');