diff --git a/README.md b/README.md index be143dd..0519fd6 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Resources are uploaded to `/gw-resources/{HOME_URL}/`. If you'd like a friendlie If you have problems uploading resources, check the [Permissive Uploads](#permissive-uploads) section. -## API +## Node.js API For most projects, you should only need to specify the `wordpress` config and use the `wordpress-deploy` task (or its alias `deploy`). @@ -330,6 +330,26 @@ Synchronizes all resources in `path` to the WordPress site. * `path`: The directory containing resources to synchronize. * `callback` (`function( error )`): Callback to invoke after synchronizing all resources. +## PHP API + +### Constants + +#### GW_VERSION + +The installed version of grunt-wordpress. + +#### GW_RESOURCE_DIR + +The path to the resources directory for the current site. + +### Methods + +#### gw_resources_dir( url ) + +Gets the resources directory for a specific site. + +* `url`: The URL for the site. + ## Permissive Uploads Depending on what resources you're uploading, you may need to change some WordPress settings. diff --git a/grunt-wordpress.php b/grunt-wordpress.php index bdff054..aea7dee 100644 --- a/grunt-wordpress.php +++ b/grunt-wordpress.php @@ -7,8 +7,11 @@ define( 'GW_VERSION', '1.0.7' ); if ( ! defined( 'GW_RESOURCE_DIR' ) ) - define( 'GW_RESOURCE_DIR', dirname( WP_CONTENT_DIR ) . '/gw-resources/' . - preg_replace( '/^\w+:\/\//', '', home_url() ) ); + define( 'GW_RESOURCE_DIR', gw_resources_dir( home_url() ) ); + +function gw_resources_dir( $url ) { + return dirname( WP_CONTENT_DIR ) . '/gw-resources/' . preg_replace( '/^\w+:\/\//', '', $url ); +} function gw_get_version( $args ) { global $wp_xmlrpc_server;