brian d foy > WordPress-Grep-0.010_003 > wpgrep

Download:
WordPress-Grep-0.010_003.tar.gz

Annotate this POD

Source  

NAME ^

wpgrep - Search through a WordPress database directly

SYNOPSIS ^

        # search by SQL pattern
        % wpgrep --host ... --user ... --like '%Amelia%'

        # search by Perl pattern
        % wpgrep --host ... --user ... --regex '\bAmelia(?!Foo)'

        # search by arbitrary code
        % wpgrep --host ... --user ... --code Some::Module::subroutine

        # or combine them
        % wpgrep --host ... --user ... --like '%Amelia%' \
                --regex '\bAmelia(?!Foo)' --code Some::Module::subroutine

        # include the categories or tags
        % wpgrep  ... --categories
        % wpgrep  ... --tags

        # specify a template for the results
        % wpgrep ... --template '%T'

DESCRIPTION ^

I wanted a tool for complex searches of WordPress posts in my own installations. This is it. I can search by an SQL pattern, a Perl regular expression, or a any code I care to run on the values.

If you specify --like, it limits the returned rows to those whose post_title or post_content match that argument.

If you specify --categories or --tags, the returned rows are annotated with relationship information. The categories and tags keys have array reference values with lists of term names. The terms keys is a hash with more term information. Dump it and inspect it if you want to play with it. Furthermore, the returned rows are reduced to the rows that have the specified categories if you give those options values.

If you specify --regex, it filters the returned rows to those whose post_title or post_content satisfy the regular expression.

If you specify --code, it filters the returned rows to those for which the subroutine reference returns true. The coderef gets a hash reference of the current row. It's up to you to decide what to do with it.

These filters are consecutive. You can specify any combination of them but they always happen in that order. The --regex only gets the rows that satisfied the --like, and the --code only gets the rows that satisfied --like and --regex.

Options

Template

Most template items map directly onto the columns from wp_posts.

TO DO ^

SEE ALSO ^

WordPress::API

SOURCE AVAILABILITY ^

This source is in Github:

        http://github.com/briandfoy/wordpress-grep/

AUTHOR ^

brian d foy, <bdfoy@gmail.com>

COPYRIGHT AND LICENSE ^

Copyright (c) 2013, brian d foy, All Rights Reserved.

You may redistribute this under the same terms as Perl itself.

syntax highlighting: