admin
2 years ago
core
2 years ago
class-activator.php
3 years ago
class-assets.php
2 years ago
class-builder-page.php
3 years ago
class-deactivator.php
3 years ago
class-debug-info.php
2 years ago
class-feed-ajax.php
2 years ago
class-feed-block.php
2 years ago
class-feed-deserializer.php
2 years ago
class-feed-old.php
4 years ago
class-feed-page.php
3 years ago
class-feed-serializer.php
3 years ago
class-feed-shortcode.php
3 years ago
class-feed-widget.php
4 years ago
class-plugin-overview-ajax.php
3 years ago
class-plugin-overview.php
3 years ago
class-plugin-settings.php
2 years ago
class-plugin-support.php
3 years ago
class-plugin.php
2 years ago
class-post-types.php
3 years ago
class-reviews-cron.php
2 years ago
class-settings-save.php
3 years ago
class-view.php
2 years ago
index.php
4 years ago
page-setting-fig.php
3 years ago
page-setting-support.php
4 years ago
class-plugin-settings.php
172 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Rplg_Google_Reviews\Includes; |
| 4 | |
| 5 | class Plugin_Settings { |
| 6 | |
| 7 | private $debug_info; |
| 8 | |
| 9 | public function __construct(Debug_Info $debug_info) { |
| 10 | $this->debug_info = $debug_info; |
| 11 | } |
| 12 | |
| 13 | public function register() { |
| 14 | add_action('grw_admin_page_grw-settings', array($this, 'init')); |
| 15 | add_action('grw_admin_page_grw-settings', array($this, 'render')); |
| 16 | } |
| 17 | |
| 18 | public function init() { |
| 19 | |
| 20 | } |
| 21 | |
| 22 | public function render() { |
| 23 | |
| 24 | $tab = isset($_GET['grw_tab']) && strlen($_GET['grw_tab']) > 0 ? sanitize_text_field(wp_unslash($_GET['grw_tab'])) : 'active'; |
| 25 | |
| 26 | $grw_enabled = get_option('grw_active') == '1'; |
| 27 | $grw_demand_assets = get_option('grw_demand_assets'); |
| 28 | $grw_minified_assets = get_option('grw_minified_assets'); |
| 29 | $grw_google_api_key = get_option('grw_google_api_key'); |
| 30 | $grw_activation_time = get_option('grw_activation_time'); |
| 31 | $grw_debug_mode = get_option('grw_debug_mode') == '1'; |
| 32 | |
| 33 | $grw_revupd_cron = get_option('grw_revupd_cron') == '1'; |
| 34 | ?> |
| 35 | |
| 36 | <div class="grw-page-title"> |
| 37 | Settings |
| 38 | </div> |
| 39 | |
| 40 | <?php do_action('grw_admin_notices'); ?> |
| 41 | |
| 42 | <div class="grw-settings-workspace"> |
| 43 | |
| 44 | <div data-nav-tabs=""> |
| 45 | |
| 46 | <div class="nav-tab-wrapper"> |
| 47 | <a href="#grw-general" class="nav-tab<?php if ($tab == 'active') { ?> nav-tab-active<?php } ?>">General</a> |
| 48 | <a href="#grw-google" class="nav-tab<?php if ($tab == 'google') { ?> nav-tab-active<?php } ?>">Google</a> |
| 49 | <a href="#grw-advance" class="nav-tab<?php if ($tab == 'advance') { ?> nav-tab-active<?php } ?>">Advance</a> |
| 50 | </div> |
| 51 | |
| 52 | <div id="grw-general" class="tab-content" style="display:<?php echo $tab == 'active' ? 'block' : 'none'?>;"> |
| 53 | <h3>General Settings</h3> |
| 54 | <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=grw_settings_save&grw_tab=active&active=' . (string)((int)($grw_enabled != true)))); ?>"> |
| 55 | <div class="grw-field"> |
| 56 | <div class="grw-field-label"> |
| 57 | <label>Google Reviews plugin is currently <b><?php echo $grw_enabled ? 'enabled' : 'disabled' ?></b></label> |
| 58 | </div> |
| 59 | <div class="wp-review-field-option"> |
| 60 | <?php wp_nonce_field('grw-wpnonce_active', 'grw-form_nonce_active'); ?> |
| 61 | <input type="submit" name="active" class="button" value="<?php echo $grw_enabled ? 'Disable' : 'Enable'; ?>" /> |
| 62 | </div> |
| 63 | </div> |
| 64 | </form> |
| 65 | </div> |
| 66 | |
| 67 | <div id="grw-google" class="tab-content" style="display:<?php echo $tab == 'google' ? 'block' : 'none'?>;"> |
| 68 | <h3>Google</h3> |
| 69 | <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=grw_settings_save&grw_tab=google')); ?>"> |
| 70 | <?php wp_nonce_field('grw-wpnonce_save', 'grw-form_nonce_save'); ?> |
| 71 | <div class="grw-field"> |
| 72 | <div class="grw-field-label"> |
| 73 | <label>Google Places API key</label> |
| 74 | </div> |
| 75 | <div class="wp-review-field-option"> |
| 76 | <input type="text" id="grw_google_api_key" name="grw_google_api_key" class="regular-text" value="<?php echo esc_attr($grw_google_api_key); ?>"> |
| 77 | <?php if (!$grw_google_api_key && time() - $grw_activation_time > 60 * 60 * 48) { ?> |
| 78 | <div class="grw-warn">Your Google API key is not set for this reason, reviews are not automatically updated daily.<br>Please create your own Google API key and save here.</div> |
| 79 | <?php } ?> |
| 80 | <p>API key is mandatory to make the reviews automatically updated.</p> |
| 81 | <p>If you do not know how to create it, please read: <a href="<?php echo admin_url('admin.php?page=grw-support&grw_tab=fig'); ?>" target="_blank">Full Installation Guide</a></p> |
| 82 | <div style="padding-top:15px"> |
| 83 | <input type="submit" value="Save" name="save" class="button" /> |
| 84 | </div> |
| 85 | </div> |
| 86 | </div> |
| 87 | </form> |
| 88 | </div> |
| 89 | |
| 90 | <div id="grw-advance" class="tab-content" style="display:<?php echo $tab == 'advance' ? 'block' : 'none'?>;"> |
| 91 | <h3>Advance</h3> |
| 92 | <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=grw_settings_save&grw_tab=advance')); ?>"> |
| 93 | |
| 94 | <div class="grw-field"> |
| 95 | <div class="grw-field-label"> |
| 96 | <label>Reviews update daily schedule is <b><?php echo $grw_revupd_cron ? 'enabled' : 'disabled' ?></b></label> |
| 97 | </div> |
| 98 | <div class="wp-review-field-option"> |
| 99 | <?php wp_nonce_field('grw-wpnonce_revupd_cron', 'grw-form_nonce_revupd_cron'); ?> |
| 100 | <input type="submit" value="<?php echo $grw_revupd_cron ? 'Disable' : 'Enable'; ?>" name="revupd_cron" class="button" /> |
| 101 | </div> |
| 102 | </div> |
| 103 | |
| 104 | <div class="grw-field"> |
| 105 | <div class="grw-field-label"> |
| 106 | <label>Re-create the database tables of the plugin (service option)</label> |
| 107 | </div> |
| 108 | <div class="wp-review-field-option"> |
| 109 | <?php wp_nonce_field('grw-wpnonce_create_db', 'grw-form_nonce_create_db'); ?> |
| 110 | <input type="submit" value="Re-create Database" name="create_db" onclick="return confirm('Are you sure you want to re-create database tables?')" class="button" /> |
| 111 | </div> |
| 112 | </div> |
| 113 | <div class="grw-field"> |
| 114 | <div class="grw-field-label"> |
| 115 | <label><b>Please be careful</b>: this removes all settings, reviews, feeds and install the plugin from scratch</label> |
| 116 | </div> |
| 117 | <div class="wp-review-field-option"> |
| 118 | <?php wp_nonce_field('grw-wpnonce_create_db', 'grw-form_nonce_create_db'); ?> |
| 119 | <input type="submit" value="Install from scratch" name="install" onclick="return confirm('It will delete all current feeds, are you sure you want to install from scratch the plugin?')" class="button" /> |
| 120 | <p><label><input type="checkbox" id="install_multisite" name="install_multisite"> For all sites (WP Multisite)</label></p> |
| 121 | </div> |
| 122 | </div> |
| 123 | <div class="grw-field"> |
| 124 | <div class="grw-field-label"> |
| 125 | <label><b>Please be careful</b>: this removes all plugin-specific settings, reviews and feeds</label> |
| 126 | </div> |
| 127 | <div class="wp-review-field-option"> |
| 128 | <?php wp_nonce_field('grw-wpnonce_reset_all', 'grw-form_nonce_reset_all'); ?> |
| 129 | <input type="submit" value="Delete All Data" name="reset_all" onclick="return confirm('Are you sure you want to reset all plugin data including feeds?')" class="button" /> |
| 130 | <p><label><input type="checkbox" id="reset_all_multisite" name="reset_all_multisite"> For all sites (WP Multisite)</label></p> |
| 131 | </div> |
| 132 | </div> |
| 133 | <div id="debug_info" class="grw-field"> |
| 134 | <div class="grw-field-label"> |
| 135 | <label>Debug information</label> |
| 136 | </div> |
| 137 | <div class="wp-review-field-option"> |
| 138 | <input type="button" value="Copy Debug Information" name="reset_all" onclick="window.grw_debug_info.select();document.execCommand('copy');window.grw_debug_msg.innerHTML='Debug Information copied, please paste it to your email to support';" class="button" /> |
| 139 | <textarea id="grw_debug_info" style="display:block;width:30em;height:250px;margin-top:10px" onclick="window.grw_debug_info.select();document.execCommand('copy');window.grw_debug_msg.innerHTML='Debug Information copied, please paste it to your email to support';" readonly><?php $this->debug_info->render(); ?></textarea> |
| 140 | <p id="grw_debug_msg"></p> |
| 141 | </div> |
| 142 | </div> |
| 143 | <div class="grw-field" style="display:none"> |
| 144 | <div class="grw-field-label"> |
| 145 | <label>Debug mode is currently <b><?php echo $grw_debug_mode ? 'enabled' : 'disabled' ?></b></label> |
| 146 | </div> |
| 147 | <div class="wp-review-field-option"> |
| 148 | <?php wp_nonce_field('grw-wpnonce_debug_mode', 'grw-form_nonce_debug_mode'); ?> |
| 149 | <input type="submit" name="debug_mode" class="button" value="<?php echo $grw_debug_mode ? 'Disable' : 'Enable'; ?>" /> |
| 150 | </div> |
| 151 | </div> |
| 152 | <div class="grw-field"> |
| 153 | <div class="grw-field-label"> |
| 154 | <label>Execute db update manually</label> |
| 155 | </div> |
| 156 | <div class="wp-review-field-option"> |
| 157 | <?php wp_nonce_field('grw-wpnonce_update_db', 'grw-form_nonce_update_db'); ?> |
| 158 | <input type="submit" name="update_db" class="button" /> |
| 159 | <input type="text" name="update_db_ver" style="width:94px;height:22px" placeholder="version" /> |
| 160 | </div> |
| 161 | </div> |
| 162 | </form> |
| 163 | </div> |
| 164 | |
| 165 | </div> |
| 166 | |
| 167 | </div> |
| 168 | <?php |
| 169 | } |
| 170 | |
| 171 | } |
| 172 |