Plugin Directory

Changeset 2978062


Ignore:
Timestamp:
10/12/2023 10:58:26 AM (2 years ago)
Author:
appfulapp
Message:

New page content hook

Location:
appful-app
Files:
4 added
3 deleted
27 edited
243 copied

Legend:

Unmodified
Added
Removed
  • appful-app/tags/3.1.14/appful-app.php

    r2971246 r2978062  
    1212 * Plugin URI:        https://appful.io
    1313 * Description:       Appful® is the number 1 plugin for turning your WordPress Content into a native, beautiful app on iOS & Android in under 5 minutes.
    14  * Version:           3.1.13
     14 * Version:           3.1.14
    1515 * Requires at least: 5.8
    1616 * Requires PHP:      7.4
  • appful-app/tags/3.1.14/includes/api/Endpoints.php

    r2971184 r2978062  
    3838
    3939    public static string $HOOK = "/appful/api";
    40     public static string $CREATE_COMMENT = "create-comment";
    41     public static string $AUTHENTICATE_USER = "authenticate-user";
     40    public static string $CREATE_COMMENT_HOOK = "create-comment";
     41    public static string $AUTHENTICATE_USER_HOOK = "authenticate-user";
     42    public static string $GET_PAGE_CONTENT_HOOK = "get-page-content-hook";
    4243}
  • appful-app/tags/3.1.14/includes/api/ReqHandler.php

    r2971184 r2978062  
    2323use AppfulPlugin\Api\Handlers\InfoRequestHandler;
    2424use AppfulPlugin\Api\Handlers\LogRequestHandler;
     25use AppfulPlugin\Api\Handlers\Page\GetPageContentRequestHandler;
    2526use AppfulPlugin\Api\Handlers\PageSyncRequestHandler;
    2627use AppfulPlugin\Api\Handlers\PostSyncRequestHandler;
     
    7071            new GetPageContentsRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
    7172            new PullLocalPageContentRequestHandler( $use_case_manager->pages()->get_local_page_content_by_id_use_case() ),
     73            new GetPageContentRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
    7274        ];
    7375    }
  • appful-app/tags/3.1.14/includes/api/dtos/BlogHooksDto.php

    r2920040 r2978062  
    66    public ?string $create_comment;
    77    public ?string $authenticate_user;
     8    public ?string $get_page_content;
    89
    9     public function __construct( ?string $create_comment, ?string $authenticate_user ) {
     10    public function __construct(
     11        ?string $create_comment,
     12        ?string $authenticate_user,
     13        ?string $get_page_content
     14    ) {
    1015        $this->create_comment    = $create_comment;
    1116        $this->authenticate_user = $authenticate_user;
     17        $this->get_page_content  = $get_page_content;
    1218    }
    1319}
  • appful-app/tags/3.1.14/includes/api/dtos/BlogInfoDto.php

    r2920030 r2978062  
    99    public string $token;
    1010    public ?BlogHooksDto $hooks;
     11    public string $version;
    1112
    12     public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks ) {
     13    public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks, string $version ) {
    1314        $this->hostname  = $hostname;
    1415        $this->site_url  = $site_url;
    1516        $this->languages = $languages;
    16         $this->token   = $token;
     17        $this->token     = $token;
    1718        $this->hooks     = $hooks;
     19        $this->version   = $version;
    1820    }
    1921}
  • appful-app/tags/3.1.14/includes/api/handlers/AuthenticateUserRequestHandler.php

    r2920040 r2978062  
    2020
    2121    public function can_handle_request( PluginRequest $request ): bool {
    22         return $request->get_action() == Endpoints::$AUTHENTICATE_USER;
     22        return $request->get_action() == Endpoints::$AUTHENTICATE_USER_HOOK;
    2323    }
    2424
  • appful-app/tags/3.1.14/includes/api/handlers/CreateCommentRequestHandler.php

    r2954441 r2978062  
    2121
    2222    public function can_handle_request( PluginRequest $request ): bool {
    23         return $request->get_action() == Endpoints::$CREATE_COMMENT;
     23        return $request->get_action() == Endpoints::$CREATE_COMMENT_HOOK;
    2424    }
    2525
  • appful-app/tags/3.1.14/includes/api/handlers/InfoRequestHandler.php

    r2907312 r2978062  
    44
    55use AppfulPlugin\Api\Endpoints;
     6use AppfulPlugin\Api\Mapper\BlogInfoMapper;
    67use AppfulPlugin\Api\Requests\PluginRequest;
    78use AppfulPlugin\Api\Responses\PluginResponse;
     
    2324        Logger::log( "Found handler for Appful request" );
    2425
    25         $blog_info = $this->get_blog_info_use_case->invoke();
     26        $blog_info     = $this->get_blog_info_use_case->invoke();
     27        $blog_info_dto = BlogInfoMapper::to_dto( $blog_info );
    2628
    27         return PluginResponse::plugin_response()->body( $blog_info );
     29        return PluginResponse::plugin_response()->body( $blog_info_dto );
    2830    }
    2931}
  • appful-app/tags/3.1.14/includes/api/mapper/BlogHooksMapper.php

    r2920040 r2978062  
    1010        return new BlogHooksDto(
    1111            $blog_hooks->get_create_comment(),
    12             $blog_hooks->get_authenticate_user()
     12            $blog_hooks->get_authenticate_user(),
     13            $blog_hooks->get_get_page_content()
    1314        );
    1415    }
  • appful-app/tags/3.1.14/includes/api/mapper/BlogInfoMapper.php

    r2920030 r2978062  
    1313            $blog_info->get_languages(),
    1414            $blog_info->get_token(),
    15             BlogHooksMapper::to_dto( $blog_info->get_hooks() )
     15            BlogHooksMapper::to_dto( $blog_info->get_hooks() ),
     16            "3.1.14",
    1617        );
    1718    }
  • appful-app/tags/3.1.14/includes/domain/BlogHooks.php

    r2920040 r2978062  
    66    private ?string $create_comment = null;
    77    private ?string $authenticate_user = null;
     8    private ?string $get_page_content = null;
    89
    9     public static function blog_hooks(
    10         ?string $create_comment = null,
    11         ?string $authenticate_user = null
    12     ): BlogHooks {
    13         return ( new BlogHooks() )
    14             ->create_comment( $create_comment )
    15             ->authenticate_user( $authenticate_user );
     10    private function __construct() {
     11    }
     12
     13    public static function init(): BlogHooks {
     14        return new BlogHooks();
    1615    }
    1716
     
    2827    }
    2928
     29    public function get_page_content( ?string $get_page_content ): BlogHooks {
     30        $this->get_page_content = $get_page_content;
     31
     32        return $this;
     33    }
     34
    3035    public function get_create_comment(): ?string {
    3136        return $this->create_comment;
     
    3540        return $this->authenticate_user;
    3641    }
     42
     43    public function get_get_page_content(): ?string {
     44        return $this->get_page_content;
     45    }
    3746}
  • appful-app/tags/3.1.14/includes/domain/BlogInfo.php

    r2920030 r2978062  
    2222            ->languages( $languages )
    2323            ->token( $token )
    24             ->hooks( $hooks ?? new BlogHooks() );
     24            ->hooks( $hooks ?? BlogHooks::init() );
    2525    }
    2626
  • appful-app/tags/3.1.14/includes/use_cases/GetBlogInfoUseCase.php

    r2907312 r2978062  
    33namespace AppfulPlugin\UseCases;
    44
     5use AppfulPlugin\Domain\BlogInfo;
     6use AppfulPlugin\Wp\WPBlogManager;
     7
    58class GetBlogInfoUseCase {
    6     public function invoke(): array {
    7         return [ "status" => "OK" ];
     9    public function invoke(): BlogInfo {
     10        return WPBlogManager::get_blog_info();
    811    }
    912}
  • appful-app/tags/3.1.14/includes/use_cases/page/GetPageContentsByIdUseCase.php

    r2971184 r2978062  
    44
    55use AppfulPlugin\Domain\PageContent;
     6use AppfulPlugin\Wp\WPPageManager;
    67
    78class GetPageContentsByIdUseCase {
     
    2021        $page_contents = [];
    2122
    22         foreach ( $ids as $page_id ) {
    23             $response = $this->pull_local_page_content_use_case->invoke( $page_id, $user_id );
    24             if ( $response != null ) {
    25                 $page_contents[] = $response;
    26             }
    27         }
     23        $page_contents = WPPageManager::get_page_contents_by_ids($ids, $user_id);
     24//      Uncomment if for some reason fetching all pages at once should not work
     25//      foreach ( $ids as $page_id ) {
     26//          $response = $this->pull_local_page_content_use_case->invoke( $page_id, $user_id );
     27//          if ( $response != null ) {
     28//              $page_contents[] = $response;
     29//          }
     30//      }
    2831
    2932        return $page_contents;
  • appful-app/tags/3.1.14/includes/wp/WPAttachmentManager.php

    r2910521 r2978062  
    9494        $args = [
    9595            "post_type"   => "attachment",
     96            "include"     => $ids,
    9697            "numberposts" => - 1
    9798        ];
  • appful-app/tags/3.1.14/includes/wp/WPBlogManager.php

    r2920184 r2978062  
    2020
    2121    private static function get_hooks(): BlogHooks {
    22         return BlogHooks::blog_hooks()
    23                         ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT )
    24                         ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER );
     22        return BlogHooks::init()
     23                        ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT_HOOK )
     24                        ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER_HOOK )
     25                        ->get_page_content( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$GET_PAGE_CONTENT_HOOK );
    2526    }
    2627
  • appful-app/tags/3.1.14/includes/wp/WPPageManager.php

    r2971184 r2978062  
    8686
    8787        $wp_query = new \WP_Query( $args );
     88
     89        do_action( 'template_redirect' );
     90
    8891        if ( have_posts() ) {
    8992            the_post();
     
    118121    }
    119122
     123    public static function get_page_contents_by_ids( array $ids, ?int $user_id = null ): array {
     124        global $wp_query;
     125
     126        if ( $user_id ) {
     127            wp_set_current_user( $user_id );
     128        }
     129
     130        $args = [
     131            "posts_per_page" => - 1,
     132            "post_type"      => "page",
     133            "post__in"       => $ids,
     134            "post_status"    => self::get_allowed_page_stati()
     135        ];
     136
     137        $wp_query = new \WP_Query( $args );
     138
     139        do_action( 'template_redirect' );
     140
     141        $pages = [];
     142
     143        if ( have_posts() ) {
     144            ob_start();
     145            wp_head();
     146            $head = ob_get_clean();
     147
     148            ob_start();
     149            body_class();
     150            $body_class = ob_get_clean();
     151
     152            while ( have_posts() ) {
     153                the_post();
     154
     155                ob_start();
     156                the_content();
     157                $content = ob_get_clean();
     158
     159                $pages[] = PageContent::pageContent()
     160                                      ->id( get_the_ID() )
     161                                      ->content( $content )
     162                                      ->head( $head )
     163                                      ->footer( "" )
     164                                      ->body_class( $body_class );
     165            }
     166
     167            ob_start();
     168            wp_footer();
     169            $footer = ob_get_clean();
     170
     171            $pages = array_map( function ( PageContent $content ) use ( $footer ) {
     172                return $content->footer( $footer );
     173            }, $pages );
     174        }
     175
     176        wp_reset_postdata();
     177
     178        return $pages;
     179    }
     180
    120181    /**
    121182     * @return string[]
  • appful-app/tags/3.1.14/includes/wp/WPPostManager.php

    r2962811 r2978062  
    55use AppfulPlugin\Domain\Post;
    66use AppfulPlugin\Domain\PostContent;
    7 use AppfulPlugin\Domain\Role;
    8 use AppfulPlugin\Domain\UserRole;
    97use AppfulPlugin\Helper\Constants;
    108use AppfulPlugin\Wp\Mapper\PostMapper;
    119use AppfulPlugin\Wp\Plugins\LanguageHelper;
    12 use AppfulPlugin\Wp\Plugins\RoleHelper;
    1310use WP_Post;
    1411
     
    7067        $args = [
    7168            "numberposts" => - 1,
     69            "include"     => $ids,
    7270            "post_status" => self::get_allowed_post_stati()
    7371        ];
     
    9290        global $wp_query;
    9391
    94         do_action( 'template_redirect' );
    95 
    9692        $args = [
    9793            "posts_per_page" => 1,
     
    10298
    10399        $wp_query = new \WP_Query( $args );
     100
     101        do_action( 'template_redirect' );
     102
    104103        if ( have_posts() ) {
    105104            the_post();
  • appful-app/tags/3.1.14/lib/vendor/composer/autoload_classmap.php

    r2971234 r2978062  
    4848    'AppfulPlugin\\Api\\Handlers\\LogRequestHandler' => $baseDir . '/../includes/api/handlers/LogRequestHandler.php',
    4949    'AppfulPlugin\\Api\\Handlers\\PageSyncRequestHandler' => $baseDir . '/../includes/api/handlers/PageSyncRequestHandler.php',
     50    'AppfulPlugin\\Api\\Handlers\\Page\\GetPageContentRequestHandler' => $baseDir . '/../includes/api/handlers/page/GetPageContentRequestHandler.php',
    5051    'AppfulPlugin\\Api\\Handlers\\PostSyncRequestHandler' => $baseDir . '/../includes/api/handlers/PostSyncRequestHandler.php',
    5152    'AppfulPlugin\\Api\\Handlers\\PullLocalPageContentRequestHandler' => $baseDir . '/../includes/api/handlers/PullLocalPageContentRequestHandler.php',
  • appful-app/tags/3.1.14/lib/vendor/composer/autoload_psr4.php

    r2971246 r2978062  
    1010    'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
    1111    'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
    12     'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
     12    'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
    1313    'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
    1414    'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
     
    3131    'AppfulPlugin\\Api\\Requests\\' => array($baseDir . '/../includes/api/requests'),
    3232    'AppfulPlugin\\Api\\Mapper\\' => array($baseDir . '/../includes/api/mapper'),
     33    'AppfulPlugin\\Api\\Handlers\\Page\\' => array($baseDir . '/../includes/api/handlers/page'),
    3334    'AppfulPlugin\\Api\\Handlers\\' => array($baseDir . '/../includes/api/handlers'),
    3435    'AppfulPlugin\\Api\\Dtos\\' => array($baseDir . '/../includes/api/dtos'),
  • appful-app/tags/3.1.14/lib/vendor/composer/autoload_static.php

    r2971246 r2978062  
    5555            'AppfulPlugin\\Api\\Requests\\' => 26,
    5656            'AppfulPlugin\\Api\\Mapper\\' => 24,
     57            'AppfulPlugin\\Api\\Handlers\\Page\\' => 31,
    5758            'AppfulPlugin\\Api\\Handlers\\' => 26,
    5859            'AppfulPlugin\\Api\\Dtos\\' => 22,
     
    7778        'Psr\\Http\\Message\\' =>
    7879        array (
    79             0 => __DIR__ . '/..' . '/psr/http-message/src',
    80             1 => __DIR__ . '/..' . '/psr/http-factory/src',
     80            0 => __DIR__ . '/..' . '/psr/http-factory/src',
     81            1 => __DIR__ . '/..' . '/psr/http-message/src',
    8182        ),
    8283        'Psr\\Http\\Client\\' =>
     
    159160        array (
    160161            0 => __DIR__ . '/../..' . '/../includes/api/mapper',
     162        ),
     163        'AppfulPlugin\\Api\\Handlers\\Page\\' =>
     164        array (
     165            0 => __DIR__ . '/../..' . '/../includes/api/handlers/page',
    161166        ),
    162167        'AppfulPlugin\\Api\\Handlers\\' =>
     
    220225        'AppfulPlugin\\Api\\Handlers\\LogRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/LogRequestHandler.php',
    221226        'AppfulPlugin\\Api\\Handlers\\PageSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/PageSyncRequestHandler.php',
     227        'AppfulPlugin\\Api\\Handlers\\Page\\GetPageContentRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/page/GetPageContentRequestHandler.php',
    222228        'AppfulPlugin\\Api\\Handlers\\PostSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/PostSyncRequestHandler.php',
    223229        'AppfulPlugin\\Api\\Handlers\\PullLocalPageContentRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/PullLocalPageContentRequestHandler.php',
  • appful-app/tags/3.1.14/lib/vendor/composer/installed.php

    r2971246 r2978062  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => 'a41c8eaf59317be2933b3fc5141c44c0cd0052d1',
     6        'reference' => '2ba6b06d04004a7d391027374cc785e0853d4186',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => 'a41c8eaf59317be2933b3fc5141c44c0cd0052d1',
     16            'reference' => '2ba6b06d04004a7d391027374cc785e0853d4186',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • appful-app/tags/3.1.14/readme.txt

    r2971246 r2978062  
    66Tested up to: 6.3
    77Requires PHP: 7.4
    8 Stable tag: 3.1.13
     8Stable tag: 3.1.14
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • appful-app/trunk/appful-app.php

    r2971246 r2978062  
    1212 * Plugin URI:        https://appful.io
    1313 * Description:       Appful® is the number 1 plugin for turning your WordPress Content into a native, beautiful app on iOS & Android in under 5 minutes.
    14  * Version:           3.1.13
     14 * Version:           3.1.14
    1515 * Requires at least: 5.8
    1616 * Requires PHP:      7.4
  • appful-app/trunk/includes/api/Endpoints.php

    r2971184 r2978062  
    3838
    3939    public static string $HOOK = "/appful/api";
    40     public static string $CREATE_COMMENT = "create-comment";
    41     public static string $AUTHENTICATE_USER = "authenticate-user";
     40    public static string $CREATE_COMMENT_HOOK = "create-comment";
     41    public static string $AUTHENTICATE_USER_HOOK = "authenticate-user";
     42    public static string $GET_PAGE_CONTENT_HOOK = "get-page-content-hook";
    4243}
  • appful-app/trunk/includes/api/ReqHandler.php

    r2971184 r2978062  
    2323use AppfulPlugin\Api\Handlers\InfoRequestHandler;
    2424use AppfulPlugin\Api\Handlers\LogRequestHandler;
     25use AppfulPlugin\Api\Handlers\Page\GetPageContentRequestHandler;
    2526use AppfulPlugin\Api\Handlers\PageSyncRequestHandler;
    2627use AppfulPlugin\Api\Handlers\PostSyncRequestHandler;
     
    7071            new GetPageContentsRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
    7172            new PullLocalPageContentRequestHandler( $use_case_manager->pages()->get_local_page_content_by_id_use_case() ),
     73            new GetPageContentRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
    7274        ];
    7375    }
  • appful-app/trunk/includes/api/dtos/BlogHooksDto.php

    r2920040 r2978062  
    66    public ?string $create_comment;
    77    public ?string $authenticate_user;
     8    public ?string $get_page_content;
    89
    9     public function __construct( ?string $create_comment, ?string $authenticate_user ) {
     10    public function __construct(
     11        ?string $create_comment,
     12        ?string $authenticate_user,
     13        ?string $get_page_content
     14    ) {
    1015        $this->create_comment    = $create_comment;
    1116        $this->authenticate_user = $authenticate_user;
     17        $this->get_page_content  = $get_page_content;
    1218    }
    1319}
  • appful-app/trunk/includes/api/dtos/BlogInfoDto.php

    r2920030 r2978062  
    99    public string $token;
    1010    public ?BlogHooksDto $hooks;
     11    public string $version;
    1112
    12     public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks ) {
     13    public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks, string $version ) {
    1314        $this->hostname  = $hostname;
    1415        $this->site_url  = $site_url;
    1516        $this->languages = $languages;
    16         $this->token   = $token;
     17        $this->token     = $token;
    1718        $this->hooks     = $hooks;
     19        $this->version   = $version;
    1820    }
    1921}
  • appful-app/trunk/includes/api/handlers/AuthenticateUserRequestHandler.php

    r2920040 r2978062  
    2020
    2121    public function can_handle_request( PluginRequest $request ): bool {
    22         return $request->get_action() == Endpoints::$AUTHENTICATE_USER;
     22        return $request->get_action() == Endpoints::$AUTHENTICATE_USER_HOOK;
    2323    }
    2424
  • appful-app/trunk/includes/api/handlers/CreateCommentRequestHandler.php

    r2954441 r2978062  
    2121
    2222    public function can_handle_request( PluginRequest $request ): bool {
    23         return $request->get_action() == Endpoints::$CREATE_COMMENT;
     23        return $request->get_action() == Endpoints::$CREATE_COMMENT_HOOK;
    2424    }
    2525
  • appful-app/trunk/includes/api/handlers/InfoRequestHandler.php

    r2907312 r2978062  
    44
    55use AppfulPlugin\Api\Endpoints;
     6use AppfulPlugin\Api\Mapper\BlogInfoMapper;
    67use AppfulPlugin\Api\Requests\PluginRequest;
    78use AppfulPlugin\Api\Responses\PluginResponse;
     
    2324        Logger::log( "Found handler for Appful request" );
    2425
    25         $blog_info = $this->get_blog_info_use_case->invoke();
     26        $blog_info     = $this->get_blog_info_use_case->invoke();
     27        $blog_info_dto = BlogInfoMapper::to_dto( $blog_info );
    2628
    27         return PluginResponse::plugin_response()->body( $blog_info );
     29        return PluginResponse::plugin_response()->body( $blog_info_dto );
    2830    }
    2931}
  • appful-app/trunk/includes/api/mapper/BlogHooksMapper.php

    r2920040 r2978062  
    1010        return new BlogHooksDto(
    1111            $blog_hooks->get_create_comment(),
    12             $blog_hooks->get_authenticate_user()
     12            $blog_hooks->get_authenticate_user(),
     13            $blog_hooks->get_get_page_content()
    1314        );
    1415    }
  • appful-app/trunk/includes/api/mapper/BlogInfoMapper.php

    r2920030 r2978062  
    1313            $blog_info->get_languages(),
    1414            $blog_info->get_token(),
    15             BlogHooksMapper::to_dto( $blog_info->get_hooks() )
     15            BlogHooksMapper::to_dto( $blog_info->get_hooks() ),
     16            "3.1.14",
    1617        );
    1718    }
  • appful-app/trunk/includes/domain/BlogHooks.php

    r2920040 r2978062  
    66    private ?string $create_comment = null;
    77    private ?string $authenticate_user = null;
     8    private ?string $get_page_content = null;
    89
    9     public static function blog_hooks(
    10         ?string $create_comment = null,
    11         ?string $authenticate_user = null
    12     ): BlogHooks {
    13         return ( new BlogHooks() )
    14             ->create_comment( $create_comment )
    15             ->authenticate_user( $authenticate_user );
     10    private function __construct() {
     11    }
     12
     13    public static function init(): BlogHooks {
     14        return new BlogHooks();
    1615    }
    1716
     
    2827    }
    2928
     29    public function get_page_content( ?string $get_page_content ): BlogHooks {
     30        $this->get_page_content = $get_page_content;
     31
     32        return $this;
     33    }
     34
    3035    public function get_create_comment(): ?string {
    3136        return $this->create_comment;
     
    3540        return $this->authenticate_user;
    3641    }
     42
     43    public function get_get_page_content(): ?string {
     44        return $this->get_page_content;
     45    }
    3746}
  • appful-app/trunk/includes/domain/BlogInfo.php

    r2920030 r2978062  
    2222            ->languages( $languages )
    2323            ->token( $token )
    24             ->hooks( $hooks ?? new BlogHooks() );
     24            ->hooks( $hooks ?? BlogHooks::init() );
    2525    }
    2626
  • appful-app/trunk/includes/use_cases/GetBlogInfoUseCase.php

    r2907312 r2978062  
    33namespace AppfulPlugin\UseCases;
    44
     5use AppfulPlugin\Domain\BlogInfo;
     6use AppfulPlugin\Wp\WPBlogManager;
     7
    58class GetBlogInfoUseCase {
    6     public function invoke(): array {
    7         return [ "status" => "OK" ];
     9    public function invoke(): BlogInfo {
     10        return WPBlogManager::get_blog_info();
    811    }
    912}
  • appful-app/trunk/includes/use_cases/page/GetPageContentsByIdUseCase.php

    r2971184 r2978062  
    44
    55use AppfulPlugin\Domain\PageContent;
     6use AppfulPlugin\Wp\WPPageManager;
    67
    78class GetPageContentsByIdUseCase {
     
    2021        $page_contents = [];
    2122
    22         foreach ( $ids as $page_id ) {
    23             $response = $this->pull_local_page_content_use_case->invoke( $page_id, $user_id );
    24             if ( $response != null ) {
    25                 $page_contents[] = $response;
    26             }
    27         }
     23        $page_contents = WPPageManager::get_page_contents_by_ids($ids, $user_id);
     24//      Uncomment if for some reason fetching all pages at once should not work
     25//      foreach ( $ids as $page_id ) {
     26//          $response = $this->pull_local_page_content_use_case->invoke( $page_id, $user_id );
     27//          if ( $response != null ) {
     28//              $page_contents[] = $response;
     29//          }
     30//      }
    2831
    2932        return $page_contents;
  • appful-app/trunk/includes/wp/WPAttachmentManager.php

    r2910521 r2978062  
    9494        $args = [
    9595            "post_type"   => "attachment",
     96            "include"     => $ids,
    9697            "numberposts" => - 1
    9798        ];
  • appful-app/trunk/includes/wp/WPBlogManager.php

    r2920184 r2978062  
    2020
    2121    private static function get_hooks(): BlogHooks {
    22         return BlogHooks::blog_hooks()
    23                         ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT )
    24                         ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER );
     22        return BlogHooks::init()
     23                        ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT_HOOK )
     24                        ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER_HOOK )
     25                        ->get_page_content( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$GET_PAGE_CONTENT_HOOK );
    2526    }
    2627
  • appful-app/trunk/includes/wp/WPPageManager.php

    r2971184 r2978062  
    8686
    8787        $wp_query = new \WP_Query( $args );
     88
     89        do_action( 'template_redirect' );
     90
    8891        if ( have_posts() ) {
    8992            the_post();
     
    118121    }
    119122
     123    public static function get_page_contents_by_ids( array $ids, ?int $user_id = null ): array {
     124        global $wp_query;
     125
     126        if ( $user_id ) {
     127            wp_set_current_user( $user_id );
     128        }
     129
     130        $args = [
     131            "posts_per_page" => - 1,
     132            "post_type"      => "page",
     133            "post__in"       => $ids,
     134            "post_status"    => self::get_allowed_page_stati()
     135        ];
     136
     137        $wp_query = new \WP_Query( $args );
     138
     139        do_action( 'template_redirect' );
     140
     141        $pages = [];
     142
     143        if ( have_posts() ) {
     144            ob_start();
     145            wp_head();
     146            $head = ob_get_clean();
     147
     148            ob_start();
     149            body_class();
     150            $body_class = ob_get_clean();
     151
     152            while ( have_posts() ) {
     153                the_post();
     154
     155                ob_start();
     156                the_content();
     157                $content = ob_get_clean();
     158
     159                $pages[] = PageContent::pageContent()
     160                                      ->id( get_the_ID() )
     161                                      ->content( $content )
     162                                      ->head( $head )
     163                                      ->footer( "" )
     164                                      ->body_class( $body_class );
     165            }
     166
     167            ob_start();
     168            wp_footer();
     169            $footer = ob_get_clean();
     170
     171            $pages = array_map( function ( PageContent $content ) use ( $footer ) {
     172                return $content->footer( $footer );
     173            }, $pages );
     174        }
     175
     176        wp_reset_postdata();
     177
     178        return $pages;
     179    }
     180
    120181    /**
    121182     * @return string[]
  • appful-app/trunk/includes/wp/WPPostManager.php

    r2962811 r2978062  
    55use AppfulPlugin\Domain\Post;
    66use AppfulPlugin\Domain\PostContent;
    7 use AppfulPlugin\Domain\Role;
    8 use AppfulPlugin\Domain\UserRole;
    97use AppfulPlugin\Helper\Constants;
    108use AppfulPlugin\Wp\Mapper\PostMapper;
    119use AppfulPlugin\Wp\Plugins\LanguageHelper;
    12 use AppfulPlugin\Wp\Plugins\RoleHelper;
    1310use WP_Post;
    1411
     
    7067        $args = [
    7168            "numberposts" => - 1,
     69            "include"     => $ids,
    7270            "post_status" => self::get_allowed_post_stati()
    7371        ];
     
    9290        global $wp_query;
    9391
    94         do_action( 'template_redirect' );
    95 
    9692        $args = [
    9793            "posts_per_page" => 1,
     
    10298
    10399        $wp_query = new \WP_Query( $args );
     100
     101        do_action( 'template_redirect' );
     102
    104103        if ( have_posts() ) {
    105104            the_post();
  • appful-app/trunk/lib/vendor/composer/autoload_classmap.php

    r2971234 r2978062  
    4848    'AppfulPlugin\\Api\\Handlers\\LogRequestHandler' => $baseDir . '/../includes/api/handlers/LogRequestHandler.php',
    4949    'AppfulPlugin\\Api\\Handlers\\PageSyncRequestHandler' => $baseDir . '/../includes/api/handlers/PageSyncRequestHandler.php',
     50    'AppfulPlugin\\Api\\Handlers\\Page\\GetPageContentRequestHandler' => $baseDir . '/../includes/api/handlers/page/GetPageContentRequestHandler.php',
    5051    'AppfulPlugin\\Api\\Handlers\\PostSyncRequestHandler' => $baseDir . '/../includes/api/handlers/PostSyncRequestHandler.php',
    5152    'AppfulPlugin\\Api\\Handlers\\PullLocalPageContentRequestHandler' => $baseDir . '/../includes/api/handlers/PullLocalPageContentRequestHandler.php',
  • appful-app/trunk/lib/vendor/composer/autoload_psr4.php

    r2971246 r2978062  
    1010    'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
    1111    'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
    12     'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
     12    'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
    1313    'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
    1414    'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
     
    3131    'AppfulPlugin\\Api\\Requests\\' => array($baseDir . '/../includes/api/requests'),
    3232    'AppfulPlugin\\Api\\Mapper\\' => array($baseDir . '/../includes/api/mapper'),
     33    'AppfulPlugin\\Api\\Handlers\\Page\\' => array($baseDir . '/../includes/api/handlers/page'),
    3334    'AppfulPlugin\\Api\\Handlers\\' => array($baseDir . '/../includes/api/handlers'),
    3435    'AppfulPlugin\\Api\\Dtos\\' => array($baseDir . '/../includes/api/dtos'),
  • appful-app/trunk/lib/vendor/composer/autoload_static.php

    r2971246 r2978062  
    5555            'AppfulPlugin\\Api\\Requests\\' => 26,
    5656            'AppfulPlugin\\Api\\Mapper\\' => 24,
     57            'AppfulPlugin\\Api\\Handlers\\Page\\' => 31,
    5758            'AppfulPlugin\\Api\\Handlers\\' => 26,
    5859            'AppfulPlugin\\Api\\Dtos\\' => 22,
     
    7778        'Psr\\Http\\Message\\' =>
    7879        array (
    79             0 => __DIR__ . '/..' . '/psr/http-message/src',
    80             1 => __DIR__ . '/..' . '/psr/http-factory/src',
     80            0 => __DIR__ . '/..' . '/psr/http-factory/src',
     81            1 => __DIR__ . '/..' . '/psr/http-message/src',
    8182        ),
    8283        'Psr\\Http\\Client\\' =>
     
    159160        array (
    160161            0 => __DIR__ . '/../..' . '/../includes/api/mapper',
     162        ),
     163        'AppfulPlugin\\Api\\Handlers\\Page\\' =>
     164        array (
     165            0 => __DIR__ . '/../..' . '/../includes/api/handlers/page',
    161166        ),
    162167        'AppfulPlugin\\Api\\Handlers\\' =>
     
    220225        'AppfulPlugin\\Api\\Handlers\\LogRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/LogRequestHandler.php',
    221226        'AppfulPlugin\\Api\\Handlers\\PageSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/PageSyncRequestHandler.php',
     227        'AppfulPlugin\\Api\\Handlers\\Page\\GetPageContentRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/page/GetPageContentRequestHandler.php',
    222228        'AppfulPlugin\\Api\\Handlers\\PostSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/PostSyncRequestHandler.php',
    223229        'AppfulPlugin\\Api\\Handlers\\PullLocalPageContentRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/PullLocalPageContentRequestHandler.php',
  • appful-app/trunk/lib/vendor/composer/installed.php

    r2971246 r2978062  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => 'a41c8eaf59317be2933b3fc5141c44c0cd0052d1',
     6        'reference' => '2ba6b06d04004a7d391027374cc785e0853d4186',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => 'a41c8eaf59317be2933b3fc5141c44c0cd0052d1',
     16            'reference' => '2ba6b06d04004a7d391027374cc785e0853d4186',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • appful-app/trunk/readme.txt

    r2971246 r2978062  
    66Tested up to: 6.3
    77Requires PHP: 7.4
    8 Stable tag: 3.1.13
     8Stable tag: 3.1.14
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.