| @@ -6,16 +6,21 @@ | ||
| 6 | 6 | <div class="wrap"> |
| 7 | 7 | <h1><?php _e('Settings', 'e2pdf'); ?></h1> |
| 8 | 8 | <hr class="wp-header-end"> |
| 9 | 9 | <?php $this->render('blocks', 'notifications'); ?> |
| 10 | + <?php if ($this->get->get('group') == 'woocommerce_group') { ?> | |
| 11 | + <div id="message" class="e2pdf-notice notice notice-warning"> | |
| 12 | + <p><?php _e("It's recommended to use the Integration Hooks in the E2Pdf Template settings instead", 'e2pdf'); ?></p> | |
| 13 | + </div> | |
| 14 | + <?php } ?> | |
| 10 | 15 | <h3 class="nav-tab-wrapper wp-clearfix"> |
| 11 | 16 | <?php foreach ($this->view->groups as $group_key => $group) { ?> |
| 12 | 17 | <?php if (isset($group['action']) && isset($group['group'])) { ?> |
| 13 | - <a href="<?php echo $this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $group['action'], 'group' => $group['group'])); ?>" class="nav-tab <?php if ($this->get->get('action') === $group['action'] && $this->get->get('group') === $group['group']) { ?>nav-tab-active<?php } ?>"><?php echo $group['name']; ?></a> | |
| 18 | + <a href="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $group['action'], 'group' => $group['group']))); ?>" class="nav-tab <?php if ($this->get->get('action') === $group['action'] && $this->get->get('group') === $group['group']) { ?>nav-tab-active<?php } ?>"><?php echo esc_html($group['name']); ?></a> | |
| 14 | 19 | <?php } elseif (isset($group['action'])) { ?> |
| 15 | - <a href="<?php echo $this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $group['action'])); ?>" class="nav-tab <?php if ($this->get->get('action') === $group['action']) { ?>nav-tab-active<?php } ?>"><?php echo $group['name']; ?></a> | |
| 20 | + <a href="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $group['action']))); ?>" class="nav-tab <?php if ($this->get->get('action') === $group['action']) { ?>nav-tab-active<?php } ?>"><?php echo esc_html($group['name']); ?></a> | |
| 16 | 21 | <?php } else { ?> |
| 17 | - <a href="<?php echo $this->helper->get_url(array('page' => 'e2pdf-settings')); ?>" class="nav-tab <?php if (!$this->get->get('action')) { ?>nav-tab-active<?php } ?>"><?php echo $group['name']; ?></a> | |
| 22 | + <a href="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings'))); ?>" class="nav-tab <?php if (!$this->get->get('action')) { ?>nav-tab-active<?php } ?>"><?php echo esc_html($group['name']); ?></a> | |
| 18 | 23 | <?php } ?> |
| 19 | 24 | <?php } ?> |
| 20 | 25 | </h3> |
| 21 | 26 | <div class="wrap"> |
| @@ -21,16 +26,17 @@ | ||
| 21 | 26 | <div class="wrap"> |
| 22 | 27 | <?php if ($this->get->get('action') == 'fonts') { ?> |
| 23 | 28 | <div class="e2pdf-view-area"> |
| 24 | 29 | <form enctype="multipart/form-data" method="post"> |
| 25 | - <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce('e2pdf_post') ?>"> | |
| 26 | - <ul class="e2pdf-fonts-list"> | |
| 30 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 31 | + <ul class="e2pdf-fonts-upload"> | |
| 27 | 32 | <li><h4><?php _e('Upload Font', 'e2pdf'); ?>:</h4></li> |
| 28 | 33 | <li> |
| 29 | 34 | <div class="e2pdf-name"><?php _e('Font', 'e2pdf'); ?>: |
| 30 | 35 | </div><div class="e2pdf-value"> |
| 31 | - <input name="font" type="file"> | |
| 32 | - <div class="e2pdf-note"><?php _e('Allowed filetypes', 'e2pdf'); ?>: <strong>.ttf</strong></div> | |
| 36 | + <input name="font" type="file" accept=".<?php echo esc_attr(implode(', .', $this->view->allowed_extensions)); ?>"> | |
| 37 | + <div class="e2pdf-note"><?php _e('Allowed File Types', 'e2pdf'); ?>: <strong>.<?php echo esc_html(implode(', .', $this->view->allowed_extensions)); ?></strong></div> | |
| 38 | + <div class="e2pdf-note"><?php _e('Max Upload File Size', 'e2pdf'); ?>: <strong><?php echo esc_html($this->view->upload_max_filesize); ?></strong></div> | |
| 33 | 39 | </div> |
| 34 | 40 | </li> |
| 35 | 41 | <li> |
| 36 | 42 | <div class="e2pdf-name"></div><div class="e2pdf-value"> |
| @@ -40,21 +46,21 @@ | ||
| 40 | 46 | </ul> |
| 41 | 47 | </form> |
| 42 | 48 | <div class="e2pdf-rel"> |
| 43 | 49 | <form> |
| 44 | - <div class="e2pdf-form-loader"><span class="spinner"></span></div> | |
| 45 | 50 | <ul class="e2pdf-fonts-list"> |
| 46 | - <li><h4><?php _e('Available Fonts', 'e2pdf'); ?>:</h4></li> | |
| 51 | + <li></li> | |
| 47 | 52 | <?php foreach ($this->view->fonts as $key => $value) { ?> |
| 48 | 53 | <li> |
| 49 | 54 | <div class="e2pdf-name"> |
| 50 | - <strong><?php echo $value; ?></strong> (<?php echo $key; ?>) | |
| 55 | + <strong><?php echo esc_html($value); ?></strong> (<?php echo esc_html($key); ?>) | |
| 51 | 56 | </div><div class="e2pdf-value"> |
| 52 | - <a class="e2pdf-link" href="<?php echo $this->helper->get_upload_url('fonts/' . $key); ?>" target="_blank"><i class="dashicons dashicons-download"></i></a> | |
| 57 | + <?php echo in_array(md5_file($this->helper->get('fonts_dir') . $key), $this->view->cached_fonts) ? '<i class="dashicons dashicons-cloud-saved"></i>' : ''; ?> | |
| 58 | + <a class="e2pdf-link" href="<?php echo esc_url($this->helper->get_upload_url('fonts/' . $key)); ?>" target="_blank"><i class="dashicons dashicons-download"></i></a> | |
| 53 | 59 | <?php if ($key === 'NotoSans-Regular.ttf') { ?> |
| 54 | - <a class="e2pdf-link" disabled="disabled" data-font="<?php echo $key; ?>" href="javascript:void(0);"><i class="dashicons dashicons-no"></i></a> | |
| 60 | + <a class="e2pdf-link" disabled="disabled" data-font="<?php echo esc_attr($key); ?>" href="javascript:void(0);"><i class="dashicons dashicons-no"></i></a> | |
| 55 | 61 | <?php } else { ?> |
| 56 | - <a class="e2pdf-link e2pdf-delete-font" data-font="<?php echo $key; ?>" href="javascript:void(0);"><i class="dashicons dashicons-no"></i></a> | |
| 62 | + <a class="e2pdf-link e2pdf-delete-font" data-font="<?php echo esc_attr($key); ?>" href="javascript:void(0);" _wpnonce="<?php echo wp_create_nonce('e2pdf_settings'); ?>"><i class="dashicons dashicons-no"></i></a> | |
| 57 | 63 | <?php } ?> |
| 58 | 64 | </div> |
| 59 | 65 | |
| 60 | 66 | </li> |
| @@ -62,76 +68,128 @@ | ||
| 62 | 68 | </ul> |
| 63 | 69 | </form> |
| 64 | 70 | </div> |
| 65 | 71 | </div> |
| 72 | + <?php } elseif ($this->get->get('action') == 'permissions') { ?> | |
| 73 | + <div class="e2pdf-view-area"> | |
| 74 | + <form enctype="multipart/form-data" method="post"> | |
| 75 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 76 | + <ul class="e2pdf-permissions-list"> | |
| 77 | + <?php foreach ($this->view->roles as $role_key => $role) { ?> | |
| 78 | + <li> | |
| 79 | + <div class="e2pdf-name"><?php echo esc_html($role['name']); ?>: | |
| 80 | + </div><div class="e2pdf-value"> | |
| 81 | + <?php | |
| 82 | + foreach ($this->view->caps as $cap_key => $cap) { | |
| 83 | + $this->render('field', 'checkbox', array( | |
| 84 | + 'field' => array( | |
| 85 | + 'name' => 'permissions[' . $role_key . '][' . $cap_key . ']', | |
| 86 | + 'placeholder' => $cap['name'] | |
| 87 | + ), | |
| 88 | + 'value' => isset($role['capabilities'][$cap_key]) && $role['capabilities'][$cap_key] ? true : false, | |
| 89 | + 'checkbox_value' => true, | |
| 90 | + 'default_value' => false, | |
| 91 | + )); | |
| 92 | + } | |
| 93 | + ?> | |
| 94 | + </div> | |
| 95 | + </li> | |
| 96 | + <?php } ?> | |
| 97 | + </ul> | |
| 98 | + <?php submit_button(); ?> | |
| 99 | + </form> | |
| 100 | + | |
| 101 | + </div> | |
| 102 | + <?php } elseif ($this->get->get('action') == 'maintenance') { ?> | |
| 103 | + <div class="e2pdf-view-area"> | |
| 104 | + <ul class="e2pdf-options-list"> | |
| 105 | + <li><h2><?php _e('Maintenance', 'e2pdf') ?></h2></li> | |
| 106 | + <li> | |
| 107 | + <div class="e2pdf-name"> | |
| 108 | + <?php _e('Optimize DB', 'e2pdf'); ?>: | |
| 109 | + </div><div class="e2pdf-value"> | |
| 110 | + <form onsubmit="return confirm('<?php _e('Are you sure want to continue?', 'e2pdf') ?>');" method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'maintenance'))); ?>"> | |
| 111 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 112 | + <input type="hidden" name="e2pdf_db_optimize" value="1"> | |
| 113 | + <input type="submit" name="submit" id="submit" class="button button-primary" value="»"> | |
| 114 | + </form> | |
| 115 | + </div> | |
| 116 | + </li> | |
| 117 | + <li> | |
| 118 | + <div class="e2pdf-name"> | |
| 119 | + <?php _e('Clear Recovery Mode Limit', 'e2pdf'); ?>: | |
| 120 | + </div><div class="e2pdf-value"> | |
| 121 | + <form onsubmit="return confirm('<?php _e('Are you sure want to continue?', 'e2pdf') ?>');" method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'maintenance'))); ?>"> | |
| 122 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 123 | + <input type="hidden" name="e2pdf_recovery_mode_limit" value="1"> | |
| 124 | + <input type="submit" name="submit" id="submit" class="button button-primary" value="»"> | |
| 125 | + </form> | |
| 126 | + </div> | |
| 127 | + </li> | |
| 128 | + <li><h2><?php _e('Cache', 'e2pdf') ?></h2></li> | |
| 129 | + <li> | |
| 130 | + <div class="e2pdf-name"> | |
| 131 | + <?php _e('Purge Objects Cache', 'e2pdf'); ?>: | |
| 132 | + </div><div class="e2pdf-value"> | |
| 133 | + <form onsubmit="return confirm('<?php _e('Are you sure want to continue?', 'e2pdf') ?>');" method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'maintenance'))); ?>"> | |
| 134 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 135 | + <input type="hidden" name="e2pdf_purge_objects_cache" value="1"> | |
| 136 | + <input type="submit" name="submit" id="submit" class="button button-primary" value="»"> | |
| 137 | + </form> | |
| 138 | + </div> | |
| 139 | + </li> | |
| 140 | + <li> | |
| 141 | + <div class="e2pdf-name"> | |
| 142 | + <?php _e('Purge Fonts Cache', 'e2pdf'); ?>: | |
| 143 | + </div><div class="e2pdf-value"> | |
| 144 | + <form onsubmit="return confirm('<?php _e('Are you sure want to continue?', 'e2pdf') ?>');" method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'maintenance'))); ?>"> | |
| 145 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 146 | + <input type="hidden" name="e2pdf_purge_fonts_cache" value="1"> | |
| 147 | + <input type="submit" name="submit" id="submit" class="button button-primary" value="»"> | |
| 148 | + </form> | |
| 149 | + </div> | |
| 150 | + </li> | |
| 151 | + <li> | |
| 152 | + <div class="e2pdf-name"> | |
| 153 | + <?php _e('Purge PDFs Cache', 'e2pdf'); ?>: | |
| 154 | + </div><div class="e2pdf-value"> | |
| 155 | + <form onsubmit="return confirm('<?php _e('Are you sure want to continue?', 'e2pdf') ?>');" method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'maintenance'))); ?>"> | |
| 156 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 157 | + <input type="hidden" name="e2pdf_purge_pdfs_cache" value="1"> | |
| 158 | + <input type="submit" name="submit" id="submit" class="button button-primary" value="»"> | |
| 159 | + </form> | |
| 160 | + </div> | |
| 161 | + </li> | |
| 162 | + <li><hr></li> | |
| 163 | + <li> | |
| 164 | + <div class="e2pdf-name"> | |
| 165 | + <?php _e('Purge Full Cache', 'e2pdf'); ?>: | |
| 166 | + </div><div class="e2pdf-value"> | |
| 167 | + <form onsubmit="return confirm('<?php _e('Are you sure want to continue?', 'e2pdf') ?>');" method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'maintenance'))); ?>"> | |
| 168 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 169 | + <input type="hidden" name="e2pdf_purge_cache" value="1"> | |
| 170 | + <input type="submit" name="submit" id="submit" class="button button-primary" value="»"> | |
| 171 | + </form> | |
| 172 | + </div> | |
| 173 | + </li> | |
| 174 | + </ul> | |
| 175 | + </div> | |
| 66 | 176 | <?php } else { ?> |
| 67 | 177 | <div class="e2pdf-view-area"> |
| 68 | 178 | <?php if (isset($group['action']) && isset($group['group'])) { ?> |
| 69 | - <form method="post" action="<?php echo $this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $this->get->get('action'), 'group' => $this->get->get('group'))); ?>"> | |
| 179 | + <form method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $this->get->get('action'), 'group' => $this->get->get('group')))); ?>"> | |
| 70 | 180 | <?php } elseif (isset($group['action'])) { ?> |
| 71 | - <form method="post" action="<?php echo $this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $this->get->get('action'))); ?>"> | |
| 181 | + <form method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => $this->get->get('action')))); ?>"> | |
| 72 | 182 | <?php } else { ?> |
| 73 | - <form method="post" action="<?php echo $this->helper->get_url(array('page' => 'e2pdf-settings')); ?>"> | |
| 183 | + <form method="post" action="<?php echo esc_url($this->helper->get_url(array('page' => 'e2pdf-settings'))); ?>"> | |
| 74 | 184 | <?php } ?> |
| 75 | - | |
| 76 | - <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce('e2pdf_post') ?>"> | |
| 185 | + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('e2pdf_settings'); ?>"> | |
| 77 | 186 | <ul class="e2pdf-options-list"> |
| 78 | - <?php foreach ($this->view->options as $group_key => $group) { ?> | |
| 79 | - <?php foreach ($group['options'] as $option_key => $option_value) { ?> | |
| 80 | - <?php if (isset($option_value['header'])) { ?> | |
| 81 | - <li><h4><?php echo $option_value['header']; ?></h4></li> | |
| 82 | - <?php } ?> | |
| 83 | - <?php if ($option_value['type'] != 'hidden') { ?> | |
| 84 | - <li> | |
| 85 | - <div class="e2pdf-name"> | |
| 86 | - <?php echo $option_value['name']; ?>: | |
| 87 | - </div><div class="e2pdf-value"> | |
| 88 | - <?php | |
| 89 | - if ($option_value['type'] == 'checkbox') { | |
| 90 | - $this->render('field', 'checkbox', array( | |
| 91 | - 'field' => array( | |
| 92 | - 'name' => $option_value['key'], | |
| 93 | - 'placeholder' => isset($option_value['placeholder']) ? $option_value['placeholder'] : '' | |
| 94 | - ), | |
| 95 | - 'value' => isset($option_value['value']) ? $option_value['value'] : '', | |
| 96 | - 'checkbox_value' => isset($option_value['checkbox_value']) ? $option_value['checkbox_value'] : '', | |
| 97 | - 'default_value' => isset($option_value['default_value']) ? $option_value['default_value'] : '', | |
| 98 | - )); | |
| 99 | - } elseif ($option_value['type'] == 'text') { | |
| 100 | - $this->render('field', 'text', array( | |
| 101 | - 'field' => array( | |
| 102 | - 'name' => isset($option_value['key']) ? $option_value['key'] : '', | |
| 103 | - 'placeholder' => isset($option_value['placeholder']) ? $option_value['placeholder'] : '', | |
| 104 | - 'class' => isset($option_value['class']) ? 'e2pdf-w100 ' . $option_value['class'] : 'e2pdf-w100' | |
| 105 | - ), | |
| 106 | - 'value' => $option_value['value'], | |
| 107 | - )); | |
| 108 | - } elseif ($option_value['type'] == 'textarea') { | |
| 109 | - $this->render('field', 'textarea', array( | |
| 110 | - 'field' => array( | |
| 111 | - 'name' => isset($option_value['key']) ? $option_value['key'] : '', | |
| 112 | - 'style' => 'height: 100px;', | |
| 113 | - 'class' => 'e2pdf-w100', | |
| 114 | - 'placeholder' => isset($option_value['placeholder']) ? $option_value['placeholder'] : '', | |
| 115 | - ), | |
| 116 | - 'value' => isset($option_value['value']) ? $option_value['value'] : '', | |
| 117 | - )); | |
| 118 | - } elseif ($option_value['type'] == 'select') { | |
| 119 | - $this->render('field', 'select', array( | |
| 120 | - 'field' => array( | |
| 121 | - 'name' => isset($option_value['key']) ? $option_value['key'] : '', | |
| 122 | - 'class' => 'e2pdf-w100' | |
| 123 | - ), | |
| 124 | - 'value' => isset($option_value['value']) ? $option_value['value'] : '', | |
| 125 | - 'options' => isset($option_value['options']) ? $option_value['options'] : '' | |
| 126 | - )); | |
| 127 | - } | |
| 128 | - ?> | |
| 129 | - </div> | |
| 130 | - </li> | |
| 131 | - <?php } ?> | |
| 132 | - <?php } ?> | |
| 133 | - <?php } ?> | |
| 187 | + <?php | |
| 188 | + $this->render('field', 'group', array( | |
| 189 | + 'groups' => $this->view->options | |
| 190 | + )); | |
| 191 | + ?> | |
| 134 | 192 | </ul> |
| 135 | 193 | <?php submit_button(); ?> |
| 136 | 194 | </form> |
| 137 | 195 | </div> |