RCCWP_CustomWritePanel::GetCustomWritePanels PHP Method

GetCustomWritePanels() public static method

Get all Write Panels.
public static GetCustomWritePanels ( $include_global = FALSE ) : array
return array of objects containing all write panels. Each object contains id, name, description, display_order, capability_name, type, always_show
    public static function GetCustomWritePanels($include_global = FALSE)
    {
        global $wpdb;
        $sql = "SELECT id, name, description, display_order, capability_name, type, single  FROM " . MF_TABLE_PANELS;
        if (!$include_global) {
            // fix to exclude the global panel from general lists
            $sql .= " WHERE name <> '_Global' ";
        }
        $sql .= " ORDER BY display_order ASC";
        $results = $wpdb->get_results($sql);
        if (!isset($results)) {
            $results = array();
        }
        return $results;
    }

Usage Example

コード例 #1
0
function install()
{
    require_once dirname(__FILE__) . '/../magic-fields/RCCWP_CustomWritePanel.php';
    // Create default write pages
    $existing_write_panels = array();
    foreach (RCCWP_CustomWritePanel::GetCustomWritePanels() as $panel) {
        array_push($existing_write_panels, $panel->name);
    }
    $panels_dir_name = dirname(__FILE__) . '/panels/';
    $panels_dir = opendir($panels_dir_name);
    $panels = array();
    while (false !== ($panel_file = readdir($panels_dir))) {
        $panel_name = basename($panel_file, ".pnl");
        if (!is_dir($panel_file) && $panel_name && $panel_name != $panel_file && !in_array($panel_name, $existing_write_panels)) {
            // If this file isn't a directory, ends with .pnl, and isn't already an existing panel, create and store it for import.
            // $panel_id = RCCWP_CustomWritePanel::Create($panel_name, '', array(), array(), 1, "post", false);
            RCCWP_CustomWritePanel::Import($panels_dir_name . $panel_file);
            $panels[$panel_name] = $panel_file;
        }
    }
    foreach ($panels as $panel_name => $panel_file) {
        RCCWP_CustomWritePanel::Import($panels_dir_name . $panel_file, $panel_name, true);
    }
}
All Usage Examples Of RCCWP_CustomWritePanel::GetCustomWritePanels