Giter Club home page Giter Club logo

virtual-page's Introduction

Virtual Pages

Provides an interface for plugins to define virtual pages (ie, pages that are not part of WordPress's content stream).

Usage

To create a virtual page:

add_action( 'forkriver_virtual_page_init', 'my_virtual_page_creator' );
function my_virtual_page_creator() {
    if ( function_exists( '\forkriver\virtual_page\register_virtual_page' ) ) {
        \forkriver\virtual_page\register_virtual_page( array(
            'slug'        => 'desired-slug',  // required
            'title'       => 'My Page Title', // required
        ) );
    }
}

Filters

Filters exist for the virtual page's content, title, and template. In these filters, replace any slash characters (/) with __slash__. Eg., to target the virtual page at my-page/my-child-page, the $slug should be my-page__slash__my-child-page.

Content filtering:

add_filter( "fr_virtual_page_content_{$slug}", 'my_virtual_page_content' );
function my_virtual_page_content( $content ) {
    // Make changes to $content here.
    // If you want to use WP's automatic formatting, you need to explicitly add it:
    $content = wpautop( $content );
    return $content;
}

By default, the content is unset.

Title filtering:

add_filter( "fr_virtual_page_title_{$slug}", 'my_virtual_page_title' );
function my_virtual_page_title( $title ) {
    // Make changes to $title here.
    return $title;
}

By default, the title is the value of the title used in the \forkriver\virtual_page\register_virtual_page() call.

Template filtering:

add_filter( "fr_virtual_page_template_{$slug}", 'my_virtual_page_template' );
function my_virtual_page_template( $template ) {
    // Make changes to $template here.
    return $template;
}

By default, $template is page-{$slug}.php, page.php, or index.php in your active theme.

Todo

  • Implement show_in_nav and menu_order.
  • __() all the (text) things.

virtual-page's People

Contributors

pjohanneson avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.