RCCWP_CustomWritePanel::GetAssignedCategoryIds PHP Method

GetAssignedCategoryIds() public static method

Get a list of the ids of the categories assigned to a write panel
public static GetAssignedCategoryIds ( integer $customWritePanelId ) : array
$customWritePanelId integer write panel id
return array of ids
    public static function GetAssignedCategoryIds($customWritePanelId)
    {
        $results = RCCWP_CustomWritePanel::GetAssignedCategories($customWritePanelId);
        $ids = array();
        foreach ($results as $r) {
            $ids[] = $r->cat_id;
        }
        return $ids;
    }

Usage Example

 function ApplyCustomWritePanelAssignedCategories($content)
 {
     global $CUSTOM_WRITE_PANEL;
     global $post, $title;
     if ($post->post_type == "post") {
         $assignedCategoryIds = RCCWP_CustomWritePanel::GetAssignedCategoryIds($CUSTOM_WRITE_PANEL->id);
         if ($post->ID == 0) {
             foreach ($assignedCategoryIds as $categoryId) {
                 $toReplace = 'id="in-category-' . $categoryId . '"';
                 $replacement = $toReplace . ' checked="checked"';
                 $content = str_replace($toReplace, $replacement, $content);
             }
         }
     }
     if ($post->post_type == "page") {
         $customParentPage = RCCWP_CustomWritePanel::GetParentPage($CUSTOM_WRITE_PANEL->name);
         if ($customParentPage && $post->ID == 0) {
             $toReplace = 'value="' . $customParentPage . '"';
             $replacement = 'value="' . $customParentPage . '"' . ' SELECTED';
             $content = str_replace($toReplace, $replacement, $content);
         }
         $customThemePage = RCCWP_CustomWritePanel::GetThemePage($CUSTOM_WRITE_PANEL->name);
         //set default theme page
         if ($post->ID == 0) {
             $toReplace = "value='" . $customThemePage . "'";
             $replacement = "value='" . $customThemePage . "'" . ' SELECTED';
             $content = str_replace($toReplace, $replacement, $content);
         }
     }
     return $content;
 }
All Usage Examples Of RCCWP_CustomWritePanel::GetAssignedCategoryIds