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 ); +?> + +
+ + | ++ + | +
---|