Tuesday, September 27, 2011

WP: Turn Off Comments / Ping Backs by Default from Pages

Turn Off Comments / Ping Backs by Default from Pages

Themes functions.php or yourplugin.php:

// This is valid hack as long as "wp-admin/includes/post.php"
// `get_default_post_to_edit()` keeps calling `apply_filter()` for 
// `default_content` *after* `comment_status` and `ping_status` setting.
function my_disable_pages_default_commenting($content, $post) {
    if ($post->post_type == 'page') {
        $post->comment_status = "closed";
        $post->ping_status = "closed";
    }

    return $content;
}
add_filter('default_content', 'my_disable_pages_default_commenting', 1, 2);

Snippet above turns off the check boxes only from New Pages, any existing pages must be unchecked manually.

Friday, September 23, 2011

Duplicate All Pages (in-place) in Acrobat X

This is just a small JavaScript extension to Acrobat X that allowes to Duplicate all pages in-place there exists another version which used extractPages and I didn't like that behavior so I wrote own.

First elevate privileges of the JavaScript programs:
  1. Right click on document, and choose "Page Display Preferences"
  2. Choose "JavaScript" from the left.
  3. Check the "Enable menu items JavaScript execution privileges".
Secondly save following snippet as duplicate.js to the %appdata%\Adobe\Acrobat\10.0\JavaScripts folder:
app.addMenuItem({
        cExec: "duplicatePagesInPlace();",
        cParent: "Edit",
        cName: "Duplicate all pages (in-place)"
});

function duplicatePagesInPlace() {
    var doc = this,
        pages = this.numPages;
    for (var i = pages - 1; i >= 0; i--) {
        doc.insertPages({ 
            cPath: doc.path, 
            nStart : i, 
            nEnd : i,
            nPage : i
        });
    }
}

Now you should be able to access the "Duplicate all pages (in-place)" under "Edit" menu item. If you can't see the item remember to restart Acrobat.