DragDropBuilder
1 month ago
EmailSettings
1 year ago
Membership
1 month ago
AbstractSettingsPage.php
2 years ago
AddNewForm.php
1 year ago
AdminFooter.php
4 years ago
ExtensionsSettingsPage.php
1 year ago
FormList.php
4 months ago
Forms.php
1 year ago
FuseWP.php
3 years ago
GeneralSettings.php
9 months ago
IDUserColumn.php
5 years ago
LicenseUpgrader.php
3 years ago
MailOptin.php
3 years ago
MemberDirectories.php
1 year ago
MembersDirectoryList.php
4 years ago
ToolsSettingsPage.php
4 years ago
index.php
3 years ago
ExtensionsSettingsPage.php
195 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages; |
| 4 | |
| 5 | use ProfilePress\Core\Classes\ExtensionManager as EM; |
| 6 | use ProfilePress\Custom_Settings_Page_Api; |
| 7 | |
| 8 | class ExtensionsSettingsPage extends AbstractSettingsPage |
| 9 | { |
| 10 | protected $spInstance; |
| 11 | |
| 12 | public function __construct() |
| 13 | { |
| 14 | add_action('ppress_admin_hooks', function () { |
| 15 | add_action('ppress_register_menu_page', [$this, 'register_settings_page']); |
| 16 | add_action('ppress_admin_settings_page_addons', [$this, 'settings_page_function']); |
| 17 | }); |
| 18 | |
| 19 | if ( ! EM::is_premium()) { |
| 20 | add_filter('install_plugins_tabs', [$this, 'add_extension_tab']); |
| 21 | add_action('install_plugins_ppress_extensions', [$this, 'extension_view']); |
| 22 | } |
| 23 | |
| 24 | add_action('admin_init', function () { |
| 25 | if (ppressGET_var('page') == PPRESS_EXTENSIONS_SETTINGS_SLUG) { |
| 26 | $this->spInstance = Custom_Settings_Page_Api::instance([], EM::DB_OPTION_NAME); |
| 27 | } |
| 28 | }); |
| 29 | } |
| 30 | |
| 31 | public function default_header_menu() |
| 32 | { |
| 33 | return 'addons'; |
| 34 | } |
| 35 | |
| 36 | public function add_extension_tab($tabs) |
| 37 | { |
| 38 | $tabs['ppress_extensions'] = 'ProfilePress ' . __('Addons', 'wp-user-avatar'); |
| 39 | |
| 40 | return $tabs; |
| 41 | } |
| 42 | |
| 43 | public function extension_view($tabs) |
| 44 | { |
| 45 | $this->admin_settings_page_callback(); |
| 46 | } |
| 47 | |
| 48 | public function admin_page_title() |
| 49 | { |
| 50 | return esc_html__('Addons', 'wp-user-avatar'); |
| 51 | } |
| 52 | |
| 53 | public function register_settings_page() |
| 54 | { |
| 55 | add_submenu_page( |
| 56 | PPRESS_DASHBOARD_SETTINGS_SLUG, |
| 57 | 'ProfilePress ' . $this->admin_page_title(), |
| 58 | '<span style="color:#f18500">' . $this->admin_page_title() . '</span>', |
| 59 | 'manage_options', |
| 60 | PPRESS_EXTENSIONS_SETTINGS_SLUG, |
| 61 | [$this, 'admin_page_callback']); |
| 62 | } |
| 63 | |
| 64 | public function settings_page_function() |
| 65 | { |
| 66 | add_filter('wp_cspa_main_content_area', array($this, 'admin_settings_page_callback'), 10, 2); |
| 67 | add_action('wp_cspa_form_tag', function () { |
| 68 | echo 'id="ppress-extension-manager-form"'; |
| 69 | }); |
| 70 | |
| 71 | $this->spInstance->add_view_classes('ppress-extensions'); |
| 72 | $this->spInstance->page_header($this->admin_page_title()); |
| 73 | $this->register_core_settings($this->spInstance, true); |
| 74 | $this->spInstance->build(true); |
| 75 | } |
| 76 | |
| 77 | public function admin_settings_page_callback() |
| 78 | { |
| 79 | ?> |
| 80 | <div class="ppress-extensions-items-wrap"> |
| 81 | <?php if (EM::is_premium()) : ?> |
| 82 | <div class="ppress-extensions-header"> |
| 83 | <div class="ppress-extensions-header-buttons"> |
| 84 | <div class="button-content"> |
| 85 | <button type="button" class="button-primary ppress-extensions-button" onclick="jQuery('.ppress-extension-manager-checkbox').prop('checked', true);jQuery('#ppress-extension-manager-form').trigger('submit');"> |
| 86 | <?= esc_html__('Activate All', 'wp-user-avatar') ?> |
| 87 | </button> |
| 88 | <button type="button" class="button-secondary ppress-extensions-button" onclick="jQuery('.ppress-extension-manager-checkbox').prop('checked', false);jQuery('#ppress-extension-manager-form').trigger('submit');"> |
| 89 | <?= esc_html__('Deactivate All', 'wp-user-avatar') ?> |
| 90 | </button> |
| 91 | </div> |
| 92 | </div> |
| 93 | </div> |
| 94 | <?php else : ?> |
| 95 | <div class="ppress-extensions-upsell-wrap"> |
| 96 | <div class="notice-content"> |
| 97 | <span> |
| 98 | <?= sprintf( |
| 99 | esc_html__('Upgrade to unlock premium extensions and other great features. As a valued ProfilePress Lite user, you will %1$sreceive 10%3$s off%2$s your purchase, automatically applied at checkout!', 'wp-user-avatar'), |
| 100 | '<span class="ppress-extensions-upsell-highlight">', '</span>', '%' |
| 101 | ) ?> |
| 102 | </span> |
| 103 | <div class="ppress-extensions-upsell-button"> |
| 104 | <a target="_blank" href="<?php echo ppress_upgrade_urls_affilify('https://profilepress.com/pricing/?discount=10PPOFF&utm_source=liteplugin&utm_medium=extension-page&utm_campaign=notice&utm_content=upsell'); ?>" class="button-primary"> |
| 105 | <?= esc_html__('Upgrade Now', 'wp-user-avatar') ?> |
| 106 | </a> |
| 107 | </div> |
| 108 | </div> |
| 109 | </div> |
| 110 | <?php endif; ?> |
| 111 | <div class="ppress-extensions-items-row"> |
| 112 | |
| 113 | <?php foreach (EM::available_extensions() as $id => $extension) : |
| 114 | $name = sprintf('%s[%s]', EM::DB_OPTION_NAME, $id); |
| 115 | $extension_class = ppress_var(EM::class_map(), $id); |
| 116 | $upgrade_url = ppress_upgrade_urls_affilify("https://profilepress.com/pricing/?utm_source=WordPress&utm_campaign=liteplugin&utm_medium=extension-upgrade&utm_content=$id"); |
| 117 | if ( ! EM::is_premium()) { |
| 118 | $upgrade_url = add_query_arg('discount', '10PPOFF', $upgrade_url); |
| 119 | } |
| 120 | |
| 121 | $upgrade_label = ! EM::is_premium() ? esc_html__('Upgrade to Premium', 'wp-user-avatar') : esc_html__('Upgrade Plan', 'wp-user-avatar'); |
| 122 | |
| 123 | ?> |
| 124 | |
| 125 | <?php $dependency_available = isset($extension['is_available']) && true !== ($callable_result = call_user_func($extension['is_available'])) ? $callable_result : true; ?> |
| 126 | <div class="ppress-extension-item-wrap"> |
| 127 | <div class="ppress-extension-item-card"> |
| 128 | <div class="ppress-extension-card-body<?= EM::is_premium() && class_exists($extension_class) && $extension_class::$instance_flag && (true !== $dependency_available) ? ' ppress-unavailable' : '' ?>"> |
| 129 | <div class="ppress-extension-card-header"> |
| 130 | <?= ppress_var($extension, 'icon', '') ?> |
| 131 | <?= esc_html($extension['title']) ?> |
| 132 | </div> |
| 133 | <div class="ppress-extension-card-description"> |
| 134 | <div><?= esc_html($extension['description']) ?></div> |
| 135 | <div class="ppress-extension-card-learn-more"> |
| 136 | <a href="<?= esc_url($extension['url']) ?>" target="_blank"><?= esc_html__('Learn More', 'wp-user-avatar') ?></a> |
| 137 | <a href="<?= esc_url($extension['url']) ?>" target="_blank" class="no-underline"> →</a> |
| 138 | </div> |
| 139 | </div> |
| 140 | </div> |
| 141 | <div class="ppress-extension-card-footer"> |
| 142 | |
| 143 | <?php if (class_exists($extension_class) && $extension_class::$instance_flag) : ?> |
| 144 | |
| 145 | <?php if (true !== $dependency_available) : ?> |
| 146 | <span class="ppress-extension-status"> |
| 147 | <?= sprintf(esc_html__('Unavailable: %s', 'wp-user-avatar'), "<span>$callable_result</span>") ?> |
| 148 | </span> |
| 149 | <?php else : ?> |
| 150 | |
| 151 | <?php if ( ! empty($extension['setting_url']) && EM::is_enabled($id)) : ?> |
| 152 | <div class="ppress-extension-card-settings"> |
| 153 | <a href="<?= esc_url($extension['setting_url']) ?>" class="button"><?php esc_html_e('Settings', 'wp-user-avatar') ?></a> |
| 154 | </div> |
| 155 | <?php endif; ?> |
| 156 | <div class="ppress-extension-card-install-activate"> |
| 157 | <span class="ppress-extension-card-status"> |
| 158 | <?= EM::is_enabled($id) ? esc_html__('Activated', 'wp-user-avatar') : esc_html__('Deactivated', 'wp-user-avatar') ?> |
| 159 | </span> |
| 160 | <label for="ppress-<?= $id ?>"> |
| 161 | <input type="hidden" name="<?= $name ?>" value="false"> |
| 162 | <input class="ppress-extension-manager-checkbox" type="checkbox" name="<?= $name ?>" id="ppress-<?= $id ?>" value="true" onchange="jQuery('#ppress-extension-manager-form').trigger('submit');" <?php checked(EM::is_enabled($id)) ?>> |
| 163 | <span class="ppress-extension-use-switch"></span> |
| 164 | </label> |
| 165 | </div> |
| 166 | <?php endif; ?> |
| 167 | |
| 168 | <?php else : ?> |
| 169 | <div class="ppress-extensions-upgrade-cta"> |
| 170 | <a class="button-primary ppress-extensions-button" href="<?= esc_url($upgrade_url) ?>" target="_blank"> |
| 171 | <?= esc_html($upgrade_label) ?> |
| 172 | </a> |
| 173 | </div> |
| 174 | <?php endif; ?> |
| 175 | </div> |
| 176 | </div> |
| 177 | </div> |
| 178 | <?php endforeach; ?> |
| 179 | </div> |
| 180 | <input type="hidden" name="save_ppress_extension_manager" value="true"> |
| 181 | </div> |
| 182 | <?php |
| 183 | } |
| 184 | |
| 185 | public static function get_instance() |
| 186 | { |
| 187 | static $instance = null; |
| 188 | |
| 189 | if (is_null($instance)) { |
| 190 | $instance = new self(); |
| 191 | } |
| 192 | |
| 193 | return $instance; |
| 194 | } |
| 195 | } |