Skip to content

Commit

Permalink
Merge pull request #114 from fapi-cz/FAPI-935-edit-fapi-member-in-wp-…
Browse files Browse the repository at this point in the history
…user-2.2.6

added-edit-fapi-member-in-wp-user-2.2.6
  • Loading branch information
fsArti24 authored Nov 15, 2024
2 parents fc369d4 + f036b18 commit 7611714
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/Components/Content/Levels/Levels/LevelsNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function LevelsNav({activeItem, setActiveItem}) {
return (
<div className="levels-nav">
{ [
{text: 'Přiřazené stránky a přízpěvky', key: LevelsNavItemType.PAGES},
{text: 'Přiřazené stránky a příspěvky', key: LevelsNavItemType.PAGES},
{text: 'E-maily', key: LevelsNavItemType.EMAILS},
{text: 'Servisní stránky', key: LevelsNavItemType.SERVICE_PAGES},
{text: 'Uvolňování obsahu', key: LevelsNavItemType.UNLOCKING},
Expand Down
4 changes: 2 additions & 2 deletions fapi-member.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Plugin Name: FAPI Member
* Plugin URI: https://fapi.cz/
* Description: Plugin FAPI pro jednoduchou správu členských sekcí na webu.
* Version: 2.2.4
* Version: 2.2.6
* Requires at least: 5.9
* Requires PHP: 8.1
* Author: FAPI Business s.r.o.
Expand All @@ -29,7 +29,7 @@
require __DIR__ . '/src/Elementor/fapi-member.php';
require __DIR__ . '/src/Utils/functions.php';

define('FAPI_MEMBER_PLUGIN_VERSION', '2.2.4');
define('FAPI_MEMBER_PLUGIN_VERSION', '2.2.6');

$FapiPlugin = new FapiMemberPlugin();

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requires at least: 5.9
Tested up to: 6.4
Requires PHP: 8.1
License: GPLv2 or later
Stable tag: 2.2.4
Stable tag: 2.2.6

Plugin FAPI pro jednoduchou správu členských sekcí na webu.

Expand All @@ -26,6 +26,9 @@ Ohodnotit tento plugin můžete na stránkách [WordPress](https://wordpress.org

== Changelog ==

= 2.2.6 =
* Added link to FAPI Member section settings in users table and user profile

= 2.2.4 =
* Allow seamless migration from the SimpleShop plugin to FAPI Member

Expand Down
9 changes: 9 additions & 0 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private function addHooks(): void
{
$this->addInitHooks();
$this->addAdminHooks();
$this->registerUserFapiMemberTableColumn();

add_action('wp_enqueue_scripts', [$this, 'addPublicScripts']);

Expand Down Expand Up @@ -579,4 +580,12 @@ private function initializeMembershipChanges(): void
}
}

public function registerUserFapiMemberTableColumn(): void
{
add_filter('manage_users_columns', [$this->elementService, 'addUserColumn']);
add_action('manage_users_custom_column', [$this->elementService, 'showUserColumnContent'], 10, 3);
add_action('show_user_profile', [$this->elementService, 'addUserProfileSection']);
add_action('edit_user_profile', [$this->elementService, 'addUserProfileSection']);
}

}
40 changes: 40 additions & 0 deletions src/Service/ElementService.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,44 @@ public static function renderCheckbox(MemberSection|MemberLevel $level, array $l
return '<input name="' . PostValue::SECTIONS . '[]" ' . ($isAssigned ? 'checked="checked"' : '' ) . 'type="checkbox" value="' . $level->getId(). '">' . $level->getName() . '<br>';
}

public function addUserColumn($columns)
{
if (isset($columns['posts'])) {
$posts = $columns['posts'];
unset($columns['posts']);
}

$columns['fapi_member_edit'] = __('Upravit ve FAPI Member', 'fapi-member');

if (isset($posts)) {
$columns['posts'] = $posts;
}

return $columns;
}

public function showUserColumnContent($value, $columnName, $userId)
{
if ('fapi_member_edit' == $columnName) {
$editUrl = admin_url('admin.php?page=fapi-member-settings&fm-page=members&member=' . $userId);
return '<a href="' . esc_url($editUrl) . '">' . __('Upravit ve FAPI Member', 'fapi-member') . '</a>';
}

return $value;
}

public function addUserProfileSection($user)
{
if (!current_user_can('edit_users')) {
return;
}

$editUrl = admin_url('admin.php?page=fapi-member-settings&fm-page=members&member=' . $user->ID);

echo '<h2>' . __('FAPI Member', 'fapi-member') . '</h2>';
echo '<table class="form-table"><tr><th>'.__('Nastavení členských sekcí').'</th><td>';
echo '<a href="' . esc_url($editUrl) . '" class="button button-secondary">' . __('Upravit ve FAPI Member', 'fapi-member') . '</a>';
echo '</td></tr></table>';
}

}

0 comments on commit 7611714

Please sign in to comment.