Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include berlindb by autoloader #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions berlindb-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,9 @@
$plugin_dir = plugin_dir_path( __FILE__ );

/**
* REQUIRE BERLINDB FILES.
* For now, BerlinDB files are manually required.
* REQUIRE BERLINDB.
*/
require_once( $plugin_dir . 'core/base.php' );
require_once( $plugin_dir . 'core/column.php' );
require_once( $plugin_dir . 'core/meta.php' );
require_once( $plugin_dir . 'core/compare.php' );
require_once( $plugin_dir . 'core/date.php' );
require_once( $plugin_dir . 'core/query.php' );
require_once( $plugin_dir . 'core/row.php' );
require_once( $plugin_dir . 'core/schema.php' );
require_once( $plugin_dir . 'core/table.php' );
require_once( $plugin_dir . 'core/autoloader.php' );

/**
* BOOKS TABLE REQUIRED FILES.
Expand Down Expand Up @@ -167,6 +158,10 @@
* This example hooks into WordPress's the_content, but this could be done anywhere.
*/
add_filter( 'the_content', function ( $content ) {
if ( defined('REST_REQUEST') ) {
return $content;
}

$query = new Book_Query( [
'author' => 'J.K. Rowling', // Only get books written by J.K Rowling
'orderby' => 'date_published', // Sort the books by the date they were published
Expand All @@ -179,4 +174,4 @@
}

return $content;
} );
} );