/** * Replace submitdiv(metabox) HTML * @param object $post */ function replace_submitdiv($post) { ob_start(); post_submit_meta_box($post); $buff = ob_get_clean(); if (preg_match('!(^.*)(<label for="visibility-radio-public")(.*)(<input type="radio" name="visibility" id="visibility-radio-password")(.*$)!is', $buff, $matches)) { $buff = sprintf('%s%s%s<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" %s tabindex="4" /> <label for="sticky" class="selectit">%s</label><br /></span>%s%s', $matches[1], $matches[2], $matches[3], checked(is_sticky($post->ID), true, false), __('Stick this post to the front page'), $matches[4], $matches[5]); } if (is_sticky($post->ID)) { $buff = preg_replace('!(<span id="post-visibility-display">)[^<]*(</span>)!is', sprintf('$1%s$2', __('Public, Sticky')), $buff); } echo $buff; }
public static function post_submit_meta_box($post) { @ob_start(); post_submit_meta_box($post); $out = @ob_get_contents(); @ob_end_clean(); $find = ' <label for="visibility-radio-public" class="selectit">' . translate('Public') . '</label><br />'; $replace = '<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" /> <label for="sticky" class="selectit">' . translate('Stick this post to the front page') . '</label><br /></span>'; $replace .= '<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" />'; echo str_replace($find, $find . $replace, $out); }
private function renderModifiedPublishBoxContent($post) { ob_start(); post_submit_meta_box($post); $html = ob_get_clean(); $doc = new \DOMDocument(); $doc->loadHTML($html); $element = $doc->getElementById('minor-publishing'); $element->removeChild($doc->getElementById('minor-publishing-actions')); $doc->getElementById('minor-publishing')->parentNode->removeChild($doc->getElementById('major-publishing-actions')); $element = $doc->getElementById('misc-publishing-actions'); $element->removeChild($doc->getElementById('visibility')); $element->removeChild($element->getElementsByTagName('div')->item(0)); echo $doc->saveHTML(); }