DragDropBuilder
5 years ago
EmailSettings
5 years ago
ShortcodeBuilder
5 years ago
AbstractSettingsPage.php
5 years ago
AddNewForm.php
5 years ago
AdminFooter.php
5 years ago
ExtensionsSettingsPage.php
5 years ago
FormList.php
5 years ago
Forms.php
5 years ago
GeneralSettings.php
5 years ago
IDUserColumn.php
5 years ago
MemberDirectories.php
5 years ago
MembersDirectoryList.php
5 years ago
ToolsSettingsPage.php
5 years ago
index.php
5 years ago
AbstractSettingsPage.php
176 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages; |
| 4 | |
| 5 | use ProfilePress\Core\Classes\ExtensionManager; |
| 6 | use ProfilePress\Custom_Settings_Page_Api; |
| 7 | |
| 8 | if ( ! defined('ABSPATH')) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | abstract class AbstractSettingsPage |
| 13 | { |
| 14 | protected $option_name; |
| 15 | |
| 16 | public function init_menu() |
| 17 | { |
| 18 | add_action('admin_menu', array($this, 'register_core_menu')); |
| 19 | } |
| 20 | |
| 21 | private function getMenuIcon() |
| 22 | { |
| 23 | return 'data:image/svg+xml;base64,' . base64_encode('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" width="150" height="150" viewBox="0 0 11.71 11.71" shape-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" xmlns:v="https://vecta.io/nano"><path d="M5.85.2c3.13 0 5.66 2.53 5.66 5.65 0 3.13-2.53 5.66-5.66 5.66C2.73 11.51.2 8.98.2 5.85A5.65 5.65 0 0 1 5.85.2zM3.17 5.66l2.98-2.98c.24-.24.62-.24.86 0L8.53 4.2c.24.24.24.63 0 .87L6.12 7.48l.53.54a.64.64 0 0 1 0 .92l-.07.07a.64.64 0 0 1-.92 0l-.54-.53L3.44 6.8l-.27-.28c-.24-.23-.24-.62 0-.86zm3.21-1.22L4.93 5.89c-.12.11-.12.29 0 .4.11.11.28.11.39 0l1.46-1.45c.11-.11.11-.29 0-.4h0c-.11-.11-.29-.11-.4 0zM4.93 6.29h0z" fill="#a6aaad"/></svg>'); |
| 24 | } |
| 25 | |
| 26 | public function register_core_menu() |
| 27 | { |
| 28 | add_menu_page( |
| 29 | esc_html__('ProfilePress - WordPress User Registration & Profile Plugin', 'wp-user-avatar'), |
| 30 | 'ProfilePress', |
| 31 | 'manage_options', |
| 32 | PPRESS_SETTINGS_SLUG, |
| 33 | '', |
| 34 | $this->getMenuIcon(), |
| 35 | '80.0015' |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Register core settings. |
| 41 | * |
| 42 | * @param Custom_Settings_Page_Api $instance |
| 43 | * @param bool $remove_sidebar |
| 44 | */ |
| 45 | public function register_core_settings(Custom_Settings_Page_Api $instance, $remove_sidebar = false) |
| 46 | { |
| 47 | if ( ! $remove_sidebar) { |
| 48 | $instance->sidebar($this->sidebar_args()); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | public function settings_tab_args() |
| 53 | { |
| 54 | $tabs = apply_filters('ppress_settings_page_tabs', [ |
| 55 | 20 => ['url' => PPRESS_SETTINGS_SETTING_PAGE, 'label' => esc_html__('General', 'wp-user-avatar')], |
| 56 | 40 => ['url' => add_query_arg('view', 'email', PPRESS_SETTINGS_SETTING_PAGE), 'label' => esc_html__('Emails', 'wp-user-avatar')], |
| 57 | 60 => ['url' => add_query_arg('view', 'tools', PPRESS_SETTINGS_SETTING_PAGE), 'label' => esc_html__('Tools', 'wp-user-avatar')], |
| 58 | ]); |
| 59 | |
| 60 | if ( ! ExtensionManager::is_premium()) { |
| 61 | $tabs[999] = ['url' => PPRESS_EXTENSIONS_SETTINGS_PAGE, 'label' => esc_html__('Premium Addons', 'wp-user-avatar')]; |
| 62 | } |
| 63 | |
| 64 | ksort($tabs); |
| 65 | |
| 66 | return $tabs; |
| 67 | } |
| 68 | |
| 69 | public function sidebar_args() |
| 70 | { |
| 71 | $sidebar_args = [ |
| 72 | [ |
| 73 | 'section_title' => esc_html__('Help / Support', 'wp-user-avatar'), |
| 74 | 'content' => $this->sidebar_support_docs(), |
| 75 | ], |
| 76 | [ |
| 77 | 'section_title' => esc_html__('Check out MailOptin', 'wp-user-avatar'), |
| 78 | 'content' => $this->mailoptin_ad_block(), |
| 79 | ] |
| 80 | ]; |
| 81 | |
| 82 | return $sidebar_args; |
| 83 | } |
| 84 | |
| 85 | public function sidebar_support_docs() |
| 86 | { |
| 87 | $content = '<p>'; |
| 88 | $content .= sprintf( |
| 89 | esc_html__('Visit the %s for guidance.', 'wp-user-avatar'), |
| 90 | '<strong><a href="https://profilepress.net/docs/" target="_blank">' . esc_html__('Documentation', 'wp-user-avatar') . '</a></strong>' |
| 91 | ); |
| 92 | |
| 93 | $content .= '</p>'; |
| 94 | |
| 95 | $content .= '<p>'; |
| 96 | $content .= sprintf( |
| 97 | esc_html__('For support, %sreach out to us%s.', 'wp-user-avatar'), |
| 98 | '<strong><a href="https://profilepress.net/support/" target="_blank">', '</a></strong>' |
| 99 | ); |
| 100 | $content .= '</p>'; |
| 101 | |
| 102 | return $content; |
| 103 | } |
| 104 | |
| 105 | public function mailoptin_ad_block() |
| 106 | { |
| 107 | $content = '<p>'; |
| 108 | $content .= sprintf( |
| 109 | esc_html__('Use the coupon code %s10PERCENTOFF%s to save %s off MailOptin.', 'wp-user-avatar'), |
| 110 | '<code>', '</code>', '10%' |
| 111 | ); |
| 112 | |
| 113 | $content .= '</p>'; |
| 114 | |
| 115 | $content .= '<a href="https://mailoptin.io/?utm_source=wp_dashboard&utm_medium=profilepress-admin-sidebar&utm_campaign=mailoptin" target="_blank"><img style="width: 100%" src="' . PPRESS_ASSETS_URL . '/images/admin/mo-pro-upgrade.jpg"></a>'; |
| 116 | |
| 117 | return $content; |
| 118 | } |
| 119 | |
| 120 | protected function placeholder_tags_table($placeholders) |
| 121 | { |
| 122 | ?> |
| 123 | <div class="pp-placeholder-tags"> |
| 124 | <table class="widefat striped"> |
| 125 | <tbody> |
| 126 | <tr> |
| 127 | <th colspan="2"><?= esc_html__('Available placeholders for subject and message body', 'wp-user-avatar'); ?></th> |
| 128 | </tr> |
| 129 | <?php foreach ($placeholders as $tag => $description) : ?> |
| 130 | <tr> |
| 131 | <td><?= $tag ?></td> |
| 132 | <td><?= $description ?></td> |
| 133 | </tr> |
| 134 | <?php endforeach; ?> |
| 135 | </tbody> |
| 136 | </table> |
| 137 | </div> |
| 138 | <?php |
| 139 | } |
| 140 | |
| 141 | protected function page_dropdown($id, $appends = [], $args = []) |
| 142 | { |
| 143 | $html = wp_dropdown_pages( |
| 144 | array_replace( |
| 145 | [ |
| 146 | 'name' => PPRESS_SETTINGS_DB_OPTION_NAME . "[$id]", |
| 147 | 'show_option_none' => esc_html__('Select...', 'wp-user-avatar'), |
| 148 | 'selected' => ppress_get_setting($id, ''), |
| 149 | 'echo' => false |
| 150 | ], |
| 151 | $args |
| 152 | ) |
| 153 | ); |
| 154 | |
| 155 | if ( ! empty($appends)) { |
| 156 | $addition = ''; |
| 157 | foreach ($appends as $append) { |
| 158 | $key = $append['key']; |
| 159 | $label = $append['label']; |
| 160 | $addition .= "<option value=\"$key\"" . selected(ppress_get_setting($id), $key, false) . '>' . $label . '</option>'; |
| 161 | } |
| 162 | |
| 163 | $html = ppress_append_option_to_select($addition, $html); |
| 164 | } |
| 165 | |
| 166 | return $html; |
| 167 | } |
| 168 | |
| 169 | protected function custom_text_input($id, $placeholder = '') |
| 170 | { |
| 171 | $placeholder = ! empty($placeholder) ? $placeholder : esc_html__('Custom URL Here', 'wp-user-avatar'); |
| 172 | $value = ppress_get_setting($id, ''); |
| 173 | |
| 174 | return "<input placeholder=\"$placeholder\" name=\"" . PPRESS_SETTINGS_DB_OPTION_NAME . "[$id]\" type=\"text\" class=\"regular-text code\" value=\"$value\">"; |
| 175 | } |
| 176 | } |