コード例 #1
0
	/**
	 * Initialize Admin
	 */
	public function init() {
		// load text domain for translations
		load_plugin_textdomain( $this->domain, FALSE, dirname( plugin_basename( $this->plugin_file ) ) . '/lang/' );

		// set activation hook
		register_activation_hook( $this->plugin_file, array( $this, 'call_activation' ) );

		// set deactivation hook
		register_deactivation_hook( $this->plugin_file, array( $this, 'call_deactivation' ) );

		// set options for add_page_method
		$menu_pos = $this->form->set_current_option( 'screen' )->value( 'menu_position' );

		// init meta box page
		$this->meta_box_page->init(
			// settings
			array(
				'menu_title' => $this->__( 'External Links' ),
				'page_slug' => strtolower( $this->domain ),
				'add_page_method' => ( ! empty( $menu_pos ) AND $menu_pos != 'admin.php' ) ? 'add_submenu_page' : 'add_menu_page',
				'parent_slug' => ( ! empty( $menu_pos ) AND $menu_pos != 'admin.php' ) ? $menu_pos : NULL,
				'column_widths' => array(
					1 => array( 99 ),
					2 => array( 69, 29 ),
				),
				'icon_url' => plugins_url( 'images/icon-wp-external-links-16.png', $this->plugin_file ),
			),
			// load callback
			array( $this, 'call_load_meta_box' )
		);
	}
コード例 #2
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->check_version_update();
     // set meta box page
     $this->meta_box_page = new WP_Meta_Box_Page_01();
     // set ajax forms (also used by front-end)
     $this->form = new WP_Option_Forms_01(WP_EXTERNAL_LINKS_KEY, $this->save_options);
     self::$staticForm = $this->form;
     // init admin
     add_action('admin_init', array($this, 'admin_init'));
     if (is_admin()) {
         // set options for add_page_method
         $menu_pos = $this->form->set_current_option('screen')->value('menu_position');
         // init meta box page
         $this->meta_box_page->init(array('page_title' => $this->__('WP External Links'), 'menu_title' => $this->__('External Links'), 'page_slug' => strtolower(WP_EXTERNAL_LINKS_KEY), 'add_page_method' => (!empty($menu_pos) and $menu_pos != 'admin.php') ? 'add_submenu_page' : 'add_menu_page', 'parent_slug' => (!empty($menu_pos) and $menu_pos != 'admin.php') ? $menu_pos : NULL, 'column_widths' => array(1 => array(99), 2 => array(69, 29)), 'icon_url' => plugins_url('images/icon-wp-external-links-16.png', WP_EXTERNAL_LINKS_FILE)), array($this, 'call_load_meta_box'));
     }
 }