All Projects → dreamsoftin → Flutter_wordpress

dreamsoftin / Flutter_wordpress

Licence: mit
Flutter WordPress API

Programming Languages

dart
5743 projects
dartlang
94 projects

Projects that are alternatives of or similar to Flutter wordpress

Wordprismic
Utility to import existing Wordpress blogs into the Prismic.io content platform
Stars: ✭ 25 (-83.87%)
Mutual labels:  wordpress-api, wordpress
Headless Wp
A demo repo for Headless WordPress
Stars: ✭ 89 (-42.58%)
Mutual labels:  wordpress-api, wordpress
Ultimate Fields
The plugin for custom fields in WordPress
Stars: ✭ 39 (-74.84%)
Mutual labels:  wordpress-api, wordpress
Wp Api Angular
Angular (>=2) services for WordPress WP-API(v2) or WP >= 4.7 (natively supports WP-API)
Stars: ✭ 266 (+71.61%)
Mutual labels:  wordpress-api, wordpress
Frontpress
⚡️ A full front-end AngularJS template for WordPress Rest API.
Stars: ✭ 109 (-29.68%)
Mutual labels:  wordpress-api, wordpress
Tony
An Elegant WordPress Theme Based on ✌️Vue.js | 基于 Vue.js 的简洁一般强大的 WordPress 单栏博客主题
Stars: ✭ 462 (+198.06%)
Mutual labels:  wordpress-api, wordpress
Better Rest Endpoints
A WordPress plugin that serves up slimmer WP Rest API endpoints.
Stars: ✭ 56 (-63.87%)
Mutual labels:  wordpress-api, wordpress
Hybrid
[I don't have time to work on this anymore. Use at your own risk] Build WordPress based PWA, iOS, Android & Windows phones apps in minutes!
Stars: ✭ 1,026 (+561.94%)
Mutual labels:  wordpress-api, wordpress
Nextjs Wordpress Starter
WebDevStudios Next.js WordPress Starter
Stars: ✭ 104 (-32.9%)
Mutual labels:  wordpress-api, wordpress
Wordpresssharp
A C# client to to interact with the WordPress XML-RPC API
Stars: ✭ 97 (-37.42%)
Mutual labels:  wordpress-api, wordpress
Wp Api React
This boilerplate will help you use React JS with Wordpress REST API.
Stars: ✭ 255 (+64.52%)
Mutual labels:  wordpress-api, wordpress
Google Docs Add On
Publish to WordPress from Google Docs
Stars: ✭ 140 (-9.68%)
Mutual labels:  wordpress-api, wordpress
Create React Wptheme
Create modern, React-enabled WordPress themes with a single command.
Stars: ✭ 252 (+62.58%)
Mutual labels:  wordpress-api, wordpress
Intervention
WordPress plugin to configure wp-admin and application state using a single config file.
Stars: ✭ 481 (+210.32%)
Mutual labels:  wordpress-api, wordpress
Kasia
🎩 A React Redux toolset for the WordPress API
Stars: ✭ 219 (+41.29%)
Mutual labels:  wordpress-api, wordpress
Ember Wordpress
The bridge between Ember.js and Wordpress
Stars: ✭ 94 (-39.35%)
Mutual labels:  wordpress-api, wordpress
Restsplain
WordPress REST API documentation generator
Stars: ✭ 126 (-18.71%)
Mutual labels:  wordpress-api, wordpress
Live Composer Page Builder
Free page builder plugin for WordPress http://livecomposerplugin.com
Stars: ✭ 143 (-7.74%)
Mutual labels:  wordpress-api, wordpress
Dokan
Multivendor marketplace platform
Stars: ✭ 146 (-5.81%)
Mutual labels:  wordpress
Themeforest Wp Theme Approval Checklist
A comprehensive list of rejection messages which you should avoid to get your WordPress theme approved quickly in Themeforest
Stars: ✭ 150 (-3.23%)
Mutual labels:  wordpress

Flutter Wordpress

pub.dev

This library uses WordPress REST API V2 to provide a way for your application to interact with your WordPress website.

Tutorial - by Ritesh Sharma

Screenshots

Requirements

For authentication and usage of administrator level REST APIs, you need to use either of the two popular authentication plugins in your WordPress site:

  1. Application Passwords
  2. JWT Authentication for WP REST API (recommended)

Getting Started

1. Import library

First:

Find your pubspec.yaml in the root of your project and add flutter_wordpress: ^0.2.0 under dependencies:

Second:

import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;

2. Instantiate WordPress class

wp.WordPress wordPress;

// adminName and adminKey is needed only for admin level APIs
wordPress = wp.WordPress(
  baseUrl: 'http://localhost',
  authenticator: wp.WordPressAuthenticator.JWT,
  adminName: '',
  adminKey: '',
);

3. Authenticate User

Future<wp.User> response = wordPress.authenticateUser(
  username: 'ChiefEditor',
  password: '[email protected]',
);

response.then((user) {
  createPost(user);
}).catchError((err) {
  print('Failed to fetch user: $err');
});

4. Fetch Posts

Future<List<wp.Post>> posts = wordPress.fetchPosts(
  postParams: wp.ParamsPostList(
    context: wp.WordPressContext.view,
    pageNum: 1,
    perPage: 20,
    order: wp.Order.desc,
    orderBy: wp.PostOrderBy.date,
  ),
  fetchAuthor: true,
  fetchFeaturedMedia: true,
  fetchComments: true,
  postType: 'post'
);

5. Fetch Users

Future<List<wp.User>> users = wordPress.fetchUsers(
  params: wp.ParamsUserList(
    context: wp.WordPressContext.view,
    pageNum: 1,
    perPage: 30,
    order: wp.Order.asc,
    orderBy: wp.UsersOrderBy.name,
    roles: ['subscriber'],
  ),
);

6. Fetch Comments

Future<List<wp.Comment>> comments = wordPress.fetchComments(
  params: wp.ParamsCommentList(
    context: wp.WordPressContext.view,
    pageNum: 1,
    perPage: 30,
    includePostIDs: [1],
  ),
);

7. Create User

Future<void> createUser({@required String email, @required String username, @required String password, @required List<String> roles}) async {
    await widget.wordPress.createUser(
      user: wp.User(
        email: email,
        password: password,
        username: username,
        roles: roles
      )
    ).then((p) {
      print('User created successfully ${p}');
    }).catchError((err) {
      print('Failed to create user: $err');
    });
  }

8. Create Post

  void createPost({@required wp.User user}) {
    final post = widget.wordPress.createPost(
      post: new wp.Post(
        title: 'First post as a Chief Editor',
        content: 'Blah! blah! blah!',
        excerpt: 'Discussion about blah!',
        authorID: user.id,
        commentStatus: wp.PostCommentStatus.open,
        pingStatus: wp.PostPingStatus.closed,
        status: wp.PostPageStatus.publish,
        format: wp.PostFormat.standard,
        sticky: true,
      ),
    );

    post.then((p) {
      print('Post created successfully with ID: ${p.id}');
    }).catchError((err) {
      print('Failed to create post: $err');
    });
  }

9. create Comment

  void createComment({@required int userId, @required int postId}) {
    final comment = widget.wordPress.createComment(
      comment: new wp.Comment(
        author: userId,
        post: postId,
        content: "First!",
        parent: 0,
      ),
    );

    comment.then((c) {
      print('Comment successfully posted with ID: ${c.id}');
    }).catchError((err) {
      print('Failed to comment: $err');
    });
  }

10. Update Comment

Future<void> updateComment({@required int id, @required int postId, @required wp.User user}) async {
    await widget.wordPress.updateComment(
      comment: new wp.Comment(
        content: "Comment Updated2!",
        author: user.id,
        post: postId,
      ),
      id: id,
    ).then((c) {
      print('Comment updated successfully "$c"');
    }).catchError((err) {
      print('Failed to update Comment: $err');
    });
  }

11. Update Post

Future<void> updatePost({@required int id, @required int userId}) async {
    await widget.wordPress.updatePost(
      post: new wp.Post(
        title: 'First post as a Chief Editor',
        content: 'Blah! blah! blah!',
        excerpt: 'Discussion about blah!',
        authorID: userId,
        commentStatus: wp.PostCommentStatus.open,
        pingStatus: wp.PostPingStatus.closed,
        status: wp.PostPageStatus.publish,
        format: wp.PostFormat.standard,
        sticky: true,
      ),
      id: id, //
    ).then((p) {
      print('Post updated successfully with ID ${p}');
    }).catchError((err) {
      print('Failed to update post: $err');
    });
  }

12. Update User

Future<void> updateUser({@required int id, @required String username, @required String email}) async {
    await widget.wordPress.updateUser(
      user: new wp.User(
        description: "This is description for this user",
        username: username,
        id: id,
        email: email
      ),
      id: id,
    ).then((u) {
      print('User updated successfully $u');
    }).catchError((err) {
      print('Failed to update User: $err');
    });
  }

13. Delete Comment

Future<void> deleteComment({@required int id}) async {
    await widget.wordPress.deleteComment(id: id).then((c) {
      print('Comment Deleted successfully: $c');
    }).catchError((err) {
      print('Failed to Delete comment: $err');
    });
  }

14. Delete Post

  Future<void> deletePost({@required int id}) async {
    await widget.wordPress.deletePost(id: id).then((p) {
      print('Post Deleted successfully: $p');
    }).catchError((err) {
      print('Failed to Delete post: $err');
    });
  }

15. Delete User

  Future<void> deleteUser({@required int id, @required int reassign}) async {
    await widget.wordPress.deleteUser(id: id, reassign: reassign).then((u) {
      print('User Deleted successfully: $u');
    }).catchError((err) {
      print('Failed to Delete user: $err');
    });
  }

16. Upload Media

  uploadMedia(File image) async {
  var media = await wordPress.uploadMedia(image).then((m) {
    print('Media uploaded successfully: $m');
  }).catchError((err) {
    print('Failed to upload Media: $err');
  });
  int mediaID = media['id'];  
}

Future Work

  1. Implementing OAuth 2.0 authentication.

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].