Skip to content

Commit 3cd2629

Browse files
committed
AddWordPressShortcodesFromViews() - not implemented
1 parent 01ce70f commit 3cd2629

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc.ViewComponents;
6+
using PeachPied.WordPress.Standard;
7+
8+
namespace PeachPied.WordPress.AspNetCore.Internal
9+
{
10+
internal sealed class ViewsAsShortcodesPlugin : IWpPlugin, IWpPluginProvider // TODO
11+
{
12+
readonly IViewComponentDescriptorCollectionProvider _viewsProvider;
13+
14+
public ViewsAsShortcodesPlugin(IViewComponentDescriptorCollectionProvider viewsProvider)
15+
{
16+
_viewsProvider = viewsProvider;
17+
}
18+
19+
ValueTask IWpPlugin.ConfigureAsync(WpApp app, CancellationToken token)
20+
{
21+
if (_viewsProvider != null)
22+
{
23+
foreach (var item in _viewsProvider.ViewComponents.Items)
24+
{
25+
26+
}
27+
}
28+
29+
return ValueTask.CompletedTask;
30+
}
31+
32+
IEnumerable<IWpPlugin> IWpPluginProvider.GetPlugins(IServiceProvider provider, string wpRootPath) => new[] { this };
33+
}
34+
}

PeachPied.WordPress.AspNetCore/ServiceCollectionExtensions.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using PeachPied.WordPress.AspNetCore;
3+
using PeachPied.WordPress.AspNetCore.Internal;
34
using PeachPied.WordPress.Standard;
45
using System;
56

@@ -32,5 +33,26 @@ public static IServiceCollection AddWordPress(this IServiceCollection services,
3233
//
3334
return services;
3435
}
36+
37+
///// <summary>
38+
///// Registers all shared views as WordPress shortcodes correspondingly.
39+
///// </summary>
40+
///// <remarks>Same as configuring WordPress with <see cref="PeachPied.WordPress.AspNetCore.WpAppExtension.RegisterPartialViewAsShortcode"/> for each shared view.</remarks>
41+
//public static IServiceCollection AddWordPressShortcodesFromViews(this IServiceCollection services)
42+
//{
43+
// if (services == null)
44+
// {
45+
// throw new ArgumentNullException(nameof(services));
46+
// }
47+
48+
// services.Add(new ServiceDescriptor(
49+
// typeof(IWpPluginProvider),
50+
// typeof(ViewsAsShortcodesPlugin),
51+
// ServiceLifetime.Transient
52+
// ));
53+
54+
// //
55+
// return services;
56+
//}
3557
}
3658
}

0 commit comments

Comments
 (0)