| @@ -263,12 +263,12 @@ | ||
| 263 | 263 | __( 'Welcome to the Friends Settings! You can configure the Friends plugin here to your liking.', 'friends' ) . |
| 264 | 264 | '</p>' . |
| 265 | 265 | '<p>' . |
| 266 | 266 | sprintf( |
| 267 | - // translators: %1$s is a URL, %2$s is the name of a wp-admin screen. | |
| 268 | - __( 'There are more settings available for each friend or subscription individually. To get there, click on the user on the <a href=%1$s>%2$s</a> screen.', 'friends' ), | |
| 269 | - '"' . esc_attr( self_admin_url( self::get_users_url() ) ) . '"', | |
| 270 | - __( 'Friends & Requests', 'friends' ) | |
| 267 | + // translators: %1$s is a URL, %2$s is the name of a page. | |
| 268 | + __( 'There are more settings available for each friend or subscription individually. To get there, click on the user on the <a href=%1$s>%2$s</a> page.', 'friends' ), | |
| 269 | + '"' . esc_attr( self::get_users_url() ) . '"', | |
| 270 | + __( 'Following', 'friends' ) | |
| 271 | 271 | ) . |
| 272 | 272 | '</p>', |
| 273 | 273 | ) |
| 274 | 274 | ); |
| @@ -489,9 +489,9 @@ | ||
| 489 | 489 | return; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | $this->check_admin_settings(); |
| 493 | - foreach ( array( 'disable_auto_tagging' ) as $checkbox ) { | |
| 493 | + foreach ( array( 'disable_auto_tagging', 'disable_link_previews' ) as $checkbox ) { | |
| 494 | 494 | if ( isset( $_POST[ $checkbox ] ) && boolval( $_POST[ $checkbox ] ) ) { |
| 495 | 495 | update_option( 'friends_' . $checkbox, true ); |
| 496 | 496 | } else { |
| 497 | 497 | delete_option( 'friends_' . $checkbox ); |
| @@ -498,8 +498,15 @@ | ||
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | if ( current_user_can( 'manage_options' ) ) { |
| 502 | + if ( isset( $_POST['main_user_id'] ) ) { | |
| 503 | + $main_user_id = absint( $_POST['main_user_id'] ); | |
| 504 | + if ( $main_user_id && user_can( $main_user_id, Friends::REQUIRED_ROLE ) ) { | |
| 505 | + update_option( 'friends_main_user_id', $main_user_id ); | |
| 506 | + } | |
| 507 | + } | |
| 508 | + | |
| 502 | 509 | foreach ( array( 'force_enable_post_formats', 'expose_post_format_feeds', 'exclude_compose_format_from_feed' ) as $checkbox ) { |
| 503 | 510 | if ( isset( $_POST[ $checkbox ] ) && boolval( $_POST[ $checkbox ] ) ) { |
| 504 | 511 | update_option( 'friends_' . $checkbox, true ); |
| 505 | 512 | } else { |
| @@ -606,8 +613,13 @@ | ||
| 606 | 613 | return apply_filters( |
| 607 | 614 | 'friends_news_entries', |
| 608 | 615 | array( |
| 609 | 616 | array( |
| 617 | + 'version' => '4.3', | |
| 618 | + 'title' => __( '4.3: Link Previews', 'friends' ), | |
| 619 | + 'template' => 'admin/news-4-3', | |
| 620 | + ), | |
| 621 | + array( | |
| 610 | 622 | 'version' => '4.2', |
| 611 | 623 | 'title' => __( '4.2: Direct Messages', 'friends' ), |
| 612 | 624 | 'template' => 'admin/news-4-2', |
| 613 | 625 | ), |
| @@ -1292,9 +1304,12 @@ | ||
| 1292 | 1304 | 'limit_homepage_post_format' => get_option( 'friends_limit_homepage_post_format', false ), |
| 1293 | 1305 | 'expose_post_format_feeds' => get_option( 'friends_expose_post_format_feeds' ), |
| 1294 | 1306 | 'compose_post_format' => get_option( 'friends_compose_post_format', 'status' ), |
| 1295 | 1307 | 'exclude_compose_format_from_feed' => get_option( 'friends_exclude_compose_format_from_feed' ), |
| 1308 | + 'main_user_id' => Friends::get_main_friend_user_id(), | |
| 1309 | + 'potential_main_users' => User_Query::all_admin_users(), | |
| 1296 | 1310 | 'disable_auto_tagging' => get_option( 'friends_disable_auto_tagging' ), |
| 1311 | + 'disable_link_previews' => get_option( 'friends_disable_link_previews' ), | |
| 1297 | 1312 | 'retention_days' => Friends::get_retention_days(), |
| 1298 | 1313 | 'retention_number' => Friends::get_retention_number(), |
| 1299 | 1314 | 'retention_days_enabled' => get_option( 'friends_enable_retention_days' ), |
| 1300 | 1315 | 'retention_number_enabled' => get_option( 'friends_enable_retention_number' ), |
| @@ -1697,10 +1712,15 @@ | ||
| 1697 | 1712 | if ( ! Friends::has_required_privileges() ) { |
| 1698 | 1713 | wp_send_json_error( __( 'You do not have permission to do this.', 'friends' ) ); |
| 1699 | 1714 | } |
| 1700 | 1715 | |
| 1701 | - $url = $this->normalize_frontend_subscription_url( wp_unslash( $_POST['url'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1716 | + $incoming_url = trim( wp_unslash( $_POST['url'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1717 | + if ( ! class_exists( '\Activitypub\Activitypub' ) && preg_match( '/^@?[A-Za-z0-9_.-]+@(?:[A-Za-z0-9_-]+\.)+[A-Za-z]+$/i', $incoming_url ) ) { | |
| 1718 | + wp_send_json_error( __( 'The ActivityPub plugin is required to follow Mastodon handles. Please install and activate it first.', 'friends' ) ); | |
| 1719 | + } | |
| 1702 | 1720 | |
| 1721 | + $url = $this->normalize_frontend_subscription_url( $incoming_url ); | |
| 1722 | + | |
| 1703 | 1723 | if ( '' === $url ) { |
| 1704 | 1724 | wp_send_json_error( __( 'No URL provided.', 'friends' ) ); |
| 1705 | 1725 | } |
| 1706 | 1726 | |
| @@ -2342,9 +2362,9 @@ | ||
| 2342 | 2362 | |
| 2343 | 2363 | if ( isset( $_GET['_wp_http_referer'] ) ) { |
| 2344 | 2364 | wp_safe_redirect( wp_get_referer() ); |
| 2345 | 2365 | } else { |
| 2346 | - wp_safe_redirect( add_query_arg( $arg, $arg_value, self_admin_url( 'admin.php?page=friends-list' ) ) ); | |
| 2366 | + wp_safe_redirect( add_query_arg( $arg, $arg_value, home_url( '/friends/following/' ) ) ); | |
| 2347 | 2367 | } |
| 2348 | 2368 | exit; |
| 2349 | 2369 | } |
| 2350 | 2370 | |
| @@ -2867,9 +2887,9 @@ | ||
| 2867 | 2887 | return $friend_roles; |
| 2868 | 2888 | } |
| 2869 | 2889 | |
| 2870 | 2890 | public static function get_users_url() { |
| 2871 | - return 'admin.php?page=friends-list'; | |
| 2891 | + return home_url( '/friends/following/' ); | |
| 2872 | 2892 | } |
| 2873 | 2893 | |
| 2874 | 2894 | /** |
| 2875 | 2895 | * Override the post title for specific post formats. |
| @@ -2961,9 +2981,9 @@ | ||
| 2961 | 2981 | array( |
| 2962 | 2982 | 'id' => 'friends', |
| 2963 | 2983 | 'parent' => 'friends-menu', |
| 2964 | 2984 | 'title' => esc_html__( 'Settings' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain |
| 2965 | - 'href' => $my_admin_url . '/wp-admin/admin.php?page=friends-settings', | |
| 2985 | + 'href' => home_url( '/friends/settings/' ), | |
| 2966 | 2986 | ) |
| 2967 | 2987 | ); |
| 2968 | 2988 | } |
| 2969 | 2989 | |