调用我创建类的文件

时间:2012-12-28 08:17:32

标签: wordpress class plugins

我有一个目录结构。

-Main
  -admin
   -admin.php
  -user
 myfile.php
admin.php中的

我有一个类名“createPost”。在那堂课里我写得像贝洛一样

<?php
// admin setting for wordpress

class wp_adminsettings {

  static $instance = false;


  private function __construct() {
    add_action( 'init', array( $this, 'wp_post_type' ) );
    .......................
    .......................
     hear i call all the add_action hook.
    .......................
    .......................
  }

    public static function getInstance() {
        if ( !self::$instance )
            self::$instance = new self;
        return self::$instance;
     }

然后我创建所有方法,如下面给出一个......

  public function wp_post_type {
    $plugin_url = plugins_url();
    $labels = array(
    'name'               => _x( 'Badges', 'post type general name' ),
    'singular_name'      => _x( 'Badge', 'post type singular name' ),
    'add_new'            => _x( 'Add New', 'book' ),
    'add_new_item'       => __( 'Add New Badge' ),
    'edit_item'          => __( 'Edit Badge' ),
    'new_item'           => __( 'New Badge' ),
    'all_items'          => __( 'Badges' ),
    'view_item'          => __( 'View Badge' ),
    'search_items'       => __( 'Search Badges' ),
    'not_found'          => __( 'No badges found' ),
    'not_found_in_trash' => __( 'No badges found in the Trash' ), 
    'parent_item_colon'  => '',
    'menu_name'          => 'Badges',
    );
    $args = array(
    'labels'        => $labels,
    'description'   => 'Holds our badges and badge specific data',
    'public'        => true,
    'menu_position' => 5,
    'supports'      => array( 'title', 'editor', 'thumbnail' ),
    'menu_icon' => plugins_url( '/images/badge.png', __FILE__ ),
    'has_archive'   => true,
    );
    register_post_type( 'badge', $args );   
  }

现在我在“admin.php”中的所有代码都创建了一个帖子类型。我想在“myfile.php”中调用该类。因为我想创建一个跟踪插件(创建自定义帖子类型)。那么如何在“myfile.php”中调用该类。所以我创建了一个自定义帖子类型。

0 个答案:

没有答案