2017 © Pedro Peláez
 

library wp-post-helper

image

megumi/wp-post-helper

  • Tuesday, December 23, 2014
  • by miya0001
  • Repository
  • 9 Watchers
  • 4 Stars
  • 705 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

megumi/wp-post-helper

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Helper class for the wp_insert_post(), (*2)

Installation

Create a composer.json in your project root., (*3)

{
    "require": {
        "megumi/wp-post-helper": "*"
    }
}

Documentation

Basic usage

$args = array(
    'post_name'    => 'slug',                  // slug
    'post_author'  => '1',                     // author's ID
    'post_date'    => '2012-11-15 20:00:00',   // post date and time
    'post_type'    => 'post',                 // post type (you can use custom post type)
    'post_status'  => 'publish',               // post status, publish, draft and so on
    'post_title'   => 'title',                 // post title
    'post_content' => 'content',               // post content
    'post_category'=> array( 1, 4 ),           // category IDs in an array
    'post_tags'    => array( 'tag1', 'tag2' ), // post tags in an array
);

$helper = new Megumi\WP\Post\Helper( $args );
$post_id = $helper->insert();

Attachements

$args = array(
    ...
);

$helper = new Megumi\WP\Post\Helper( $args );
$post_id = $helper->insert();

$attachment_id = $helper->add_media(
    'http://placehold.jp/100x100.png', // path or url
    'title',
    'description',
    'caption',
    false
);

Adding a value to a custom field

$args = array(
    ...
);

$helper = new Megumi\WP\Post\Helper( $args );
$post_id = $helper->insert();

$post->add_meta(
   'meta_key',  // meta key
   'meta_val',  // meta value
   true         // add it as unique (true) or not (false)
);

Aadding a value as a format of Advanced Custom Field

$args = array(
    ...
);

$helper = new Megumi\WP\Post\Helper( $args );
$post_id = $helper->insert();

$post->add_field(
   'field_xxxxxxxxxxxxx',   // key
   'field_val'          // value
);

Contributing

Clone this project., (*4)

$ git clone git@github.com:megumiteam/wp-post-helper.git

Run testing

Initialize the testing environment locally:, (*5)

(you'll need to already have mysql, svn and wget available), (*6)

$ bash bin/install-wp-tests.sh wordpress_test root '' localhost latest

Install phpunit., (*7)

$ composer install

The unit test files are in the tests/ directory., (*8)

To run the unit tests, just execute:, (*9)

$ phpunit

Issue

https://github.com/megumiteam/wp-post-helper/issues, (*10)

The Versions

23/12 2014

dev-stable

dev-stable

  Sources   Download

GPL2

The Requires

  • php >=5.3

 

by Wataru Okamoto

23/12 2014

0.5.0

0.5.0.0

  Sources   Download

GPL2

The Requires

  • php >=5.3

 

by Wataru Okamoto

23/12 2014

dev-master

9999999-dev

  Sources   Download

GPL2

The Requires

  • php >=5.3

 

by Wataru Okamoto

22/12 2014

0.4.0

0.4.0.0

  Sources   Download

GPL2

The Requires

  • php >=5.3

 

by Wataru Okamoto

22/12 2014

0.3.0

0.3.0.0

  Sources   Download

GPL2

The Requires

  • php >=5.3

 

by Wataru Okamoto

21/12 2014

0.2.0

0.2.0.0

  Sources   Download

GPL2

The Requires

  • php >=5.3

 

by Wataru Okamoto

12/12 2014

0.1.0

0.1.0.0

  Sources   Download

GPL2

The Requires

 

by Wataru Okamoto