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; }
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; }