From efa64457e3b4b01ccc9a92649f27bd705126e701 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 11 Feb 2020 10:00:25 +0100 Subject: [PATCH] make attachment links configurable --- includes/class-admin.php | 46 +++++++++++++++++++++++++++++++++---- languages/activitypub.pot | 2 +- templates/user-settings.php | 37 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 templates/user-settings.php diff --git a/includes/class-admin.php b/includes/class-admin.php index fbdf85d..e5745f8 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -14,6 +14,8 @@ class Admin { \add_action( 'admin_menu', array( '\Activitypub\Admin', 'admin_menu' ) ); \add_action( 'admin_init', array( '\Activitypub\Admin', 'register_settings' ) ); \add_action( 'show_user_profile', array( '\Activitypub\Admin', 'add_fediverse_profile' ) ); + \add_action( 'personal_options_update', array( '\Activitypub\Admin', 'save_profile' ), 11 ); + \add_action( 'edit_user_profile_update', array( '\Activitypub\Admin', 'save_profile' ), 11 ); } /** @@ -50,7 +52,7 @@ class Admin { } /** - * Register PubSubHubbub settings + * Register ActivityPub settings */ public static function register_settings() { \register_setting( @@ -106,6 +108,14 @@ class Admin { 'default' => array( 'post', 'pages' ), ) ); + \register_setting( + 'activitypub', 'activitypub_profile_fields', array( + 'type' => 'array', + 'description' => \esc_html__( 'You can have up to 4 items displayed as a table on your profile.', 'activitypub' ), + 'show_in_rest' => true, + 'default' => array(), + ) + ); } public static function add_settings_help_tab() { @@ -132,10 +142,36 @@ class Admin { // todo } + /** + * Undocumented function + * + * @param [type] $user + * @return void + */ public static function add_fediverse_profile( $user ) { - ?> -

- ID ); + \load_template( \dirname( __FILE__ ) . '/../templates/user-settings.php' ); + } + + /** + * Save the ActivityPub specific data. + * + * @param int $user_id + * @return void + */ + public static function save_profile( $user_id ) { + if ( ! current_user_can( 'edit_user', $user_id ) ) { + return false; + } + + $profile_fields = array(); + + if ( isset( $_POST['activitypub_profile_fields'] ) ) { + foreach ( $_POST['activitypub_profile_fields'] as $key => $value ) { + + } + } + + echo "
";
+		var_dump($_POST);
 	}
 }
diff --git a/languages/activitypub.pot b/languages/activitypub.pot
index 78fdde3..ce79490 100644
--- a/languages/activitypub.pot
+++ b/languages/activitypub.pot
@@ -5,7 +5,7 @@ msgstr ""
 "Project-Id-Version: ActivityPub 0.9.1\n"
 "Report-Msgid-Bugs-To: "
 "https://wordpress.org/support/plugin/wordpress-activitypub\n"
-"POT-Creation-Date: 2019-11-27 07:27:13+00:00\n"
+"POT-Creation-Date: 2019-11-27 08:14:18+00:00\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
diff --git a/templates/user-settings.php b/templates/user-settings.php
new file mode 100644
index 0000000..0bec17e
--- /dev/null
+++ b/templates/user-settings.php
@@ -0,0 +1,37 @@
+

+ +ID ); +?> + + + + + + + + +