RCCWP_CustomWritePanel::GetParentPage PHP Method

GetParentPage() public static method

Get the properties of a write panel
public static GetParentPage ( $customWritePanelName ) : an
return an object containing the properties of the write panel which are id, name, description, display_order, capability_name, type
    public static function GetParentPage($customWritePanelName)
    {
        global $wpdb;
        $sql = "SELECT meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = 'p_" . $customWritePanelName . "' AND post_id = 0";
        $sql = $wpdb->prepare("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id = 0", array("p_" . $customWritePanelName));
        $results = $wpdb->get_row($sql);
        if ($results) {
            return $results->meta_value;
        }
        return FALSE;
    }

Usage Example

コード例 #1
0
 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::GetParentPage