admin管理员组

文章数量:1323529

Trying to write an OOP plugin, migrating from a script monkey plugin.

I need to create a number of pages of plugin activation, and have the following code:

  public function __construct()
  {
    global $wpdb;
    $this->tablename = $wpdb->prefix . 'arch_church_nominations';
    $this->activate();
  }

  public function activate()
  {
    $this->createTable();   // this works fine
    $this->createPages();
  }

  ...

  private function createPages()
  {
    require_once(ABSPATH . "wp-includes/pluggable.php");

    $nominationPost = array(
      'post_title'    => wp_strip_all_tags('Nominations'),
      'post_content'  => 'Nominations parent',
      'post_status'   => 'publish',
      'post_author'   => 1,
      'post_type'     => 'page',
    );

    // Insert the post into the database
    $this->$parentId = wp_insert_post($nominationPost);   // <-- this line
  }
}

$archChurchNominations = new ArchChurchNominations();

The noted line above if included causes the following error:

Notice: Trying to get property 'feeds' of non-object in /Users/[USERNAME]/Projects/wordpress/wp-includes/post.php on line 4482

However the exact same code snippet works fine, if not in an OOP plugin. What's wrong with my config please?

本文标签: Error on plugin activation and creating new page