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

Documentation for integrating and extending #125

Closed
wants to merge 25 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a0aa063
store storage post type in a public constant so that other plugins ca…
ashfame Nov 18, 2024
57e71bf
define Subject class & SubjectType enum
ashfame Nov 19, 2024
53791b1
announce via do_action when a subject is created or updated
ashfame Nov 21, 2024
b21b354
allow filtration of what post should be treated as the transformed ou…
ashfame Nov 21, 2024
f81da7b
use SubjectType enum in our Transformer class
ashfame Nov 21, 2024
a940117
remove post_type_for_transformed_post filter
ashfame Nov 21, 2024
f6f35be
remove skip_native_transformation filter
ashfame Nov 21, 2024
e487e3e
use our new hooks to run our own transformations instead of save_post…
ashfame Nov 21, 2024
330febb
store meta key used for storing reference to transformed output, as c…
ashfame Nov 21, 2024
26b3777
also store the back reference to liberation source
ashfame Nov 21, 2024
104035b
use SubType enum in Transformer class' tests
ashfame Nov 21, 2024
f134467
simplify get_post_type_for_transformed_post() in Transformer class
ashfame Nov 21, 2024
ab4bd18
tiny improvement in test
ashfame Nov 21, 2024
35b7c00
remove get_transformed_post_id() from Transformer class
ashfame Nov 21, 2024
1051aad
define SubjectRepo to loop over all liberated data
ashfame Nov 22, 2024
b9a96fa
add documentation
ashfame Nov 22, 2024
929b51a
change filter name for controlling preview
ashfame Nov 22, 2024
3b01813
add comment to code example in docs
ashfame Nov 22, 2024
7b4010f
correct grammar mistakes
ashfame Nov 22, 2024
2f6cb94
try relative urls in docs
ashfame Nov 22, 2024
7854b8b
fix url
ashfame Nov 22, 2024
60f2d0a
code alignment in code example
ashfame Nov 22, 2024
9a87303
add api to access transformed output via Subject class
ashfame Nov 22, 2024
c6a245d
abstract the act of storing references to Subject class
ashfame Nov 25, 2024
361343c
Merge pull request #127 from WordPress/feedback_abstract_relationship…
ashfame Dec 4, 2024
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
Prev Previous commit
Next Next commit
define SubjectRepo to loop over all liberated data
ashfame committed Nov 22, 2024
commit 1051aade2ee0625cfd4e83c14dfd3c792ec413bb
3 changes: 3 additions & 0 deletions src/plugin/class-engine.php
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ public function __construct() {
require 'class-page-controller.php';
require 'class-storage.php';
require 'class-subject.php';
require 'class-subject-repo.php';

( function () {
$transformer = new Transformer();
@@ -27,6 +28,8 @@ public function __construct() {
new Page_Controller( self::STORAGE_POST_TYPE );

new Storage( self::STORAGE_POST_TYPE );

Subject_Repo::init( self::STORAGE_POST_TYPE );
} )();
}
}
43 changes: 43 additions & 0 deletions src/plugin/class-subject-repo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace DotOrg\TryWordPress;

class Subject_Repo {
private static string $post_type;

public static function init( string $post_type ): void {
static::$post_type = $post_type;
}

/**
* Loops over all liberated_post posts for the specified subject_type
*
* @TODO: pagination support for large sites
*
* @param string $subject_type Type of subject.
* @return Subject[]
*/
public static function loop( string $subject_type ): array {
$args = array(
'post_type' => static::$post_type,
'post_status' => 'draft',
'posts_per_page' => -1,
);

if ( ! empty( $subject_type ) ) {
// @phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
$args['meta_query'] = array(
'key' => 'subject_type',
'value' => $subject_type,
'compare' => '=',
);
}

return array_map(
function ( $post ) {
return Subject::from_post( $post->ID );
},
get_posts( $args )
);
}
}