admin.php
6 years ago
backup-handler.php
7 years ago
backup.php
6 years ago
cap-helper.php
6 years ago
filters-admin.php
6 years ago
filters-woocommerce.php
7 years ago
filters-wp_rest_workarounds.php
6 years ago
filters.php
6 years ago
functions-admin.php
6 years ago
functions.php
6 years ago
handler.php
6 years ago
inflect-cme.php
7 years ago
manager.php
6 years ago
network.php
6 years ago
pp-handler.php
6 years ago
pp-ui.php
6 years ago
publishpress-roles.php
6 years ago
backup.php
162 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Capability Manager Backup Tool. |
| 4 | * Provides backup and restore functionality to Capability Manager. |
| 5 | * |
| 6 | * @version $Rev: 198515 $ |
| 7 | * @author Jordi Canals |
| 8 | * @copyright Copyright (C) 2009, 2010 Jordi Canals |
| 9 | * @license GNU General Public License version 2 |
| 10 | * @link http://alkivia.org |
| 11 | * @package Alkivia |
| 12 | * @subpackage CapsMan |
| 13 | * |
| 14 | * |
| 15 | * Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat> |
| 16 | * |
| 17 | * Modifications Copyright 2020, PublishPress <help@publishpress.com> |
| 18 | * |
| 19 | * This program is free software; you can redistribute it and/or |
| 20 | * modify it under the terms of the GNU General Public License |
| 21 | * version 2 as published by the Free Software Foundation. |
| 22 | * |
| 23 | * This program is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | * GNU General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License |
| 29 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 30 | */ |
| 31 | |
| 32 | ?> |
| 33 | |
| 34 | <div class="wrap publishpress-caps-manage pressshack-admin-wrapper"> |
| 35 | <div id="icon-capsman-admin" class="icon32"></div> |
| 36 | <h2><?php printf( __('Backup Tool for %1$sPublishPress Capabilities%2$s', 'capsman-enhanced'), '<a href="admin.php?page=capsman">', '</a>' );?></h2> |
| 37 | |
| 38 | <form method="post" action="admin.php?page=<?php echo $this->ID ?>-tool"> |
| 39 | <?php wp_nonce_field('capsman-backup-tool'); ?> |
| 40 | <fieldset> |
| 41 | <table id="akmin"> |
| 42 | <tr> |
| 43 | <td class="content"> |
| 44 | <dl> |
| 45 | <dt><?php _e('Backup and Restore', 'capsman-enhanced'); ?></dt> |
| 46 | <dd> |
| 47 | <table width='100%' class="form-table"> |
| 48 | <tr> |
| 49 | <th scope="row"><?php _e('Select action:', 'capsman-enhanced'); ?></th> |
| 50 | <td> |
| 51 | <select name="action"> |
| 52 | <option value="backup"> <?php _e('Backup roles and capabilities', 'capsman-enhanced'); ?> </option> |
| 53 | |
| 54 | <?php |
| 55 | if ( $initial = get_option( 'capsman_backup_initial' ) ):?> |
| 56 | <option value="restore_initial"> <?php _e('Restore initial backup', 'capsman-enhanced'); ?> </option> |
| 57 | <?php endif;?> |
| 58 | |
| 59 | <option value="restore"> <?php _e('Restore last saved backup', 'capsman-enhanced'); ?> </option> |
| 60 | </select> |
| 61 | <input type="submit" name="Perform" value="<?php _e('Do Action', 'capsman-enhanced') ?>" class="button-primary" /> |
| 62 | </td> |
| 63 | </tr> |
| 64 | </table> |
| 65 | </dd> |
| 66 | |
| 67 | <p> |
| 68 | <?php if( ! empty( $initial ) ):?> |
| 69 | <a id="cme_show_initial" href="javascript:void(0)"><?php _e('Show initial backup', 'capsman-enhanced');?></a> • |
| 70 | <?php endif;?> |
| 71 | <a id="cme_show_last" href="javascript:void(0)"><?php _e('Show last backup', 'capsman-enhanced');?></a> |
| 72 | </p> |
| 73 | |
| 74 | <script type="text/javascript"> |
| 75 | /* <![CDATA[ */ |
| 76 | jQuery(document).ready( function($) { |
| 77 | $( '#cme_show_initial').click( function() { |
| 78 | $('#cme_display_capsman_backup_initial').show(); |
| 79 | $('#cme_display_capsman_backup').hide(); |
| 80 | }); |
| 81 | $( '#cme_show_last').click( function() { |
| 82 | $('#cme_display_capsman_backup_initial').hide(); |
| 83 | $('#cme_display_capsman_backup').show(); |
| 84 | }); |
| 85 | }); |
| 86 | /* ]]> */ |
| 87 | </script> |
| 88 | |
| 89 | <?php |
| 90 | global $wp_roles; |
| 91 | |
| 92 | $initial_caption = ( $backup_datestamp = get_option( 'capsman_backup_initial_datestamp' ) ) ? sprintf( __('Initial Backup - %s', 'capsman-enhanced'), date( 'j M Y, g:i a', $backup_datestamp ) ) : __('Initial Backup', 'capsman-enhanced'); |
| 93 | $last_caption = ( $backup_datestamp = get_option( 'capsman_backup_datestamp' ) ) ? sprintf( __('Last Backup - %s', 'capsman-enhanced'), date( 'j M Y, g:i a', $backup_datestamp ) ) : __('Last Backup', 'capsman-enhanced'); |
| 94 | |
| 95 | $backups = array( |
| 96 | 'capsman_backup_initial' => $initial_caption, |
| 97 | 'capsman_backup' => $last_caption, |
| 98 | ); |
| 99 | |
| 100 | foreach( $backups as $name => $caption ) { |
| 101 | if ( $backup_data = get_option( $name ) ) :?> |
| 102 | <div id="cme_display_<?php echo $name;?>" style="display:none;padding-left:20px;"> |
| 103 | <h3><?php printf( __( "%s (%s roles)", 'capsman-enhanded' ), $caption, count($backup_data) ); ?></h3> |
| 104 | |
| 105 | <?php foreach( $backup_data as $role => $props ) :?> |
| 106 | <?php if ( ! isset( $props['name'] ) ) continue;?> |
| 107 | <?php |
| 108 | $level = 0; |
| 109 | for( $i=10; $i>=0; $i--) { |
| 110 | if ( ! empty( $props['capabilities']["level_{$i}"] ) ) { |
| 111 | $level = $i; |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | ?> |
| 116 | <?php |
| 117 | $role_caption = $props['name']; |
| 118 | if ( empty( $wp_roles->role_objects[$role] ) ) $role_caption = "<span class='cme-plus' style='color:green;font-weight:800'>$role_caption</span>";?> |
| 119 | <h4><?php printf( __( '%s (level %s)', 'capsman-enhanced' ), translate_user_role($role_caption), $level );?></h4> |
| 120 | <ul style="list-style:disc;padding-left:30px"> |
| 121 | |
| 122 | <?php |
| 123 | ksort( $props['capabilities'] ); |
| 124 | foreach( $props['capabilities'] as $cap_name => $val ) : |
| 125 | if ( 0 === strpos( $cap_name, 'level_' ) ) continue; |
| 126 | ?> |
| 127 | <?php if ( $val && ( empty( $wp_roles->role_objects[$role] ) || empty( $wp_roles->role_objects[$role]->capabilities[$cap_name] ) ) ) $cap_name = "<span class='cme-plus' style='color:green;font-weight:800'>$cap_name</span>";?> |
| 128 | <li><?php echo ( $val ) ? $cap_name : "<strike>$cap_name</strike>";?></li> |
| 129 | <?php endforeach;?> |
| 130 | |
| 131 | </ul> |
| 132 | <?php endforeach;?> |
| 133 | </div> |
| 134 | <?php endif; |
| 135 | } |
| 136 | ?> |
| 137 | </dl> |
| 138 | |
| 139 | <dl> |
| 140 | <dt><?php if ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) _e('Reset WordPress Defaults', 'capsman-enhanced'); else echo 'Reset Roles to WordPress Defaults';?></dt> |
| 141 | <dd> |
| 142 | <p style="text-align:center;"><strong><span style="color:red;"><?php _e('WARNING:', 'capsman-enhanced'); ?></span> <?php if ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) _e('Reseting default Roles and Capabilities will set them to the WordPress install defaults.', 'capsman-enhanced'); else echo 'This will delete and/or modify stored role definitions.'; ?></strong><br /> |
| 143 | <br /> |
| 144 | <?php |
| 145 | _e('If you have installed any plugin that adds new roles or capabilities, these will be lost.', 'capsman-enhanced')?><br /> |
| 146 | <strong><?php if ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) _e('It is recommended to use this only as a last resource!'); else echo('It is recommended to use this only as a last resort!');?></strong></p> |
| 147 | <p style="text-align:center;"><a class="ak-delete" title="<?php echo esc_attr(__('Reset Roles and Capabilities to WordPress defaults', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}-tool&action=reset-defaults", 'capsman-reset-defaults'); ?>" onclick="if ( confirm('<?php echo esc_js(__("You are about to reset Roles and Capabilities to WordPress defaults.\n 'Cancel' to stop, 'OK' to reset.", 'capsman-enhanced')); ?>') ) { return true;}return false;"><?php _e('Reset to WordPress defaults', 'capsman-enhanced')?></a> |
| 148 | |
| 149 | </dd> |
| 150 | </dl> |
| 151 | |
| 152 | </td> |
| 153 | </tr> |
| 154 | </table> |
| 155 | </fieldset> |
| 156 | </form> |
| 157 | |
| 158 | <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) { |
| 159 | cme_publishpressFooter(); |
| 160 | } |
| 161 | ?> |
| 162 | </div> |