wordpress_suite 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

WordPress Suite #

A Dart and Flutter package to interact with the WordPress Suite, like WooCommerce, LearnPress and etc. Welcome WordPress plugin authors, maintainers, fans to contribute!

Examples #

Use with care, some plugins may deprecated with concern!

Wordpress API open access as default, http://yourwordpress.com/wp-json

WordPress Authentication Method #

Application Passwords - Last updated: Jan 2020

https://wordpress.org/plugins/application-passwords/

Basic Authentication - Last updated: Dec 2017

https://github.com/WP-API/Basic-Auth

JSON Web Tokens - Last updated: 2019

https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/

Advanced Access Manager - Last updated May 2020

https://wordpress.org/plugins/advanced-access-manager/

[username] and [password] required for:
ApplicationPasswords, BasicAuthentication, 

WordPress GET request #

WordPress wp = WordPress(
    endpoint: Endpoint(
      address: 'https://yourwordpress.com',
    ),
    versionPath: "/wp/v2",
    method: AuthMethod.BasicAuthentication,
    username: 'username',
    password: 'password',
  );
  var users = await wp.get('/users');
  print(users);

WooCommerce GET request #

  WooCommerce wc = WooCommerce(
      endpoint: Endpoint(
        address: 'https://yourwordpress.com',
      ),
      versionPath: "/wc/v3",
      consumerKey: "ck_your_consumer_key",
      consumerSecret: "cs_your_consumer_secret");

  // Get data using the "products" endpoint
  var products = await wc.get("/products");
  print(products);

TODO #

  • Response schemas for WordPress and WooCommerce
  • Request schemas for WordPress and WooCommerce
  • Better error handling
  • Waiting LearnPress API documentation to release
  • Other WordPress's plugins, LearnDash

Issues #

Report any issues if you face any

Contributors #

Let's make it a WordPress Suite SDK !!!

#NameModule
0MeWordPress, WooCommerce

0.1.0 #

  • Noob version of RESTful API for WordPress, WooCommerce

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:wordpress_suite/wordpress.dart';
import 'package:wordpress_suite/woocommerce.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var products;
  var users;

  @override
  void initState() {
    init();
    super.initState();
  }

  void init() {
    // Initialize WordPress API
    WordPress wp = WordPress(
      endpoint: Endpoint(
        address: 'https://yourwordpress.com',
      ),
      versionPath: "/wp/v2",
      method: AuthMethod.BasicAuthentication,
      username: 'your_username',
      password: 'your_password',
    );
    setState(() async {
      users = await wp.get('/users');
    });

    // Initialize WooCommerce API
    WooCommerce wc = WooCommerce(
      endpoint: Endpoint(
        address: 'https://yourwordpress.com',
      ),
      versionPath: "/wc/v3",
      consumerKey: "ck_your_consumer_key",
      consumerSecret: "cs_your_consumer_secret",
    );

    setState(() async {
      products = await wc.get("/products");
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Text('$users\n\n$products'),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  wordpress_suite: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:wordpress_suite/constants.dart';
import 'package:wordpress_suite/endpoint.dart';
import 'package:wordpress_suite/error.dart';
import 'package:wordpress_suite/learnpress.dart';
import 'package:wordpress_suite/rest.dart';
import 'package:wordpress_suite/woocommerce.dart';
import 'package:wordpress_suite/wordpress.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [wordpress_suite] that is in a package requiring null.

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:wordpress_suite/learnpress.dartpackage:wordpress_suite/rest.dartdart:io

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
dio ^3.0.9 3.0.9
flutter 0.0.0
meta ^1.1.8 1.1.8
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
path 1.7.0
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test