Exemplo n.º 1
0
 /// <summary>
 /// Hooks onto <c>wp_dashboard_setup</c> and registers <c>dashboard_widget</c> through <c>wp_add_dashboard_widget</c> API call.
 /// </summary>
 public static void DashboardWidget(this WpApp app, string widget_id, string widget_name, Action <TextWriter> htmlwriter)
 {
     app.AddFilter(
         "wp_dashboard_setup",
         new Action(() => app.Context.Call("wp_add_dashboard_widget",
                                           (PhpValue)widget_id, (PhpValue)widget_name, PhpValue.FromClass(new Action(() => htmlwriter(app.Context.Output))))));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Invoked by PHP plugin implementation (peachpie-api.php) to bridge into .NET.
 /// </summary>
 public virtual void AppStarted(WpApp app)
 {
     // activate plugins:
     foreach (var plugin in _plugins)
     {
         plugin.Configure(app);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Retrieve metadata for the specified object.
 /// </summary>
 /// <returns>
 /// Will be an array if <paramref name="single"/> is <c>false</c>.
 /// Will be value of meta data field if <paramref name="single"/> is <c>true</c>.
 /// </returns>
 public static PhpValue GetMetaData(this WpApp app, string metaType, int objectId, string metaKey, bool single = false)
 {
     return(app.Context.Call("get_metadata", metaType, (PhpValue)objectId, metaKey, single));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Retrieve user meta field for a user.
 /// </summary>
 /// <returns>
 /// Will be an array if <paramref name="single"/> is <c>false</c>.
 /// Will be value of meta data field if <paramref name="single"/> is <c>true</c>.
 /// </returns>
 public static PhpValue GetUserMeta(this WpApp app, int userId, string metaKey, bool single = false)
 => GetMetaData(app, "user", userId, metaKey, single);
Exemplo n.º 5
0
 /// <summary>
 /// Adds meta data to a user.
 /// </summary>
 public static bool AddUserMeta(this WpApp app, int userid, string metakey, PhpValue metavalue, bool unique = false)
 {
     return(app.Context
            .Call("add_user_meta", (PhpValue)userid, (PhpValue)metakey, metavalue, unique)
            .IsInteger());
 }
Exemplo n.º 6
0
 /// <summary>
 /// Hooks onto <c>rightnow_end</c> action to provide additional content to the dashboard summary box.
 /// </summary>
 public static void DashboardRightNow(this WpApp app, Action <TextWriter> htmlwriter)
 {
     app.AddFilter(
         "rightnow_end",
         new Action <Context>(ctx => htmlwriter(ctx.Output)));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Registers <c>the_permalink</c> filter.
 /// </summary>
 public static void FilterPermalink(this WpApp app, the_permalink_filter filter) => app.AddFilter("the_permalink", filter);
Exemplo n.º 8
0
 /// <summary>
 /// Registers <c>the_title</c> filter.
 /// </summary>
 public static void FilterTitle(this WpApp app, the_title_filter filter) => app.AddFilter("the_title", filter);
Exemplo n.º 9
0
 /// <summary>
 /// Registers <c>the_content</c> filter.
 /// </summary>
 public static void FilterContent(this WpApp app, the_content_filter filter) => app.AddFilter("the_content", filter);
Exemplo n.º 10
0
 /// <summary>
 /// Gets WordPress version string.
 /// </summary>
 public static string GetVersion(this WpApp app) => app.Context.Globals["wp_version"].ToString();