data
5 years ago
export
3 years ago
import
3 years ago
views
2 years ago
class-settings-api.php
6 years ago
class-settings-data.php
5 years ago
class-settings-export.php
6 years ago
class-settings-import.php
6 years ago
class-settings-logs.php
5 years ago
class-settings-system-info.php
6 years ago
class-settings-data.php
149 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Give Settings Page/Tab |
| 4 | * |
| 5 | * @package Give |
| 6 | * @subpackage Classes/Give_Settings_Data |
| 7 | * @copyright Copyright (c) 2016, GiveWP |
| 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | * @since 1.8 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly |
| 14 | } |
| 15 | |
| 16 | if ( ! class_exists( 'Give_Settings_Data' ) ) : |
| 17 | |
| 18 | /** |
| 19 | * Give_Settings_Data. |
| 20 | * |
| 21 | * @sine 1.8 |
| 22 | */ |
| 23 | class Give_Settings_Data extends Give_Settings_Page { |
| 24 | /** |
| 25 | * Migrations list table app container ID |
| 26 | * @since 2.10.0 |
| 27 | */ |
| 28 | const CONTAINER_ID = 'give_migrations_table_app'; |
| 29 | |
| 30 | /** |
| 31 | * Flag to check if enable saving option for setting page or not |
| 32 | * |
| 33 | * @since 1.8.17 |
| 34 | * @var bool |
| 35 | */ |
| 36 | protected $enable_save = false; |
| 37 | |
| 38 | /** |
| 39 | * Constructor. |
| 40 | */ |
| 41 | public function __construct() { |
| 42 | $this->id = 'data'; |
| 43 | $this->label = esc_html__( 'Data', 'give' ); |
| 44 | $this->default_tab = 'database_updates'; |
| 45 | |
| 46 | parent::__construct(); |
| 47 | |
| 48 | // Do not use main form for this tab. |
| 49 | if ( give_get_current_setting_tab() === $this->id ) { |
| 50 | add_action( 'give-tools_open_form', '__return_empty_string' ); |
| 51 | add_action( 'give-tools_close_form', '__return_empty_string' ); |
| 52 | /** |
| 53 | * Render app container |
| 54 | * @since 2.10.0 |
| 55 | */ |
| 56 | add_action( 'give_admin_field_' . self::CONTAINER_ID, [ $this, 'render_container' ] ); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Get settings array. |
| 62 | * |
| 63 | * @since 1.8 |
| 64 | * @return array |
| 65 | */ |
| 66 | public function get_settings() { |
| 67 | $settings = []; |
| 68 | $current_section = give_get_current_setting_section(); |
| 69 | |
| 70 | switch ( $current_section ) { |
| 71 | case 'give_recount_stats': |
| 72 | $settings = apply_filters( |
| 73 | 'give_recount_stats_settings', |
| 74 | [ |
| 75 | [ |
| 76 | 'id' => 'give_tools_tools', |
| 77 | 'type' => 'title', |
| 78 | 'table_html' => false, |
| 79 | ], |
| 80 | [ |
| 81 | 'id' => 'api', |
| 82 | 'name' => esc_html__( 'Tools', 'give' ), |
| 83 | 'type' => 'data', |
| 84 | ], |
| 85 | [ |
| 86 | 'id' => 'give_tools_tools', |
| 87 | 'type' => 'sectionend', |
| 88 | 'table_html' => false, |
| 89 | ], |
| 90 | ] |
| 91 | ); |
| 92 | |
| 93 | break; |
| 94 | |
| 95 | case 'database_updates': |
| 96 | $settings = [ |
| 97 | [ |
| 98 | 'id' => self::CONTAINER_ID, |
| 99 | 'type' => self::CONTAINER_ID, |
| 100 | ], |
| 101 | ]; |
| 102 | |
| 103 | break; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Filter the settings. |
| 108 | * |
| 109 | * @since 1.8 |
| 110 | * @param array $settings |
| 111 | */ |
| 112 | $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
| 113 | |
| 114 | // Output. |
| 115 | return $settings; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Get sections. |
| 120 | * |
| 121 | * @return array |
| 122 | * |
| 123 | * @since 2.10.0 |
| 124 | */ |
| 125 | public function get_sections() { |
| 126 | $sections = [ |
| 127 | 'database_updates' => __( 'Database updates', 'give' ), |
| 128 | 'give_recount_stats' => __( 'Recount stats', 'give' ), |
| 129 | ]; |
| 130 | |
| 131 | $sections = apply_filters( 'give_data_views', $sections ); |
| 132 | |
| 133 | return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Render Migrations list table app container |
| 138 | * |
| 139 | * @since 2.10.0 |
| 140 | */ |
| 141 | public function render_container() { |
| 142 | printf( '<div id="%s" style="padding-top: 20px"></div>', self::CONTAINER_ID ); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | endif; |
| 147 | |
| 148 | return new Give_Settings_Data(); |
| 149 |