• Stars
    star
    516
  • Rank 85,362 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

node.js client for WordPress

node-wordpress

A node.js JavaScript client for working with WordPress.

Support this project by donating on Gratipay.

Requires WordPress 3.4 or newer (uses the WordPress XML-RPC API).

Installation

npm install wordpress

Usage

var wordpress = require( "wordpress" );
var client = wordpress.createClient({
	url: "my-site.com",
	username: "admin",
	password: "secret"
});

client.getPosts(function( error, posts ) {
	console.log( "Found " + posts.length + " posts!" );
});

More usage examples can be found in the examples directory.

Full Site Synchronization

Looking for a way to manage your WordPress site without writing a bunch of code? Use Gilded WordPress to easily synchronize your entire site from a local directory.

API

Note: In order to provide a slightly nicer API, the XML-RPC field names have been mapped to CamelCase names. In some cases, the names are also altered because the original names are awkward. See the Fields section for a list of fields by type.

Client

wordpress.createClient( settings )

Creates a new client instance.

  • settings: A hash of settings that apply to all requests for the new client.
    • username: The username for the WordPress account.
    • password: The password for the WordPress account.
    • url: The URL for the WordPress install.
    • host (optional): The actual host to connect to if different from the URL, e.g., when deploying to a local server behind a firewall.
    • blogId (optional; default: 0): The blog ID for the WordPress install.
    • rejectUnauthorized (optional; default: true): A boolean indicating whether Node.js should automatically reject clients with invalid certificates. See tls.createSecurePair() in Node's documentation.
    • basicAuth (optional): An object holding HTTP basic authentication credentials.
      • username: The username for the HTTP basic auth.
      • password: The password for the HTTP basic auth.

wordpress.Client

The constructor used for client connections. Useful for creating extensions.

Posts

client.getPost( id [, fields], callback )

Gets a post by ID.

  • id: The ID of the post to get.
  • fields (optional): An array of fields to return.
  • callback (function( error, post )): A callback to invoke when the API call is complete.
    • post: An object containing the post data.

client.getPosts( [filter] [, fields], callback )

Gets all posts, optionally filtered.

  • filter (optional): A hash of key/value pairs for filtering which posts to get.
  • fields (optional): An array of fields to return.
  • callback (function( error, posts )): A callback to invoke when the API call is complete.
    • posts: An array containing the posts.

client.newPost( data, callback )

Creates a new post.

  • data: The data for the new post.
  • callback (function( error, id )): A callback to invoke when the API call is complete.
    • id: The ID of the new post.

client.editPost( id, data, callback )

Edits an existing post.

  • id: The ID of the post to edit.
  • data: The data to update on the post.
  • callback (function( error )): A callback to invoke when the API call is complete.

client.deletePost( id, callback )

Deletes a post.

NOTE: Deleting a post may move it to the trash and then deleting a second time will actually delete.

  • id: The ID of the post to delete.
  • callback (function( error )): A callback to invoke when the API call is complete.

client.getPostType( name, [, fields], callback )

Gets a post type by name.

  • name: The name of the post type to get.
  • fields (optional): An array of fields to return.
  • callback (function( error, postType )): A callback to invoke when the API call is complete.
    • postType: An object containing the post type data.

client.getPostTypes( [filter], [, fields], callback )

Gets all post types.

  • filter (optional): A hash of key/value pairs for filtering which posts types to get.
  • fields (optional): An array of fields to return.
  • callback (function( error, postTypes )): A callback to invoke when the API call is complete.
    • postTypes: An array containing the post types.

Taxonomies

client.getTaxonomy( name, callback )

Gets a taxonomy by name.

  • name: The name of the taxonomy to get.
  • callback (function( error, taxonomy )): A callback to invoke when the API call is complete.
    • taxonomy: An object containing the taxonomy data.

client.getTaxonomies( callback )

Gets all taxonomies.

  • callback (function( error, taxonomies )): A callback to invoke when the API call is complete.
    • taxonomies: An array containing the taxonomies.

client.getTerm( taxonomy, id, callback )

Gets a taxonomy term by ID.

  • taxonomy: The name fo the taxonomy the term belongs to.
  • id: The ID of the term to get.
  • callback (function( error, term )): A callback to invoke when the API call is complete.
    • term: An object containing the taxonomy term data.

client.getTerms( taxonomy [, fields], callback )

Gets all taxonomy terms.

  • taxonomy: The name fo the taxonomy the term belongs to.
  • fields (optional): An array of fields to return.
  • callback (function( error, terms )): A callback to invoke when the API call is complete.
    • terms: An array containing the taxonomy terms.

client.newTerm( data, callback )

Creates a new taxonomy term.

  • data: The data for the new taxonomy term.
  • callback (function( error, id )): A callback to invoke when the API call is complete.
    • id: The ID of the new taxonomy term.

client.editTerm( id, data, callback )

Edits an existing taxonomy term.

  • id: The ID of the taxonomy term to edit.
  • data: The data to update on the taxonomy.
  • callback (function( error )): A callback to invoke when the API call is complete.

client.deleteTerm( taxonomy, id, callback )

Deletes a taxonomy term.

  • taxonomy: The name fo the taxonomy the term belongs to.
  • id: The ID of the taxonomy term to delete.
  • callback (function( error )): A callback to invoke when the API call is complete.

Media

client.getMediaItem( id, callback )

Gets a piece of media by ID.

  • id: The ID of the piece of media to get.
  • callback (function( error, media ) ): A callback to invoke when the API call is complete.

client.getMediaLibrary( [filter], callback )

  • filter (optional): A hash of key/value pairs for filtering which posts to get.
  • callback (function( error, media ) ): A callback to invoke when the API call is complete.

client.uploadFile( data, callback )

Uploads a file to Wordpress.

  • data: The data for the file to upload.
    • name: The filename.
    • type: The file MIME type, e.g img/jpg.
    • bits: Binary data.
    • overwrite (optional): Whether this file should overwrite any existing file of the same name.
    • postId (optional): Which post to assign the attachment to.
  • callback (function( error, file )): A callback to invoke when the API call is complete.
    • file: An object containing the file data.

Utilities

client.listMethods( callback )

Gets a list of all avaialble methods.

  • callback (function( error, methods )): A callback to invoke when the API call is complete.
    • methods: An array of methods.

client.call( method [, args... ], callback )

Invokes a method.

  • method: The method to call.
  • args (optional): Arguments to pass to the method.
  • callback (function( error [, data] )): A callback to invoke when the API call is complete.
    • data: Data returned by the method.

client.authenticatedCall( method [, args... ], callback )

Invokes a method with the username and password provided by the client.

  • method: The method to call.
  • args (optional): Arguments to pass to the method.
  • callback (function( error [, data] )): A callback to invoke when the API call is complete.
  • data: Data returned by the method.

Fields

Files

  • name
  • type
  • bits
  • overwrite
  • postId

Labels

  • addNewItem
  • addOrRemoveItems
  • allItems
  • chooseFromMostUsed
  • editItem
  • menuName
  • name
  • nameAdminBar
  • newItemName
  • parentItem
  • parentItemColon
  • popularItems
  • searchItems
  • separateItemsWithCommas
  • singularName
  • updateItem
  • viewItem

Posts

  • author
  • commentStatus
  • content
  • customFields
  • date
  • excerpt
  • format
  • id
  • link
  • modified
  • menuOrder
  • name
  • pageTemplate
  • parent
  • password
  • pingStatus
  • status
  • sticky
  • terms
  • termNames
  • thumbnail
  • title
  • type

Post Types

  • cap
  • capabilityType
  • description
  • _editLink
  • excludeFromSearch
  • hasArchive
  • hierarchical
  • label
  • labels
  • mapMetaCap
  • menuIcon
  • menuPosition
  • name
  • "public
  • publiclyQuerably
  • queryVar
  • rewrite
  • showInAdminBar
  • showInMenu
  • showInNavMenus
  • showUi
  • supports
  • taxonomies

Post Type Capabilities

  • deleteOthersPosts
  • deletePost
  • deletePosts
  • deletePrivatePosts
  • deletePublishedPosts
  • editOthersPosts
  • editPost
  • editPosts
  • editPrivatePosts
  • editPublishedPosts
  • publishPosts
  • read
  • readPost
  • readPrivatePosts

Taxonomies

  • cap
  • hierarchical
  • name
  • label
  • labels
  • objectType
  • public
  • queryVar
  • rewrite
  • showInNavMenus
  • showTagCloud
  • showUi

Taxanomy Capabilities

  • assignTerms
  • deleteTerms
  • editTerms
  • manageTerms

Terms

  • count
  • description
  • name
  • parent
  • slug
  • taxonomy
  • termId
  • termTaxonomyId

Media

  • attachmentId
  • caption
  • date
  • description
  • link
  • metadata
    • file
    • height
    • imageMeta
      • aperture
      • camera
      • caption
      • copyright
      • createdTimestamp
      • credit
      • focalLength
      • iso
      • keywords
      • orientation
      • shutterSpeed
      • title
    • sizes
      • file
      • height
      • mimeType
      • width
    • width
  • parent
  • thumbnail
  • title
  • type

License

Copyright Scott González. Released under the terms of the MIT license.


Support this project by donating on Gratipay.

More Repositories

1

node-browserstack

node.js client for BrowserStack
JavaScript
215
star
2

pretty-diff

colorized HTML diffs
JavaScript
211
star
3

node-chat

Chat server built on node
JavaScript
188
star
4

jquery-ui-extensions

extensions to jQuery UI
JavaScript
170
star
5

grunt-wordpress

Grunt plugin for publishing content to WordPress
PHP
128
star
6

figlet-js

JavaScript parser for FIGlet fonts
JavaScript
118
star
7

recursive-blame

Recursive blame for Git
JavaScript
69
star
8

gilded-wordpress

Easily synchronize content between the file system and WordPress
JavaScript
53
star
9

sane-email-validation

Sanely validate email addresses, based on HTML5's definition of email addresses
JavaScript
37
star
10

node-git-tools

Tools for parsing data out of git repositories.
JavaScript
32
star
11

widget-factory-docs

32
star
12

node-github-notifier

Listen for GitHub updates using an EventEmitter.
JavaScript
18
star
13

grunt-git-authors

JavaScript
16
star
14

jquery-ui-1.8-widget-factory

Code sample showing the main changes between the widget factory in jQuery UI 1.7.2 and 1.8
JavaScript
12
star
15

frontend-masters-week-3

JavaScript
10
star
16

github-request

Low level helper for working with the GitHub API.
JavaScript
9
star
17

node-ircd

Node IRC
JavaScript
8
star
18

better-diff

The diff tool of the future
7
star
19

webchat

a full featured web chat built on node-chat
JavaScript
6
star
20

debt

DEBT: Exceptional Bug Tracking
JavaScript
5
star
21

blue-owl-core

Technical Official device integration for OWLCMS
TypeScript
4
star
22

temp-jquery-foo

JavaScript
4
star
23

web-icons

An investigation into the future of icons on the Web.
4
star
24

jquery-examples

example uses of jQuery
4
star
25

twitter-notify

Node app to display tweets in Growl notifications
JavaScript
4
star
26

connect-oauth-github

GitHub OAuth for Connect/Express
JavaScript
4
star
27

dev-test

feature, bug and performance tests
HTML
4
star
28

hookup

Easily configure GitHub web hooks.
JavaScript
3
star
29

jquery-data-replace

PHP
3
star
30

jquery-colorswatch

jQuery plugin for picking colors from color swatches
JavaScript
3
star
31

node-webkor

mini web framework built on Node.js
JavaScript
3
star
32

j5-shift-seven

Seven segment display controlled by a shift register
JavaScript
3
star
33

jquery-hijax

2
star
34

spawnback

Simplified process spawning with buffered output in a callback
JavaScript
2
star
35

regex-builder

JavaScript
2
star
36

temp-jquery-bar

JavaScript
2
star
37

changelogplease

JavaScript
2
star
38

node-growl

Growl module for node
JavaScript
2
star
39

node-http-extensions

extensions to node's http module
JavaScript
2
star
40

movie-manager

Manage your local movie collection
JavaScript
2
star
41

jquery-littles

Tiny plugins for jQuery
JavaScript
2
star
42

github-event-data

Payload samples for GitHub events available via web hooks
1
star
43

temp-test

JavaScript
1
star
44

gojira

A client for working with the JIRA REST API
1
star
45

es6-to-umd

JavaScript
1
star
46

dco

JavaScript
1
star
47

simple-game

JavaScript
1
star
48

dotnet-bundler

Script and style bundler for .NET
JavaScript
1
star
49

test-jquery-ui

JavaScript
1
star
50

grunt-test

JavaScript
1
star
51

j5-light-display

Customized light displays using Johnny-Five
JavaScript
1
star
52

implicit-pointer-capture

Chrome Extension to make all pointers have implicit capture
JavaScript
1
star
53

simple-log

JavaScript
1
star