Plugin Directory

Changeset 3039311


Ignore:
Timestamp:
02/21/2024 03:52:07 PM (2 years ago)
Author:
appfulapp
Message:

Add support for remote, dynamic post sync batch size configuration

Location:
appful-app
Files:
8 added
7 deleted
21 edited
299 copied

Legend:

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

    r3028218 r3039311  
    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.21
     14 * Version:           3.1.22
    1515 * Requires at least: 5.8
    1616 * Requires PHP:      7.4
  • appful-app/tags/3.1.22/includes/api/Endpoints.php

    r2978062 r3039311  
    44
    55class Endpoints {
    6     public static string $INFO = "info";
    7     public static string $LOGS = "logs";
     6    public static string $INFO = "info";
     7    public static string $LOGS = "logs";
    88
    9     public static string $CLEAR_LOGS = "clear-logs";
     9    public static string $SAVE_POST_SYNC_BATCH_SIZE = "save-post-sync-batch-size";
    1010
    11     public static string $SYNC = "sync";
    12     public static string $SYNC_POSTS = "sync-post";
     11    public static string $CLEAR_LOGS = "clear-logs";
    1312
    14     public static string $SYNC_PAGES = "sync-page";
    15     public static string $SYNC_COMMENTS = "sync-comment";
    16     public static string $SYNC_TAGS = "sync-tag";
    17     public static string $SYNC_ROLES = "sync-role";
    18     public static string $SYNC_USERS = "sync-user";
    19     public static string $SYNC_ATTACHMENTS = "sync-attachment";
    20     public static string $SYNC_CATEGORIES = "sync-category";
     13    public static string $SYNC = "sync";
     14    public static string $SYNC_POSTS = "sync-post";
    2115
    22     public static string $GET_ATTACHMENTS = "get-attachment";
    23     public static string $GET_COMMENTS = "get-comment";
    24     public static string $GET_CATEGORIES = "get-category";
    25     public static string $GET_POSTS = "get-post";
    26     public static string $GET_PAGES = "get-page";
    27     public static string $GET_POST_CONTENTS = "get-post-content";
    28     public static string $GET_PAGE_CONTENTS = "get-page-content";
    29     public static string $GET_POST_CONTENT_LOCAL = "get-post-content-local";
    30     public static string $GET_PAGE_CONTENT_LOCAL = "get-page-content-local";
    31     public static string $GET_USERS = "get-user";
    32     public static string $GET_TAGS = "get-tag";
    33     public static string $GET_ROLES = "get-role";
     16    public static string $SYNC_PAGES = "sync-page";
     17    public static string $SYNC_COMMENTS = "sync-comment";
     18    public static string $SYNC_TAGS = "sync-tag";
     19    public static string $SYNC_ROLES = "sync-role";
     20    public static string $SYNC_USERS = "sync-user";
     21    public static string $SYNC_ATTACHMENTS = "sync-attachment";
     22    public static string $SYNC_CATEGORIES = "sync-category";
    3423
    35     public static string $ASSET_LINKS = "android-asset-links";
    36     public static string $SITE_ASSOCIATION = "apple-app-site-association";
     24    public static string $GET_ATTACHMENTS = "get-attachment";
     25    public static string $GET_COMMENTS = "get-comment";
     26    public static string $GET_CATEGORIES = "get-category";
     27    public static string $GET_POSTS = "get-post";
     28    public static string $GET_PAGES = "get-page";
     29    public static string $GET_POST_CONTENTS = "get-post-content";
     30    public static string $GET_PAGE_CONTENTS = "get-page-content";
     31    public static string $GET_POST_CONTENT_LOCAL = "get-post-content-local";
     32    public static string $GET_PAGE_CONTENT_LOCAL = "get-page-content-local";
     33    public static string $GET_USERS = "get-user";
     34    public static string $GET_TAGS = "get-tag";
     35    public static string $GET_ROLES = "get-role";
     36
     37    public static string $ASSET_LINKS = "android-asset-links";
     38    public static string $SITE_ASSOCIATION = "apple-app-site-association";
    3739
    3840
    39     public static string $HOOK = "/appful/api";
    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";
     41    public static string $HOOK = "/appful/api";
     42    public static string $CREATE_COMMENT_HOOK = "create-comment";
     43    public static string $AUTHENTICATE_USER_HOOK = "authenticate-user";
     44    public static string $GET_PAGE_CONTENT_HOOK = "get-page-content-hook";
    4345}
  • appful-app/tags/3.1.22/includes/api/ReqHandler.php

    r3027388 r3039311  
    3030use AppfulPlugin\Api\Handlers\RequestHandler;
    3131use AppfulPlugin\Api\Handlers\RoleSyncRequestHandler;
     32use AppfulPlugin\Api\Handlers\SavePostSyncBatchSizeHandler;
    3233use AppfulPlugin\Api\Handlers\SyncRequestHandler;
    3334use AppfulPlugin\Api\Handlers\TagSyncRequestHandler;
     
    3940
    4041class ReqHandler {
    41     private array $request_handlers;
     42    private array $request_handlers;
    4243
    43     public function __construct( UseCaseManager $use_case_manager ) {
    44         $this->request_handlers = [
    45             new AndroidAssetLinkRequestHandler( $use_case_manager->get_android_asset_link_use_case() ),
    46             new AppleAppSiteAssociationRequestHandler( $use_case_manager->get_apple_app_site_association_use_case() ),
    47             new LogRequestHandler( $use_case_manager->get_logs_use_case() ),
    48             new InfoRequestHandler( $use_case_manager->get_blog_info_use_case() ),
    49             new PostSyncRequestHandler( $use_case_manager->posts()->get_sync_posts_use_case() ),
    50             new GetPostsRequestHandler( $use_case_manager->get_posts_by_id_use_case() ),
    51             new CategorySyncRequestHandler( $use_case_manager->sync_categories_use_case() ),
    52             new GetCategoriesRequestHandler( $use_case_manager->get_categories_by_id_use_case() ),
    53             new TagSyncRequestHandler( $use_case_manager->sync_tags_use_case() ),
    54             new GetTagsRequestHandler( $use_case_manager->get_tags_by_id_use_case() ),
    55             new GetAttachmentsRequestHandler( $use_case_manager->get_attachments_by_id_use_case() ),
    56             new AttachmentSyncRequestHandler( $use_case_manager->sync_attachments_use_case() ),
    57             new SyncRequestHandler( $use_case_manager->sync_all_use_case() ),
    58             new GetCommentsRequestHandler( $use_case_manager->get_comments_by_id_use_case() ),
    59             new CommentSyncRequestHandler( $use_case_manager->sync_comments_use_case() ),
    60             new UserSyncRequestHandler( $use_case_manager->sync_users_use_case() ),
    61             new GetUsersRequestHandler( $use_case_manager->get_users_by_id_use_case() ),
    62             new GetPostContentsRequestHandler( $use_case_manager->get_post_contents_by_id_use_case() ),
    63             new ClearLogRequestHandler( $use_case_manager->get_clear_logs_use_case() ),
    64             new AuthenticateUserRequestHandler( $use_case_manager->get_authenticate_user_use_case() ),
    65             new PullLocalPostContentRequestHandler( $use_case_manager->get_get_local_post_content_by_id_use_case() ),
    66             new CreateCommentRequestHandler( $use_case_manager->create_comment_use_case() ),
    67             new GetRolesRequestHandler( $use_case_manager->get_roles_by_id_use_case() ),
    68             new RoleSyncRequestHandler( $use_case_manager->sync_roles_use_case() ),
    69             new GetPagesRequestHandler( $use_case_manager->get_pages_by_id_use_case() ),
    70             new PageSyncRequestHandler( $use_case_manager->sync_pages_use_case() ),
    71             new GetPageContentsRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
    72             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() ),
    74         ];
    75     }
     44    public function __construct( UseCaseManager $use_case_manager ) {
     45        $this->request_handlers = [
     46            new AndroidAssetLinkRequestHandler( $use_case_manager->get_android_asset_link_use_case() ),
     47            new AppleAppSiteAssociationRequestHandler( $use_case_manager->get_apple_app_site_association_use_case() ),
     48            new LogRequestHandler( $use_case_manager->get_logs_use_case() ),
     49            new InfoRequestHandler( $use_case_manager->get_blog_info_use_case() ),
     50            new PostSyncRequestHandler( $use_case_manager->posts()->get_sync_posts_use_case() ),
     51            new GetPostsRequestHandler( $use_case_manager->get_posts_by_id_use_case() ),
     52            new CategorySyncRequestHandler( $use_case_manager->sync_categories_use_case() ),
     53            new GetCategoriesRequestHandler( $use_case_manager->get_categories_by_id_use_case() ),
     54            new TagSyncRequestHandler( $use_case_manager->sync_tags_use_case() ),
     55            new GetTagsRequestHandler( $use_case_manager->get_tags_by_id_use_case() ),
     56            new GetAttachmentsRequestHandler( $use_case_manager->get_attachments_by_id_use_case() ),
     57            new AttachmentSyncRequestHandler( $use_case_manager->sync_attachments_use_case() ),
     58            new SyncRequestHandler( $use_case_manager->sync_all_use_case() ),
     59            new GetCommentsRequestHandler( $use_case_manager->get_comments_by_id_use_case() ),
     60            new CommentSyncRequestHandler( $use_case_manager->sync_comments_use_case() ),
     61            new UserSyncRequestHandler( $use_case_manager->sync_users_use_case() ),
     62            new GetUsersRequestHandler( $use_case_manager->get_users_by_id_use_case() ),
     63            new GetPostContentsRequestHandler( $use_case_manager->get_post_contents_by_id_use_case() ),
     64            new ClearLogRequestHandler( $use_case_manager->get_clear_logs_use_case() ),
     65            new AuthenticateUserRequestHandler( $use_case_manager->get_authenticate_user_use_case() ),
     66            new PullLocalPostContentRequestHandler( $use_case_manager->get_get_local_post_content_by_id_use_case() ),
     67            new CreateCommentRequestHandler( $use_case_manager->create_comment_use_case() ),
     68            new GetRolesRequestHandler( $use_case_manager->get_roles_by_id_use_case() ),
     69            new RoleSyncRequestHandler( $use_case_manager->sync_roles_use_case() ),
     70            new GetPagesRequestHandler( $use_case_manager->get_pages_by_id_use_case() ),
     71            new PageSyncRequestHandler( $use_case_manager->sync_pages_use_case() ),
     72            new GetPageContentsRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
     73            new PullLocalPageContentRequestHandler( $use_case_manager->pages()->get_local_page_content_by_id_use_case() ),
     74            new GetPageContentRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
     75            new SavePostSyncBatchSizeHandler( $use_case_manager->posts()->get_save_post_sync_batch_size_use_case() )
     76        ];
     77    }
    7678
    77     public function handle_request( PluginRequest $request ): PluginResponse {
    78         foreach ( $this->request_handlers as $request_handler ) {
    79             if ( $request_handler instanceof RequestHandler ) {
    80                 if ( $request_handler->can_handle_request( $request ) ) {
    81                     return $request_handler->handle_request( $request );
    82                 }
    83             }
    84         }
     79    public function handle_request( PluginRequest $request ): PluginResponse {
     80        foreach ( $this->request_handlers as $request_handler ) {
     81            if ( $request_handler instanceof RequestHandler ) {
     82                if ( $request_handler->can_handle_request( $request ) ) {
     83                    return $request_handler->handle_request( $request );
     84                }
     85            }
     86        }
    8587
    86         Logger::error( "Did not find handler for action: " . $request->get_action() );
     88        Logger::error( "Did not find handler for action: " . $request->get_action() );
    8789
    88         return PluginResponse::plugin_response()->status( 404 );
    89     }
     90        return PluginResponse::plugin_response()->status( 404 );
     91    }
    9092}
  • appful-app/tags/3.1.22/includes/api/dtos/BlogHooksDto.php

    r2978062 r3039311  
    44
    55class BlogHooksDto {
    6     public ?string $create_comment;
    7     public ?string $authenticate_user;
    8     public ?string $get_page_content;
     6    public ?string $create_comment;
     7    public ?string $authenticate_user;
     8    public ?string $get_page_content;
    99
    10     public function __construct(
    11         ?string $create_comment,
    12         ?string $authenticate_user,
    13         ?string $get_page_content
    14     ) {
    15         $this->create_comment    = $create_comment;
    16         $this->authenticate_user = $authenticate_user;
    17         $this->get_page_content  = $get_page_content;
    18     }
     10    public function __construct(
     11        ?string $create_comment,
     12        ?string $authenticate_user,
     13        ?string $get_page_content
     14    ) {
     15        $this->create_comment    = $create_comment;
     16        $this->authenticate_user = $authenticate_user;
     17        $this->get_page_content  = $get_page_content;
     18    }
    1919}
  • appful-app/tags/3.1.22/includes/api/dtos/BlogInfoDto.php

    r3019874 r3039311  
    44
    55class BlogInfoDto {
    6     public string $hostname;
    7     public string $site_url;
    8     public array $languages;
    9     public string $token;
    10     public ?BlogHooksDto $hooks;
    11     public string $version;
    12     public ?BlogStatsDto $stats;
     6    public string $hostname;
     7    public string $site_url;
     8    public array $languages;
     9    public string $token;
     10    public ?BlogHooksDto $hooks;
     11    public string $version;
     12    public ?BlogStatsDto $stats;
     13    public ?BlogSettingsDto $settings;
    1314
    14     public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks, string $version, ?BlogStatsDto $stats ) {
    15         $this->hostname  = $hostname;
    16         $this->site_url  = $site_url;
    17         $this->languages = $languages;
    18         $this->token     = $token;
    19         $this->hooks     = $hooks;
    20         $this->version   = $version;
    21         $this->stats     = $stats;
    22     }
     15    public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks, string $version, ?BlogStatsDto $stats, ?BlogSettingsDto $settings ) {
     16        $this->hostname  = $hostname;
     17        $this->site_url  = $site_url;
     18        $this->languages = $languages;
     19        $this->token     = $token;
     20        $this->hooks     = $hooks;
     21        $this->version   = $version;
     22        $this->stats     = $stats;
     23        $this->settings  = $settings;
     24    }
    2325}
  • appful-app/tags/3.1.22/includes/api/handlers/CreateCommentRequestHandler.php

    r3018629 r3039311  
    1212
    1313class CreateCommentRequestHandler implements RequestHandler {
    14     private CreateCommentUseCase $create_comment_use_case;
     14    private CreateCommentUseCase $create_comment_use_case;
    1515
    16     public function __construct(
     16    public function __construct(
    1717        CreateCommentUseCase $create_comment_use_case
    18     ) {
    19         $this->create_comment_use_case = $create_comment_use_case;
    20     }
     18    ) {
     19        $this->create_comment_use_case = $create_comment_use_case;
     20    }
    2121
    22     public function can_handle_request( PluginRequest $request ): bool {
    23         return $request->get_action() == Endpoints::$CREATE_COMMENT_HOOK;
    24     }
     22    public function can_handle_request( PluginRequest $request ): bool {
     23        return $request->get_action() == Endpoints::$CREATE_COMMENT_HOOK;
     24    }
    2525
    2626    public function handle_request( PluginRequest $request ): PluginResponse {
     
    3131
    3232        // required fields
    33         if (!isset($data["username"], $data["email"], $data["content"], $data["post_id"])) {
     33        if ( ! isset( $data["username"], $data["email"], $data["content"], $data["post_id"] ) ) {
    3434            Logger::error( "Some parameters for create comment are missing" );
     35
    3536            return PluginResponse::plugin_response()->status( 400 );  // Bad Request
    3637        }
    3738
    3839        // sanitize fields
    39         $username  = sanitize_text_field( $data["username"] );
    40         $email     = sanitize_text_field( $data["email"] );
    41         $content   = sanitize_text_field( $data["content"] );
    42         $post_id   = intval($data["post_id"]);
     40        $username = sanitize_text_field( $data["username"] );
     41        $email    = sanitize_text_field( $data["email"] );
     42        $content  = sanitize_text_field( $data["content"] );
     43        $post_id  = intval( $data["post_id"] );
    4344
    4445        // optional field
    45         $parent_id = isset($data["parent_id"]) ? intval($data["parent_id"]) : null;
     46        $parent_id = isset( $data["parent_id"] ) ? intval( $data["parent_id"] ) : null;
    4647
    4748        $request = new CreateCommentRequest( $username, $email, $content, $post_id, $parent_id );
     
    5051        if ( $comment == null ) {
    5152            Logger::error( "Creating comment failed" );
     53
    5254            return PluginResponse::plugin_response()->status( 503 );
    5355        }
    5456
    55         $comment_dto = CommentMapper::to_dto($comment);
     57        $comment_dto = CommentMapper::to_dto( $comment );
    5658
    5759        return PluginResponse::plugin_response()->body( $comment_dto );
  • appful-app/tags/3.1.22/includes/api/handlers/GetPostContentsRequestHandler.php

    r3018629 r3039311  
    1212
    1313class GetPostContentsRequestHandler implements RequestHandler {
    14     private GetPostContentsByIdUseCase $get_post_contents_by_id_use_case;
     14    private GetPostContentsByIdUseCase $get_post_contents_by_id_use_case;
    1515
    16     public function __construct(
    17         GetPostContentsByIdUseCase $get_post_contents_by_id_use_case
    18     ) {
    19         $this->get_post_contents_by_id_use_case = $get_post_contents_by_id_use_case;
    20     }
     16    public function __construct(
     17        GetPostContentsByIdUseCase $get_post_contents_by_id_use_case
     18    ) {
     19        $this->get_post_contents_by_id_use_case = $get_post_contents_by_id_use_case;
     20    }
    2121
    22     public function can_handle_request( PluginRequest $request ): bool {
    23         return $request->get_action() == Endpoints::$GET_POST_CONTENTS;
    24     }
     22    public function can_handle_request( PluginRequest $request ): bool {
     23        return $request->get_action() == Endpoints::$GET_POST_CONTENTS;
     24    }
    2525
    26     public function handle_request( PluginRequest $request ): PluginResponse {
    27         Logger::debug( "Found handler for Appful request" );
     26    public function handle_request( PluginRequest $request ): PluginResponse {
     27        Logger::debug( "Found handler for Appful request" );
    2828
    29         // Because there could be a huge amount of posts, increase the timeout to 10min
    30         set_time_limit( 60 * 10 );
     29        // Because there could be a huge amount of posts, increase the timeout to 10min
     30        set_time_limit( 60 * 10 );
    3131
    32         if ( ! isset( $_GET['ids'] ) ) {
    33             return PluginResponse::plugin_response()->status( 400 );
    34         }
     32        if ( ! isset( $_GET['ids'] ) ) {
     33            return PluginResponse::plugin_response()->status( 400 );
     34        }
    3535
    36         $cleanedIds = sanitize_text_field( $_GET['ids'] );
    37         $ids        = array_map(
    38             function ( $id ) {
    39                 return absint( $id );
    40             },
    41             explode( ",", $cleanedIds )
    42         );
     36        $cleanedIds = sanitize_text_field( $_GET['ids'] );
     37        $ids        = array_map(
     38            function ( $id ) {
     39                return absint( $id );
     40            },
     41            explode( ",", $cleanedIds )
     42        );
    4343
    44         Logger::debug( "Sending post contents for ids " . json_encode( $ids ) );
     44        Logger::debug( "Sending post contents for ids " . json_encode( $ids ) );
    4545
    46         $postContents = $this->get_post_contents_by_id_use_case->invoke( $ids );
     46        $postContents = $this->get_post_contents_by_id_use_case->invoke( $ids );
    4747
    48         $post_content_dtos = array_map(
    49             function ( PostContent $post_content ) {
    50                 return PostContentMapper::to_dto( $post_content );
    51             },
    52             $postContents
    53         );
     48        $post_content_dtos = array_map(
     49            function ( PostContent $post_content ) {
     50                return PostContentMapper::to_dto( $post_content );
     51            },
     52            $postContents
     53        );
    5454
    55         return PluginResponse::plugin_response()->body( $post_content_dtos );
    56     }
     55        return PluginResponse::plugin_response()->body( $post_content_dtos );
     56    }
    5757}
  • appful-app/tags/3.1.22/includes/api/mapper/BlogInfoMapper.php

    r3028218 r3039311  
    77
    88class BlogInfoMapper {
    9     public static function to_dto( BlogInfo $blog_info ): BlogInfoDto {
    10         if ( $blog_info->get_stats() == null ) {
    11             $stats = null;
    12         } else {
    13             $stats = BlogStatsMapper::to_dto( $blog_info->get_stats() );
    14         }
     9    public static function to_dto( BlogInfo $blog_info ): BlogInfoDto {
     10        if ( $blog_info->get_stats() == null ) {
     11            $stats = null;
     12        } else {
     13            $stats = BlogStatsMapper::to_dto( $blog_info->get_stats() );
     14        }
    1515
    16         if($blog_info->get_hooks() == null) {
    17             $hooks = null;
    18         } else {
    19             $hooks = BlogHooksMapper::to_dto( $blog_info->get_hooks() );
    20         }
     16        if ( $blog_info->get_hooks() == null ) {
     17            $hooks = null;
     18        } else {
     19            $hooks = BlogHooksMapper::to_dto( $blog_info->get_hooks() );
     20        }
    2121
    22         return new BlogInfoDto(
    23             $blog_info->get_hostname(),
    24             $blog_info->get_site_url(),
    25             $blog_info->get_languages(),
    26             $blog_info->get_token(),
    27             $hooks,
    28             "3.1.21",
    29             $stats
    30         );
    31     }
     22        if ( $blog_info->get_settings() == null ) {
     23            $settings = null;
     24        } else {
     25            $settings = BlogSettingsMapper::to_dto( $blog_info->get_settings() );
     26        }
     27
     28        return new BlogInfoDto(
     29            $blog_info->get_hostname(),
     30            $blog_info->get_site_url(),
     31            $blog_info->get_languages(),
     32            $blog_info->get_token(),
     33            $hooks,
     34            "3.1.22",
     35            $stats,
     36            $settings
     37        );
     38    }
    3239}
  • appful-app/tags/3.1.22/includes/domain/BlogInfo.php

    r3019874 r3039311  
    44
    55class BlogInfo {
    6     private string $hostname = "";
    7     private string $site_url = "";
    8     private array $languages = [];
    9     private string $token = "";
    10     private ?BlogHooks $hooks = null;
    11     private ?BlogStats $stats = null;
     6    private string $hostname = "";
     7    private string $site_url = "";
     8    private array $languages = [];
     9    private string $token = "";
     10    private ?BlogHooks $hooks = null;
     11    private ?BlogStats $stats = null;
     12    private ?BlogSettings $settings = null;
    1213
    13     public static function blog_info(
    14         string $hostname = "",
    15         string $site_url = "",
    16         array $languages = [],
    17         string $token = "",
    18         ?BlogHooks $hooks = null,
    19         ?BlogStats $stats = null
    20     ): BlogInfo {
    21         return ( new BlogInfo() )
    22             ->hostname( $hostname )
    23             ->site_url( $site_url )
    24             ->languages( $languages )
    25             ->token( $token )
    26             ->hooks( $hooks )
    27             ->stats( $stats );
    28     }
     14    private function __construct() {
     15    }
    2916
    30     public function languages( array $languages ): BlogInfo {
    31         $this->languages = $languages;
     17    public static function blog_info(): BlogInfo {
     18        return new BlogInfo();
     19    }
    3220
    33         return $this;
    34     }
     21    public function languages( array $languages ): BlogInfo {
     22        $this->languages = $languages;
    3523
    36     public function site_url( string $site_url ): BlogInfo {
    37         $this->site_url = $site_url;
     24        return $this;
     25    }
    3826
    39         return $this;
    40     }
     27    public function settings( ?BlogSettings $settings ): BlogInfo {
     28        $this->settings = $settings;
    4129
    42     public function hostname( string $hostname ): BlogInfo {
    43         $this->hostname = $hostname;
     30        return $this;
     31    }
    4432
    45         return $this;
    46     }
     33    public function site_url( string $site_url ): BlogInfo {
     34        $this->site_url = $site_url;
    4735
    48     public function token( string $token ): BlogInfo {
    49         $this->token = $token;
     36        return $this;
     37    }
    5038
    51         return $this;
    52     }
     39    public function hostname( string $hostname ): BlogInfo {
     40        $this->hostname = $hostname;
    5341
    54     public function hooks( ?BlogHooks $hooks ): BlogInfo {
    55         $this->hooks = $hooks;
     42        return $this;
     43    }
    5644
    57         return $this;
    58     }
     45    public function token( string $token ): BlogInfo {
     46        $this->token = $token;
    5947
    60     public function stats( ?BlogStats $stats ): BlogInfo {
    61         $this->stats = $stats;
     48        return $this;
     49    }
    6250
    63         return $this;
    64     }
     51    public function hooks( ?BlogHooks $hooks ): BlogInfo {
     52        $this->hooks = $hooks;
    6553
    66     public function get_site_url(): string {
    67         return $this->site_url;
    68     }
     54        return $this;
     55    }
    6956
    70     public function get_languages(): array {
    71         return $this->languages;
    72     }
     57    public function stats( ?BlogStats $stats ): BlogInfo {
     58        $this->stats = $stats;
    7359
    74     public function get_hostname(): string {
    75         return $this->hostname;
    76     }
     60        return $this;
     61    }
    7762
    78     public function get_token(): string {
    79         return $this->token;
    80     }
     63    public function get_site_url(): string {
     64        return $this->site_url;
     65    }
    8166
    82     public function get_hooks(): ?BlogHooks {
    83         return $this->hooks;
    84     }
     67    public function get_languages(): array {
     68        return $this->languages;
     69    }
    8570
    86     public function get_stats(): ?BlogStats {
    87         return $this->stats;
    88     }
     71    public function get_hostname(): string {
     72        return $this->hostname;
     73    }
     74
     75    public function get_token(): string {
     76        return $this->token;
     77    }
     78
     79    public function get_hooks(): ?BlogHooks {
     80        return $this->hooks;
     81    }
     82
     83    public function get_stats(): ?BlogStats {
     84        return $this->stats;
     85    }
     86
     87    public function get_settings(): ?BlogSettings {
     88        return $this->settings;
     89    }
    8990}
  • appful-app/tags/3.1.22/includes/helper/Constants.php

    r3027388 r3039311  
    44
    55class Constants {
    6     public static bool $APPFUL_DEBUG = false;
     6    public static bool $APPFUL_DEBUG = false;
    77
    8     public static string $PLUGIN_ROOT_DIR = "/appful-app";
    9     public static string $PLUGIN_ROOT_FILE = "/appful-app.php";
     8    public static string $PLUGIN_ROOT_DIR = "/appful-app";
     9    public static string $PLUGIN_ROOT_FILE = "/appful-app.php";
    1010
    11     public static string $APPFUL_SESSION_ID_KEY = "appful-app_session_id";
    12     public static string $APPFUL_USERNAME_KEY = "appful-app_username";
    13     public static string $APPFUL_BLOG_ID_KEY = "appful-app_blog_id";
     11    public static string $APPFUL_SESSION_ID_KEY = "appful-app_session_id";
     12    public static string $APPFUL_USERNAME_KEY = "appful-app_username";
     13    public static string $APPFUL_BLOG_ID_KEY = "appful-app_blog_id";
    1414
    15     public static string $APPFUL_CLIENT_SESSION_KEY = "appful-app_client_token_id";
    16     public static string $APPFUL_LAST_ERROR_KEY = "appful-app_last_error";
    17     public static string $APPFUL_APPLE_APP_SITE_ASSOCIATION = "appful-app_apple_app_site_association";
    18     public static string $APPFUL_ANDROID_ASSET_LINK = "appful-app_android_asset_link";
     15    public static string $APPFUL_CLIENT_SESSION_KEY = "appful-app_client_token_id";
     16    public static string $APPFUL_LAST_ERROR_KEY = "appful-app_last_error";
     17    public static string $APPFUL_APPLE_APP_SITE_ASSOCIATION = "appful-app_apple_app_site_association";
     18    public static string $APPFUL_ANDROID_ASSET_LINK = "appful-app_android_asset_link";
     19    public static string $APPFUL_POST_SYNC_BATCH_SIZE_KEY = "appful-app_post_sync_batch_size";
    1920
    20     public static string $APPFUL_TERM_IMAGE_META_KEY = "appful-app_term_image";
     21    public static string $APPFUL_TERM_IMAGE_META_KEY = "appful-app_term_image";
    2122
    22     public static string $APPFUL_TAXONOMY_NAME = "appful";
    23     public static string $APPFUL_TAXONOMY_PUSH_TERM_NAME = "Don't send notification";
    24     public static string $APPFUL_TAXONOMY_PUSH_TERM_SLUG = "push";
     23    public static string $APPFUL_TAXONOMY_NAME = "appful";
     24    public static string $APPFUL_TAXONOMY_PUSH_TERM_NAME = "Don't send notification";
     25    public static string $APPFUL_TAXONOMY_PUSH_TERM_SLUG = "push";
    2526
    2627    public static string $APPFUL_API_URL = "https://api.wordpress.appful.io";
    2728
    28     public static string $BLOG_PATH = "/blogs";
    29     public static string $APPFUL_USER_PATH = "/appfulUsers";
    30     public static string $USER_PATH = "/users";
    31     public static string $POST_PATH = "/posts";
    32     public static string $APP_SETTINGS_PATH = "/app/settings";
    33     public static string $PAGE_PATH = "/pages";
    34     public static string $COMMENT_PATH = "/comments";
    35     public static string $ATTACHMENT_PATH = "/attachments";
    36     public static string $TAXONOMY_PATH = "/taxonomies";
    37     public static string $ROLE_PATH = "/roles";
     29    public static string $BLOG_PATH = "/blogs";
     30    public static string $APPFUL_USER_PATH = "/appfulUsers";
     31    public static string $USER_PATH = "/users";
     32    public static string $POST_PATH = "/posts";
     33    public static string $APP_SETTINGS_PATH = "/app/settings";
     34    public static string $PAGE_PATH = "/pages";
     35    public static string $COMMENT_PATH = "/comments";
     36    public static string $ATTACHMENT_PATH = "/attachments";
     37    public static string $TAXONOMY_PATH = "/taxonomies";
     38    public static string $ROLE_PATH = "/roles";
    3839
    39     public static string $API_VERSION_1 = "/v1";
     40    public static string $API_VERSION_1 = "/v1";
    4041
    41     public static int $POST_SYNC_CHUNK_SIZE = 70;
    42     public static int $PAGE_SYNC_CHUNK_SIZE = 10;
    43     public static int $COMMENT_SYNC_CHUNK_SIZE = 100;
    44     public static int $ATTACHMENT_SYNC_CHUNK_SIZE = 200;
    45     public static int $USER_SYNC_CHUNK_SIZE = 50;
    46     public static int $CATEGORY_SYNC_CHUNK_SIZE = 50;
    47     public static int $TAG_SYNC_CHUNK_SIZE = 50;
    48     public static int $ROLE_SYNC_CHUNK_SIZE = 50;
     42    public static int $POST_SYNC_CHUNK_SIZE = 10;
     43    public static int $PAGE_SYNC_CHUNK_SIZE = 5;
     44    public static int $COMMENT_SYNC_CHUNK_SIZE = 15;
     45    public static int $ATTACHMENT_SYNC_CHUNK_SIZE = 50;
     46    public static int $USER_SYNC_CHUNK_SIZE = 15;
     47    public static int $CATEGORY_SYNC_CHUNK_SIZE = 15;
     48    public static int $TAG_SYNC_CHUNK_SIZE = 15;
     49    public static int $ROLE_SYNC_CHUNK_SIZE = 15;
    4950}
  • appful-app/tags/3.1.22/includes/use_cases/post/PostUseCaseManager.php

    r3027388 r3039311  
    66
    77class PostUseCaseManager {
    8     private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
    9     private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
    10     private GetPostSyncItemUseCase $get_post_sync_item_use_case;
     8    private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
     9    private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
     10    private GetPostSyncItemUseCase $get_post_sync_item_use_case;
    1111
    12     private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
    13     private SendPostSyncUseCase $send_post_sync_use_case;
     12    private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     13    private SendPostSyncUseCase $send_post_sync_use_case;
    1414
    15     private SyncTaxonomyPostsUseCase $sync_taxonomy_posts_use_case;
    16     private SyncPostsUseCase $sync_posts_use_case;
    17     private SyncPostUseCase $sync_post_use_case;
     15    private SyncTaxonomyPostsUseCase $sync_taxonomy_posts_use_case;
     16    private SyncPostsUseCase $sync_posts_use_case;
     17    private SyncPostUseCase $sync_post_use_case;
    1818
    19     public function __construct( BackendClient $backend_client ) {
    20         $this->get_post_sync_item_use_case           = new GetPostSyncItemUseCase();
    21         $this->get_post_sync_data_use_case           = new GetPostSyncItemsUseCase();
    22         $this->get_taxonomy_post_sync_items_use_case = new GetTaxonomyPostSyncItemsUseCase();
     19    private GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case;
     20    private SavePostSyncBatchSizeUseCase $save_post_sync_batch_size_use_case;
    2321
    24         $this->send_post_chunk_sync_use_case = new SendPostChunkSyncUseCase( $backend_client );
    25         $this->send_post_sync_use_case       = new SendPostSyncUseCase( $backend_client );
     22    public function __construct( BackendClient $backend_client ) {
     23        $this->get_post_sync_batch_size_use_case  = new GetPostSyncBatchSizeUseCase();
     24        $this->save_post_sync_batch_size_use_case = new SavePostSyncBatchSizeUseCase();
    2625
    27         $this->sync_posts_use_case          = new SyncPostsUseCase( $this->get_post_sync_data_use_case, $this->send_post_chunk_sync_use_case );
    28         $this->sync_post_use_case           = new SyncPostUseCase( $this->get_post_sync_item_use_case, $this->send_post_sync_use_case );
    29         $this->sync_taxonomy_posts_use_case = new SyncTaxonomyPostsUseCase( $this->get_taxonomy_post_sync_items_use_case, $this->send_post_chunk_sync_use_case );
    30     }
     26        $this->get_post_sync_item_use_case           = new GetPostSyncItemUseCase();
     27        $this->get_post_sync_data_use_case           = new GetPostSyncItemsUseCase();
     28        $this->get_taxonomy_post_sync_items_use_case = new GetTaxonomyPostSyncItemsUseCase();
    3129
    32     public function get_sync_post_use_case(): SyncPostUseCase {
    33         return $this->sync_post_use_case;
    34     }
     30        $this->send_post_chunk_sync_use_case = new SendPostChunkSyncUseCase( $backend_client );
     31        $this->send_post_sync_use_case       = new SendPostSyncUseCase( $backend_client );
    3532
    36     public function get_sync_posts_use_case(): SyncPostsUseCase {
    37         return $this->sync_posts_use_case;
    38     }
     33        $this->sync_posts_use_case          = new SyncPostsUseCase( $this->get_post_sync_data_use_case, $this->send_post_chunk_sync_use_case, $this->get_post_sync_batch_size_use_case );
     34        $this->sync_post_use_case           = new SyncPostUseCase( $this->get_post_sync_item_use_case, $this->send_post_sync_use_case );
     35        $this->sync_taxonomy_posts_use_case = new SyncTaxonomyPostsUseCase( $this->get_taxonomy_post_sync_items_use_case, $this->send_post_chunk_sync_use_case, $this->get_post_sync_batch_size_use_case );
     36    }
    3937
    40     public function get_sync_taxonomy_posts_use_case(): SyncTaxonomyPostsUseCase {
    41         return $this->sync_taxonomy_posts_use_case;
    42     }
     38    public function get_sync_post_use_case(): SyncPostUseCase {
     39        return $this->sync_post_use_case;
     40    }
     41
     42    public function get_sync_posts_use_case(): SyncPostsUseCase {
     43        return $this->sync_posts_use_case;
     44    }
     45
     46    public function get_sync_taxonomy_posts_use_case(): SyncTaxonomyPostsUseCase {
     47        return $this->sync_taxonomy_posts_use_case;
     48    }
     49
     50    public function get_post_sync_batch_size_use_case(): GetPostSyncBatchSizeUseCase {
     51        return $this->get_post_sync_batch_size_use_case;
     52    }
     53
     54    public function get_save_post_sync_batch_size_use_case(): SavePostSyncBatchSizeUseCase {
     55        return $this->save_post_sync_batch_size_use_case;
     56    }
    4357}
  • appful-app/tags/3.1.22/includes/use_cases/post/SyncPostsUseCase.php

    r3027388 r3039311  
    44
    55use AppfulPlugin\Domain\SyncChunk;
    6 use AppfulPlugin\Helper\Constants;
    76use AppfulPlugin\Wp\WPPostManager;
    87
    98class SyncPostsUseCase {
    10     private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
    11     private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     9    private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
     10    private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     11    private GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case;
    1212
    13     public function __construct(
    14         GetPostSyncItemsUseCase $get_post_sync_data_use_case,
    15         SendPostChunkSyncUseCase $send_post_chunk_sync_use_case
    16     ) {
    17         $this->get_post_sync_data_use_case   = $get_post_sync_data_use_case;
    18         $this->send_post_chunk_sync_use_case = $send_post_chunk_sync_use_case;
    19     }
     13    public function __construct(
     14        GetPostSyncItemsUseCase $get_post_sync_data_use_case,
     15        SendPostChunkSyncUseCase $send_post_chunk_sync_use_case,
     16        GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case
     17    ) {
     18        $this->get_post_sync_data_use_case       = $get_post_sync_data_use_case;
     19        $this->send_post_chunk_sync_use_case     = $send_post_chunk_sync_use_case;
     20        $this->get_post_sync_batch_size_use_case = $get_post_sync_batch_size_use_case;
     21    }
    2022
    21     public function invoke() {
    22         $sync_id    = uniqid();
    23         $batch_size = WPPostManager::get_post_count();
    24         $chunk_size = Constants::$POST_SYNC_CHUNK_SIZE;
     23    public function invoke() {
     24        $sync_id    = uniqid();
     25        $batch_size = WPPostManager::get_post_count();
     26        $chunk_size = $this->get_post_sync_batch_size_use_case->invoke();
    2527
    26         $chunk = 0;
    27         while ( true ) {
    28             $post_sync_items = $this->get_post_sync_data_use_case->invoke($chunk * $chunk_size, $chunk_size);
     28        $chunk = 0;
     29        while ( true ) {
     30            $post_sync_items = $this->get_post_sync_data_use_case->invoke( $chunk * $chunk_size, $chunk_size );
    2931
    30             $this->send_post_chunk_sync_use_case->invoke(
    31                 SyncChunk::syncChunk()
    32                          ->batch_id( $sync_id )
    33                          ->chunk_size( $chunk_size )
    34                          ->batch_size( $batch_size )
    35                          ->chunk_items( $post_sync_items )
    36             );
     32            $this->send_post_chunk_sync_use_case->invoke(
     33                SyncChunk::syncChunk()
     34                         ->batch_id( $sync_id )
     35                         ->chunk_size( $chunk_size )
     36                         ->batch_size( $batch_size )
     37                         ->chunk_items( $post_sync_items )
     38            );
    3739
    38             $chunk ++;
     40            $chunk ++;
    3941
    40             if ( count( $post_sync_items ) < $chunk_size ) {
    41                 break;
    42             }
    43         }
    44     }
     42            if ( count( $post_sync_items ) < $chunk_size ) {
     43                break;
     44            }
     45        }
     46    }
    4547}
  • appful-app/tags/3.1.22/includes/use_cases/post/SyncTaxonomyPostsUseCase.php

    r3027388 r3039311  
    44
    55use AppfulPlugin\Domain\SyncChunk;
    6 use AppfulPlugin\Helper\Constants;
    76use AppfulPlugin\Wp\WPPostManager;
    87
    98class SyncTaxonomyPostsUseCase {
    10     private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
    11     private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     9    private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
     10    private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     11    private GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case;
    1212
    13     public function __construct(
    14         GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case,
    15         SendPostChunkSyncUseCase $send_post_chunk_sync_use_case
    16     ) {
    17         $this->get_taxonomy_post_sync_items_use_case = $get_taxonomy_post_sync_items_use_case;
    18         $this->send_post_chunk_sync_use_case         = $send_post_chunk_sync_use_case;
    19     }
     13    public function __construct(
     14        GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case,
     15        SendPostChunkSyncUseCase $send_post_chunk_sync_use_case,
     16        GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case
     17    ) {
     18        $this->get_taxonomy_post_sync_items_use_case = $get_taxonomy_post_sync_items_use_case;
     19        $this->send_post_chunk_sync_use_case         = $send_post_chunk_sync_use_case;
     20        $this->get_post_sync_batch_size_use_case     = $get_post_sync_batch_size_use_case;
     21    }
    2022
    21     public function invoke( string $taxonomy, string $term_slug ) {
    22         $sync_id    = uniqid();
    23         $batch_size = WPPostManager::get_taxonomy_post_count( $taxonomy, $term_slug );
    24         $chunk_size = Constants::$POST_SYNC_CHUNK_SIZE;
     23    public function invoke( string $taxonomy, string $term_slug ) {
     24        $sync_id    = uniqid();
     25        $batch_size = WPPostManager::get_taxonomy_post_count( $taxonomy, $term_slug );
     26        $chunk_size = $this->get_post_sync_batch_size_use_case->invoke();
    2527
    26         $chunk = 0;
    27         while ( true ) {
    28             $post_sync_items = $this->get_taxonomy_post_sync_items_use_case->invoke( $taxonomy, $term_slug, $chunk * $chunk_size, $chunk_size );
     28        $chunk = 0;
     29        while ( true ) {
     30            $post_sync_items = $this->get_taxonomy_post_sync_items_use_case->invoke( $taxonomy, $term_slug, $chunk * $chunk_size, $chunk_size );
    2931
    30             $this->send_post_chunk_sync_use_case->invoke(
    31                 SyncChunk::syncChunk()
    32                          ->batch_id( $sync_id )
    33                          ->chunk_size( $chunk_size )
    34                          ->batch_size( $batch_size )
    35                          ->chunk_items( $post_sync_items )
    36             );
     32            $this->send_post_chunk_sync_use_case->invoke(
     33                SyncChunk::syncChunk()
     34                         ->batch_id( $sync_id )
     35                         ->chunk_size( $chunk_size )
     36                         ->batch_size( $batch_size )
     37                         ->chunk_items( $post_sync_items )
     38            );
    3739
    38             $chunk ++;
     40            $chunk ++;
    3941
    40             if ( count( $post_sync_items ) < $chunk_size ) {
    41                 break;
    42             }
    43         }
    44     }
     42            if ( count( $post_sync_items ) < $chunk_size ) {
     43                break;
     44            }
     45        }
     46    }
    4547}
  • appful-app/tags/3.1.22/includes/wp/WPBlogManager.php

    r3019874 r3039311  
    66use AppfulPlugin\Domain\BlogHooks;
    77use AppfulPlugin\Domain\BlogInfo;
     8use AppfulPlugin\Domain\BlogSettings;
    89use AppfulPlugin\Domain\BlogStats;
    910use AppfulPlugin\Helper\ClientTokenManager;
     11use AppfulPlugin\UseCases\Post\GetPostSyncBatchSizeUseCase;
    1012use AppfulPlugin\Wp\Plugins\LanguageHelper;
    1113
    1214class WPBlogManager {
    13     public static function get_blog_info(): BlogInfo {
    14         return BlogInfo::blog_info()
    15                        ->hostname( self::get_hostname() )
    16                        ->site_url( self::get_site_url() )
    17                        ->languages( self::get_languages() )
    18                        ->token( ClientTokenManager::getToken() ?? ClientTokenManager::createSession() )
    19                        ->hooks( self::get_hooks() )
    20                        ->stats( self::get_stats() );
    21     }
     15    public static function get_blog_info(): BlogInfo {
     16        return BlogInfo::blog_info()
     17                       ->hostname( self::get_hostname() )
     18                       ->site_url( self::get_site_url() )
     19                       ->languages( self::get_languages() )
     20                       ->token( ClientTokenManager::getToken() ?? ClientTokenManager::createSession() )
     21                       ->hooks( self::get_hooks() )
     22                       ->stats( self::get_stats() )
     23                       ->settings( self::get_settings() );
     24    }
    2225
    23     private static function get_hooks(): BlogHooks {
    24         return BlogHooks::init()
    25                         ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT_HOOK )
    26                         ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER_HOOK )
    27                         ->get_page_content( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$GET_PAGE_CONTENT_HOOK );
    28     }
     26    private static function get_hooks(): BlogHooks {
     27        return BlogHooks::init()
     28                        ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT_HOOK )
     29                        ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER_HOOK )
     30                        ->get_page_content( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$GET_PAGE_CONTENT_HOOK );
     31    }
    2932
    30     private static function get_stats(): BlogStats {
    31         return BlogStats::init()
    32                         ->attachment_count( WPAttachmentManager::get_attachment_count() )
    33                         ->post_count( WPPostManager::get_post_count() )
    34                         ->user_count( WPUserManager::get_user_count() )
    35                         ->page_count( WPPageManager::get_page_count() )
    36                         ->comment_count( WPCommentManager::get_comment_count() );
    37     }
     33    private static function get_stats(): BlogStats {
     34        return BlogStats::init()
     35                        ->attachment_count( WPAttachmentManager::get_attachment_count() )
     36                        ->post_count( WPPostManager::get_post_count() )
     37                        ->user_count( WPUserManager::get_user_count() )
     38                        ->page_count( WPPageManager::get_page_count() )
     39                        ->comment_count( WPCommentManager::get_comment_count() );
     40    }
    3841
    39     private static function get_hostname(): string {
    40         $siteUrl = self::get_site_url();
     42    private static function get_settings(): BlogSettings {
     43        return BlogSettings::init()
     44                           ->post_sync_batch_size( ( new GetPostSyncBatchSizeUseCase() )->invoke() );
     45    }
    4146
    42         return parse_url( $siteUrl, PHP_URL_HOST );
    43     }
     47    private static function get_hostname(): string {
     48        $siteUrl = self::get_site_url();
    4449
    45     private static function get_site_url(): string {
    46         return get_site_url();
    47     }
     50        return parse_url( $siteUrl, PHP_URL_HOST );
     51    }
    4852
    49     private static function get_languages(): array {
    50         return LanguageHelper::get_languages();
    51     }
     53    private static function get_site_url(): string {
     54        return get_site_url();
     55    }
    5256
    53     public static function get_blog_language(): string {
    54         return substr( get_bloginfo( "language" ), 0, 2 ) ?? "";
    55     }
     57    private static function get_languages(): array {
     58        return LanguageHelper::get_languages();
     59    }
     60
     61    public static function get_blog_language(): string {
     62        return substr( get_bloginfo( "language" ), 0, 2 ) ?? "";
     63    }
    5664}
  • appful-app/tags/3.1.22/includes/wp/WPOptionsManager.php

    r2936340 r3039311  
    66
    77class WPOptionsManager {
    8     private static function save_option( string $key, ?string $value ): bool {
    9         if ( $value == null ) {
    10             return delete_option( $key );
    11         }
     8    private static function save_option( string $key, ?string $value ): bool {
     9        if ( $value == null ) {
     10            return delete_option( $key );
     11        }
    1212
    13         $current_value = get_option( $key, null );
    14         if ( $current_value != null ) {
    15             return update_option( $key, $value );
    16         } else {
    17             return add_option( $key, $value );
    18         }
    19     }
     13        $current_value = get_option( $key, null );
     14        if ( $current_value != null ) {
     15            return update_option( $key, $value );
     16        } else {
     17            return add_option( $key, $value );
     18        }
     19    }
    2020
    21     private static function get_option( string $key, $default = null ) {
    22         return get_option( $key, $default );
    23     }
     21    private static function get_option( string $key, $default = null ) {
     22        return get_option( $key, $default );
     23    }
    2424
    25     public static function save_app_site_association( string $value ) {
    26         self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, $value );
    27     }
     25    public static function save_app_site_association( string $value ) {
     26        self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, $value );
     27    }
    2828
    29     public static function get_apple_app_site_association(): ?string {
    30         return self::get_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION );
    31     }
     29    public static function get_apple_app_site_association(): ?string {
     30        return self::get_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION );
     31    }
    3232
    33     public static function delete_app_site_association(): void {
    34         self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, null );
    35     }
     33    public static function delete_app_site_association(): void {
     34        self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, null );
     35    }
    3636
    37     public static function save_asset_link( string $value ) {
    38         self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, $value );
    39     }
     37    public static function save_asset_link( string $value ) {
     38        self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, $value );
     39    }
    4040
    41     public static function get_android_asset_link(): ?string {
    42         return self::get_option( Constants::$APPFUL_ANDROID_ASSET_LINK );
    43     }
     41    public static function get_android_asset_link(): ?string {
     42        return self::get_option( Constants::$APPFUL_ANDROID_ASSET_LINK );
     43    }
    4444
    45     public static function delete_asset_link(): void {
    46         self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, null );
    47     }
     45    public static function delete_asset_link(): void {
     46        self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, null );
     47    }
    4848
    49     public static function save_session_id( string $session_id ): void {
    50         self::save_option( Constants::$APPFUL_SESSION_ID_KEY, $session_id );
    51     }
     49    public static function save_session_id( string $session_id ): void {
     50        self::save_option( Constants::$APPFUL_SESSION_ID_KEY, $session_id );
     51    }
    5252
    53     public static function get_session_id(): ?string {
    54         return self::get_option( Constants::$APPFUL_SESSION_ID_KEY );
    55     }
     53    public static function get_session_id(): ?string {
     54        return self::get_option( Constants::$APPFUL_SESSION_ID_KEY );
     55    }
    5656
    57     public static function delete_session_id(): void {
    58         self::save_option( Constants::$APPFUL_SESSION_ID_KEY, null );
    59     }
     57    public static function delete_session_id(): void {
     58        self::save_option( Constants::$APPFUL_SESSION_ID_KEY, null );
     59    }
    6060
    61     public static function save_username( string $username ): void {
    62         self::save_option( Constants::$APPFUL_USERNAME_KEY, $username );
    63     }
     61    public static function save_username( string $username ): void {
     62        self::save_option( Constants::$APPFUL_USERNAME_KEY, $username );
     63    }
    6464
    65     public static function get_username(): ?string {
    66         return self::get_option( Constants::$APPFUL_USERNAME_KEY );
    67     }
     65    public static function get_username(): ?string {
     66        return self::get_option( Constants::$APPFUL_USERNAME_KEY );
     67    }
    6868
    69     public static function delete_username(): void {
    70         self::save_option( Constants::$APPFUL_USERNAME_KEY, null );
    71     }
     69    public static function delete_username(): void {
     70        self::save_option( Constants::$APPFUL_USERNAME_KEY, null );
     71    }
    7272
    73     public static function save_blog_id( string $blog_id ): void {
    74         self::save_option( Constants::$APPFUL_BLOG_ID_KEY, $blog_id );
    75     }
     73    public static function save_blog_id( string $blog_id ): void {
     74        self::save_option( Constants::$APPFUL_BLOG_ID_KEY, $blog_id );
     75    }
    7676
    77     public static function get_blog_id(): ?string {
    78         return self::get_option( Constants::$APPFUL_BLOG_ID_KEY );
    79     }
     77    public static function get_blog_id(): ?string {
     78        return self::get_option( Constants::$APPFUL_BLOG_ID_KEY );
     79    }
    8080
    81     public static function delete_blog_id(): void {
    82         self::save_option( Constants::$APPFUL_BLOG_ID_KEY, null );
    83     }
     81    public static function delete_blog_id(): void {
     82        self::save_option( Constants::$APPFUL_BLOG_ID_KEY, null );
     83    }
    8484
    85     public static function save_client_token( string $client_session ): void {
    86         self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, $client_session );
    87     }
     85    public static function save_client_token( string $client_session ): void {
     86        self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, $client_session );
     87    }
    8888
    89     public static function get_client_token(): ?string {
    90         return self::get_option( Constants::$APPFUL_CLIENT_SESSION_KEY );
    91     }
     89    public static function get_client_token(): ?string {
     90        return self::get_option( Constants::$APPFUL_CLIENT_SESSION_KEY );
     91    }
    9292
    93     public static function delete_client_token(): void {
    94         self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, null );
    95     }
     93    public static function delete_client_token(): void {
     94        self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, null );
     95    }
    9696
    97     public static function save_last_sync_error( string $error ): void {
    98         self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, $error );
    99     }
     97    public static function save_last_sync_error( string $error ): void {
     98        self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, $error );
     99    }
    100100
    101     public static function get_last_sync_error(): ?string {
    102         return self::get_option( Constants::$APPFUL_LAST_ERROR_KEY );
    103     }
     101    public static function get_last_sync_error(): ?string {
     102        return self::get_option( Constants::$APPFUL_LAST_ERROR_KEY );
     103    }
    104104
    105     public static function delete_last_sync_error(): void {
    106         self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, null );
    107     }
     105    public static function delete_last_sync_error(): void {
     106        self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, null );
     107    }
    108108
    109     public static function clean() {
    110         self::delete_session_id();
    111         self::delete_blog_id();
    112         self::delete_username();
    113         self::delete_app_site_association();
    114         self::delete_asset_link();
    115         self::delete_client_token();
    116     }
     109    public static function save_post_sync_batch_size( int $size ): void {
     110        self::save_option( Constants::$APPFUL_POST_SYNC_BATCH_SIZE_KEY, $size );
     111    }
     112
     113    public static function get_post_sync_batch_size(): ?int {
     114        return self::get_option( Constants::$APPFUL_POST_SYNC_BATCH_SIZE_KEY );
     115    }
     116
     117    public static function delete_post_sync_batch_size(): void {
     118        self::save_option( Constants::$APPFUL_POST_SYNC_BATCH_SIZE_KEY, null );
     119    }
     120
     121    public static function clean() {
     122        self::delete_session_id();
     123        self::delete_blog_id();
     124        self::delete_username();
     125        self::delete_app_site_association();
     126        self::delete_asset_link();
     127        self::delete_client_token();
     128        self::delete_post_sync_batch_size();
     129    }
    117130}
  • appful-app/tags/3.1.22/lib/vendor/composer/autoload_classmap.php

    r3027388 r3039311  
    1414    'AppfulPlugin\\Api\\Dtos\\BlogHooksDto' => $baseDir . '/../includes/api/dtos/BlogHooksDto.php',
    1515    'AppfulPlugin\\Api\\Dtos\\BlogInfoDto' => $baseDir . '/../includes/api/dtos/BlogInfoDto.php',
     16    'AppfulPlugin\\Api\\Dtos\\BlogSettingsDto' => $baseDir . '/../includes/api/dtos/BlogSettingsDto.php',
    1617    'AppfulPlugin\\Api\\Dtos\\BlogStatsDto' => $baseDir . '/../includes/api/dtos/BlogStatsDto.php',
    1718    'AppfulPlugin\\Api\\Dtos\\CategoryDto' => $baseDir . '/../includes/api/dtos/CategoryDto.php',
     
    5657    'AppfulPlugin\\Api\\Handlers\\RequestHandler' => $baseDir . '/../includes/api/handlers/RequestHandler.php',
    5758    'AppfulPlugin\\Api\\Handlers\\RoleSyncRequestHandler' => $baseDir . '/../includes/api/handlers/RoleSyncRequestHandler.php',
     59    'AppfulPlugin\\Api\\Handlers\\SavePostSyncBatchSizeHandler' => $baseDir . '/../includes/api/handlers/SavePostSyncBatchSizeHandler.php',
    5860    'AppfulPlugin\\Api\\Handlers\\SyncRequestHandler' => $baseDir . '/../includes/api/handlers/SyncRequestHandler.php',
    5961    'AppfulPlugin\\Api\\Handlers\\TagSyncRequestHandler' => $baseDir . '/../includes/api/handlers/TagSyncRequestHandler.php',
     
    6365    'AppfulPlugin\\Api\\Mapper\\BlogHooksMapper' => $baseDir . '/../includes/api/mapper/BlogHooksMapper.php',
    6466    'AppfulPlugin\\Api\\Mapper\\BlogInfoMapper' => $baseDir . '/../includes/api/mapper/BlogInfoMapper.php',
     67    'AppfulPlugin\\Api\\Mapper\\BlogSettingsMapper' => $baseDir . '/../includes/api/mapper/BlogSettingsMapper.php',
    6568    'AppfulPlugin\\Api\\Mapper\\BlogStatsMapper' => $baseDir . '/../includes/api/mapper/BlogStatsMapper.php',
    6669    'AppfulPlugin\\Api\\Mapper\\CategoryMapper' => $baseDir . '/../includes/api/mapper/CategoryMapper.php',
     
    8891    'AppfulPlugin\\Domain\\BlogHooks' => $baseDir . '/../includes/domain/BlogHooks.php',
    8992    'AppfulPlugin\\Domain\\BlogInfo' => $baseDir . '/../includes/domain/BlogInfo.php',
     93    'AppfulPlugin\\Domain\\BlogSettings' => $baseDir . '/../includes/domain/BlogSettings.php',
    9094    'AppfulPlugin\\Domain\\BlogStats' => $baseDir . '/../includes/domain/BlogStats.php',
    9195    'AppfulPlugin\\Domain\\Category' => $baseDir . '/../includes/domain/Category.php',
     
    166170    'AppfulPlugin\\UseCases\\Page\\PullLocalPageContentUseCase' => $baseDir . '/../includes/use_cases/page/PullLocalPageContentUseCase.php',
    167171    'AppfulPlugin\\UseCases\\PostDeleteUseCase' => $baseDir . '/../includes/use_cases/PostDeleteUseCase.php',
     172    'AppfulPlugin\\UseCases\\Post\\GetPostSyncBatchSizeUseCase' => $baseDir . '/../includes/use_cases/post/GetPostSyncBatchSizeUseCase.php',
    168173    'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemUseCase' => $baseDir . '/../includes/use_cases/post/GetPostSyncItemUseCase.php',
    169174    'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemsUseCase' => $baseDir . '/../includes/use_cases/post/GetPostSyncItemsUseCase.php',
    170175    'AppfulPlugin\\UseCases\\Post\\GetTaxonomyPostSyncItemsUseCase' => $baseDir . '/../includes/use_cases/post/GetTaxonomyPostSyncItemsUseCase.php',
    171176    'AppfulPlugin\\UseCases\\Post\\PostUseCaseManager' => $baseDir . '/../includes/use_cases/post/PostUseCaseManager.php',
     177    'AppfulPlugin\\UseCases\\Post\\SavePostSyncBatchSizeUseCase' => $baseDir . '/../includes/use_cases/post/SavePostSyncBatchSizeUseCase.php',
    172178    'AppfulPlugin\\UseCases\\Post\\SendPostChunkSyncUseCase' => $baseDir . '/../includes/use_cases/post/SendPostChunkSyncUseCase.php',
    173179    'AppfulPlugin\\UseCases\\Post\\SendPostSyncUseCase' => $baseDir . '/../includes/use_cases/post/SendPostSyncUseCase.php',
  • appful-app/tags/3.1.22/lib/vendor/composer/autoload_static.php

    r3027388 r3039311  
    211211        'AppfulPlugin\\Api\\Dtos\\BlogHooksDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogHooksDto.php',
    212212        'AppfulPlugin\\Api\\Dtos\\BlogInfoDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogInfoDto.php',
     213        'AppfulPlugin\\Api\\Dtos\\BlogSettingsDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogSettingsDto.php',
    213214        'AppfulPlugin\\Api\\Dtos\\BlogStatsDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogStatsDto.php',
    214215        'AppfulPlugin\\Api\\Dtos\\CategoryDto' => __DIR__ . '/../..' . '/../includes/api/dtos/CategoryDto.php',
     
    253254        'AppfulPlugin\\Api\\Handlers\\RequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/RequestHandler.php',
    254255        'AppfulPlugin\\Api\\Handlers\\RoleSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/RoleSyncRequestHandler.php',
     256        'AppfulPlugin\\Api\\Handlers\\SavePostSyncBatchSizeHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/SavePostSyncBatchSizeHandler.php',
    255257        'AppfulPlugin\\Api\\Handlers\\SyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/SyncRequestHandler.php',
    256258        'AppfulPlugin\\Api\\Handlers\\TagSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/TagSyncRequestHandler.php',
     
    260262        'AppfulPlugin\\Api\\Mapper\\BlogHooksMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogHooksMapper.php',
    261263        'AppfulPlugin\\Api\\Mapper\\BlogInfoMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogInfoMapper.php',
     264        'AppfulPlugin\\Api\\Mapper\\BlogSettingsMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogSettingsMapper.php',
    262265        'AppfulPlugin\\Api\\Mapper\\BlogStatsMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogStatsMapper.php',
    263266        'AppfulPlugin\\Api\\Mapper\\CategoryMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/CategoryMapper.php',
     
    285288        'AppfulPlugin\\Domain\\BlogHooks' => __DIR__ . '/../..' . '/../includes/domain/BlogHooks.php',
    286289        'AppfulPlugin\\Domain\\BlogInfo' => __DIR__ . '/../..' . '/../includes/domain/BlogInfo.php',
     290        'AppfulPlugin\\Domain\\BlogSettings' => __DIR__ . '/../..' . '/../includes/domain/BlogSettings.php',
    287291        'AppfulPlugin\\Domain\\BlogStats' => __DIR__ . '/../..' . '/../includes/domain/BlogStats.php',
    288292        'AppfulPlugin\\Domain\\Category' => __DIR__ . '/../..' . '/../includes/domain/Category.php',
     
    363367        'AppfulPlugin\\UseCases\\Page\\PullLocalPageContentUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/page/PullLocalPageContentUseCase.php',
    364368        'AppfulPlugin\\UseCases\\PostDeleteUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/PostDeleteUseCase.php',
     369        'AppfulPlugin\\UseCases\\Post\\GetPostSyncBatchSizeUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetPostSyncBatchSizeUseCase.php',
    365370        'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetPostSyncItemUseCase.php',
    366371        'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemsUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetPostSyncItemsUseCase.php',
    367372        'AppfulPlugin\\UseCases\\Post\\GetTaxonomyPostSyncItemsUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetTaxonomyPostSyncItemsUseCase.php',
    368373        'AppfulPlugin\\UseCases\\Post\\PostUseCaseManager' => __DIR__ . '/../..' . '/../includes/use_cases/post/PostUseCaseManager.php',
     374        'AppfulPlugin\\UseCases\\Post\\SavePostSyncBatchSizeUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/SavePostSyncBatchSizeUseCase.php',
    369375        'AppfulPlugin\\UseCases\\Post\\SendPostChunkSyncUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/SendPostChunkSyncUseCase.php',
    370376        'AppfulPlugin\\UseCases\\Post\\SendPostSyncUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/SendPostSyncUseCase.php',
  • appful-app/tags/3.1.22/readme.txt

    r3028218 r3039311  
    66Tested up to: 6.4
    77Requires PHP: 7.4
    8 Stable tag: 3.1.21
     8Stable tag: 3.1.22
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • appful-app/trunk/appful-app.php

    r3028218 r3039311  
    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.21
     14 * Version:           3.1.22
    1515 * Requires at least: 5.8
    1616 * Requires PHP:      7.4
  • appful-app/trunk/includes/api/Endpoints.php

    r2978062 r3039311  
    44
    55class Endpoints {
    6     public static string $INFO = "info";
    7     public static string $LOGS = "logs";
     6    public static string $INFO = "info";
     7    public static string $LOGS = "logs";
    88
    9     public static string $CLEAR_LOGS = "clear-logs";
     9    public static string $SAVE_POST_SYNC_BATCH_SIZE = "save-post-sync-batch-size";
    1010
    11     public static string $SYNC = "sync";
    12     public static string $SYNC_POSTS = "sync-post";
     11    public static string $CLEAR_LOGS = "clear-logs";
    1312
    14     public static string $SYNC_PAGES = "sync-page";
    15     public static string $SYNC_COMMENTS = "sync-comment";
    16     public static string $SYNC_TAGS = "sync-tag";
    17     public static string $SYNC_ROLES = "sync-role";
    18     public static string $SYNC_USERS = "sync-user";
    19     public static string $SYNC_ATTACHMENTS = "sync-attachment";
    20     public static string $SYNC_CATEGORIES = "sync-category";
     13    public static string $SYNC = "sync";
     14    public static string $SYNC_POSTS = "sync-post";
    2115
    22     public static string $GET_ATTACHMENTS = "get-attachment";
    23     public static string $GET_COMMENTS = "get-comment";
    24     public static string $GET_CATEGORIES = "get-category";
    25     public static string $GET_POSTS = "get-post";
    26     public static string $GET_PAGES = "get-page";
    27     public static string $GET_POST_CONTENTS = "get-post-content";
    28     public static string $GET_PAGE_CONTENTS = "get-page-content";
    29     public static string $GET_POST_CONTENT_LOCAL = "get-post-content-local";
    30     public static string $GET_PAGE_CONTENT_LOCAL = "get-page-content-local";
    31     public static string $GET_USERS = "get-user";
    32     public static string $GET_TAGS = "get-tag";
    33     public static string $GET_ROLES = "get-role";
     16    public static string $SYNC_PAGES = "sync-page";
     17    public static string $SYNC_COMMENTS = "sync-comment";
     18    public static string $SYNC_TAGS = "sync-tag";
     19    public static string $SYNC_ROLES = "sync-role";
     20    public static string $SYNC_USERS = "sync-user";
     21    public static string $SYNC_ATTACHMENTS = "sync-attachment";
     22    public static string $SYNC_CATEGORIES = "sync-category";
    3423
    35     public static string $ASSET_LINKS = "android-asset-links";
    36     public static string $SITE_ASSOCIATION = "apple-app-site-association";
     24    public static string $GET_ATTACHMENTS = "get-attachment";
     25    public static string $GET_COMMENTS = "get-comment";
     26    public static string $GET_CATEGORIES = "get-category";
     27    public static string $GET_POSTS = "get-post";
     28    public static string $GET_PAGES = "get-page";
     29    public static string $GET_POST_CONTENTS = "get-post-content";
     30    public static string $GET_PAGE_CONTENTS = "get-page-content";
     31    public static string $GET_POST_CONTENT_LOCAL = "get-post-content-local";
     32    public static string $GET_PAGE_CONTENT_LOCAL = "get-page-content-local";
     33    public static string $GET_USERS = "get-user";
     34    public static string $GET_TAGS = "get-tag";
     35    public static string $GET_ROLES = "get-role";
     36
     37    public static string $ASSET_LINKS = "android-asset-links";
     38    public static string $SITE_ASSOCIATION = "apple-app-site-association";
    3739
    3840
    39     public static string $HOOK = "/appful/api";
    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";
     41    public static string $HOOK = "/appful/api";
     42    public static string $CREATE_COMMENT_HOOK = "create-comment";
     43    public static string $AUTHENTICATE_USER_HOOK = "authenticate-user";
     44    public static string $GET_PAGE_CONTENT_HOOK = "get-page-content-hook";
    4345}
  • appful-app/trunk/includes/api/ReqHandler.php

    r3027388 r3039311  
    3030use AppfulPlugin\Api\Handlers\RequestHandler;
    3131use AppfulPlugin\Api\Handlers\RoleSyncRequestHandler;
     32use AppfulPlugin\Api\Handlers\SavePostSyncBatchSizeHandler;
    3233use AppfulPlugin\Api\Handlers\SyncRequestHandler;
    3334use AppfulPlugin\Api\Handlers\TagSyncRequestHandler;
     
    3940
    4041class ReqHandler {
    41     private array $request_handlers;
     42    private array $request_handlers;
    4243
    43     public function __construct( UseCaseManager $use_case_manager ) {
    44         $this->request_handlers = [
    45             new AndroidAssetLinkRequestHandler( $use_case_manager->get_android_asset_link_use_case() ),
    46             new AppleAppSiteAssociationRequestHandler( $use_case_manager->get_apple_app_site_association_use_case() ),
    47             new LogRequestHandler( $use_case_manager->get_logs_use_case() ),
    48             new InfoRequestHandler( $use_case_manager->get_blog_info_use_case() ),
    49             new PostSyncRequestHandler( $use_case_manager->posts()->get_sync_posts_use_case() ),
    50             new GetPostsRequestHandler( $use_case_manager->get_posts_by_id_use_case() ),
    51             new CategorySyncRequestHandler( $use_case_manager->sync_categories_use_case() ),
    52             new GetCategoriesRequestHandler( $use_case_manager->get_categories_by_id_use_case() ),
    53             new TagSyncRequestHandler( $use_case_manager->sync_tags_use_case() ),
    54             new GetTagsRequestHandler( $use_case_manager->get_tags_by_id_use_case() ),
    55             new GetAttachmentsRequestHandler( $use_case_manager->get_attachments_by_id_use_case() ),
    56             new AttachmentSyncRequestHandler( $use_case_manager->sync_attachments_use_case() ),
    57             new SyncRequestHandler( $use_case_manager->sync_all_use_case() ),
    58             new GetCommentsRequestHandler( $use_case_manager->get_comments_by_id_use_case() ),
    59             new CommentSyncRequestHandler( $use_case_manager->sync_comments_use_case() ),
    60             new UserSyncRequestHandler( $use_case_manager->sync_users_use_case() ),
    61             new GetUsersRequestHandler( $use_case_manager->get_users_by_id_use_case() ),
    62             new GetPostContentsRequestHandler( $use_case_manager->get_post_contents_by_id_use_case() ),
    63             new ClearLogRequestHandler( $use_case_manager->get_clear_logs_use_case() ),
    64             new AuthenticateUserRequestHandler( $use_case_manager->get_authenticate_user_use_case() ),
    65             new PullLocalPostContentRequestHandler( $use_case_manager->get_get_local_post_content_by_id_use_case() ),
    66             new CreateCommentRequestHandler( $use_case_manager->create_comment_use_case() ),
    67             new GetRolesRequestHandler( $use_case_manager->get_roles_by_id_use_case() ),
    68             new RoleSyncRequestHandler( $use_case_manager->sync_roles_use_case() ),
    69             new GetPagesRequestHandler( $use_case_manager->get_pages_by_id_use_case() ),
    70             new PageSyncRequestHandler( $use_case_manager->sync_pages_use_case() ),
    71             new GetPageContentsRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
    72             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() ),
    74         ];
    75     }
     44    public function __construct( UseCaseManager $use_case_manager ) {
     45        $this->request_handlers = [
     46            new AndroidAssetLinkRequestHandler( $use_case_manager->get_android_asset_link_use_case() ),
     47            new AppleAppSiteAssociationRequestHandler( $use_case_manager->get_apple_app_site_association_use_case() ),
     48            new LogRequestHandler( $use_case_manager->get_logs_use_case() ),
     49            new InfoRequestHandler( $use_case_manager->get_blog_info_use_case() ),
     50            new PostSyncRequestHandler( $use_case_manager->posts()->get_sync_posts_use_case() ),
     51            new GetPostsRequestHandler( $use_case_manager->get_posts_by_id_use_case() ),
     52            new CategorySyncRequestHandler( $use_case_manager->sync_categories_use_case() ),
     53            new GetCategoriesRequestHandler( $use_case_manager->get_categories_by_id_use_case() ),
     54            new TagSyncRequestHandler( $use_case_manager->sync_tags_use_case() ),
     55            new GetTagsRequestHandler( $use_case_manager->get_tags_by_id_use_case() ),
     56            new GetAttachmentsRequestHandler( $use_case_manager->get_attachments_by_id_use_case() ),
     57            new AttachmentSyncRequestHandler( $use_case_manager->sync_attachments_use_case() ),
     58            new SyncRequestHandler( $use_case_manager->sync_all_use_case() ),
     59            new GetCommentsRequestHandler( $use_case_manager->get_comments_by_id_use_case() ),
     60            new CommentSyncRequestHandler( $use_case_manager->sync_comments_use_case() ),
     61            new UserSyncRequestHandler( $use_case_manager->sync_users_use_case() ),
     62            new GetUsersRequestHandler( $use_case_manager->get_users_by_id_use_case() ),
     63            new GetPostContentsRequestHandler( $use_case_manager->get_post_contents_by_id_use_case() ),
     64            new ClearLogRequestHandler( $use_case_manager->get_clear_logs_use_case() ),
     65            new AuthenticateUserRequestHandler( $use_case_manager->get_authenticate_user_use_case() ),
     66            new PullLocalPostContentRequestHandler( $use_case_manager->get_get_local_post_content_by_id_use_case() ),
     67            new CreateCommentRequestHandler( $use_case_manager->create_comment_use_case() ),
     68            new GetRolesRequestHandler( $use_case_manager->get_roles_by_id_use_case() ),
     69            new RoleSyncRequestHandler( $use_case_manager->sync_roles_use_case() ),
     70            new GetPagesRequestHandler( $use_case_manager->get_pages_by_id_use_case() ),
     71            new PageSyncRequestHandler( $use_case_manager->sync_pages_use_case() ),
     72            new GetPageContentsRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
     73            new PullLocalPageContentRequestHandler( $use_case_manager->pages()->get_local_page_content_by_id_use_case() ),
     74            new GetPageContentRequestHandler( $use_case_manager->pages()->get_page_contents_by_id_use_case() ),
     75            new SavePostSyncBatchSizeHandler( $use_case_manager->posts()->get_save_post_sync_batch_size_use_case() )
     76        ];
     77    }
    7678
    77     public function handle_request( PluginRequest $request ): PluginResponse {
    78         foreach ( $this->request_handlers as $request_handler ) {
    79             if ( $request_handler instanceof RequestHandler ) {
    80                 if ( $request_handler->can_handle_request( $request ) ) {
    81                     return $request_handler->handle_request( $request );
    82                 }
    83             }
    84         }
     79    public function handle_request( PluginRequest $request ): PluginResponse {
     80        foreach ( $this->request_handlers as $request_handler ) {
     81            if ( $request_handler instanceof RequestHandler ) {
     82                if ( $request_handler->can_handle_request( $request ) ) {
     83                    return $request_handler->handle_request( $request );
     84                }
     85            }
     86        }
    8587
    86         Logger::error( "Did not find handler for action: " . $request->get_action() );
     88        Logger::error( "Did not find handler for action: " . $request->get_action() );
    8789
    88         return PluginResponse::plugin_response()->status( 404 );
    89     }
     90        return PluginResponse::plugin_response()->status( 404 );
     91    }
    9092}
  • appful-app/trunk/includes/api/dtos/BlogHooksDto.php

    r2978062 r3039311  
    44
    55class BlogHooksDto {
    6     public ?string $create_comment;
    7     public ?string $authenticate_user;
    8     public ?string $get_page_content;
     6    public ?string $create_comment;
     7    public ?string $authenticate_user;
     8    public ?string $get_page_content;
    99
    10     public function __construct(
    11         ?string $create_comment,
    12         ?string $authenticate_user,
    13         ?string $get_page_content
    14     ) {
    15         $this->create_comment    = $create_comment;
    16         $this->authenticate_user = $authenticate_user;
    17         $this->get_page_content  = $get_page_content;
    18     }
     10    public function __construct(
     11        ?string $create_comment,
     12        ?string $authenticate_user,
     13        ?string $get_page_content
     14    ) {
     15        $this->create_comment    = $create_comment;
     16        $this->authenticate_user = $authenticate_user;
     17        $this->get_page_content  = $get_page_content;
     18    }
    1919}
  • appful-app/trunk/includes/api/dtos/BlogInfoDto.php

    r3019874 r3039311  
    44
    55class BlogInfoDto {
    6     public string $hostname;
    7     public string $site_url;
    8     public array $languages;
    9     public string $token;
    10     public ?BlogHooksDto $hooks;
    11     public string $version;
    12     public ?BlogStatsDto $stats;
     6    public string $hostname;
     7    public string $site_url;
     8    public array $languages;
     9    public string $token;
     10    public ?BlogHooksDto $hooks;
     11    public string $version;
     12    public ?BlogStatsDto $stats;
     13    public ?BlogSettingsDto $settings;
    1314
    14     public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks, string $version, ?BlogStatsDto $stats ) {
    15         $this->hostname  = $hostname;
    16         $this->site_url  = $site_url;
    17         $this->languages = $languages;
    18         $this->token     = $token;
    19         $this->hooks     = $hooks;
    20         $this->version   = $version;
    21         $this->stats     = $stats;
    22     }
     15    public function __construct( string $hostname, string $site_url, array $languages, string $token, ?BlogHooksDto $hooks, string $version, ?BlogStatsDto $stats, ?BlogSettingsDto $settings ) {
     16        $this->hostname  = $hostname;
     17        $this->site_url  = $site_url;
     18        $this->languages = $languages;
     19        $this->token     = $token;
     20        $this->hooks     = $hooks;
     21        $this->version   = $version;
     22        $this->stats     = $stats;
     23        $this->settings  = $settings;
     24    }
    2325}
  • appful-app/trunk/includes/api/handlers/CreateCommentRequestHandler.php

    r3018629 r3039311  
    1212
    1313class CreateCommentRequestHandler implements RequestHandler {
    14     private CreateCommentUseCase $create_comment_use_case;
     14    private CreateCommentUseCase $create_comment_use_case;
    1515
    16     public function __construct(
     16    public function __construct(
    1717        CreateCommentUseCase $create_comment_use_case
    18     ) {
    19         $this->create_comment_use_case = $create_comment_use_case;
    20     }
     18    ) {
     19        $this->create_comment_use_case = $create_comment_use_case;
     20    }
    2121
    22     public function can_handle_request( PluginRequest $request ): bool {
    23         return $request->get_action() == Endpoints::$CREATE_COMMENT_HOOK;
    24     }
     22    public function can_handle_request( PluginRequest $request ): bool {
     23        return $request->get_action() == Endpoints::$CREATE_COMMENT_HOOK;
     24    }
    2525
    2626    public function handle_request( PluginRequest $request ): PluginResponse {
     
    3131
    3232        // required fields
    33         if (!isset($data["username"], $data["email"], $data["content"], $data["post_id"])) {
     33        if ( ! isset( $data["username"], $data["email"], $data["content"], $data["post_id"] ) ) {
    3434            Logger::error( "Some parameters for create comment are missing" );
     35
    3536            return PluginResponse::plugin_response()->status( 400 );  // Bad Request
    3637        }
    3738
    3839        // sanitize fields
    39         $username  = sanitize_text_field( $data["username"] );
    40         $email     = sanitize_text_field( $data["email"] );
    41         $content   = sanitize_text_field( $data["content"] );
    42         $post_id   = intval($data["post_id"]);
     40        $username = sanitize_text_field( $data["username"] );
     41        $email    = sanitize_text_field( $data["email"] );
     42        $content  = sanitize_text_field( $data["content"] );
     43        $post_id  = intval( $data["post_id"] );
    4344
    4445        // optional field
    45         $parent_id = isset($data["parent_id"]) ? intval($data["parent_id"]) : null;
     46        $parent_id = isset( $data["parent_id"] ) ? intval( $data["parent_id"] ) : null;
    4647
    4748        $request = new CreateCommentRequest( $username, $email, $content, $post_id, $parent_id );
     
    5051        if ( $comment == null ) {
    5152            Logger::error( "Creating comment failed" );
     53
    5254            return PluginResponse::plugin_response()->status( 503 );
    5355        }
    5456
    55         $comment_dto = CommentMapper::to_dto($comment);
     57        $comment_dto = CommentMapper::to_dto( $comment );
    5658
    5759        return PluginResponse::plugin_response()->body( $comment_dto );
  • appful-app/trunk/includes/api/handlers/GetPostContentsRequestHandler.php

    r3018629 r3039311  
    1212
    1313class GetPostContentsRequestHandler implements RequestHandler {
    14     private GetPostContentsByIdUseCase $get_post_contents_by_id_use_case;
     14    private GetPostContentsByIdUseCase $get_post_contents_by_id_use_case;
    1515
    16     public function __construct(
    17         GetPostContentsByIdUseCase $get_post_contents_by_id_use_case
    18     ) {
    19         $this->get_post_contents_by_id_use_case = $get_post_contents_by_id_use_case;
    20     }
     16    public function __construct(
     17        GetPostContentsByIdUseCase $get_post_contents_by_id_use_case
     18    ) {
     19        $this->get_post_contents_by_id_use_case = $get_post_contents_by_id_use_case;
     20    }
    2121
    22     public function can_handle_request( PluginRequest $request ): bool {
    23         return $request->get_action() == Endpoints::$GET_POST_CONTENTS;
    24     }
     22    public function can_handle_request( PluginRequest $request ): bool {
     23        return $request->get_action() == Endpoints::$GET_POST_CONTENTS;
     24    }
    2525
    26     public function handle_request( PluginRequest $request ): PluginResponse {
    27         Logger::debug( "Found handler for Appful request" );
     26    public function handle_request( PluginRequest $request ): PluginResponse {
     27        Logger::debug( "Found handler for Appful request" );
    2828
    29         // Because there could be a huge amount of posts, increase the timeout to 10min
    30         set_time_limit( 60 * 10 );
     29        // Because there could be a huge amount of posts, increase the timeout to 10min
     30        set_time_limit( 60 * 10 );
    3131
    32         if ( ! isset( $_GET['ids'] ) ) {
    33             return PluginResponse::plugin_response()->status( 400 );
    34         }
     32        if ( ! isset( $_GET['ids'] ) ) {
     33            return PluginResponse::plugin_response()->status( 400 );
     34        }
    3535
    36         $cleanedIds = sanitize_text_field( $_GET['ids'] );
    37         $ids        = array_map(
    38             function ( $id ) {
    39                 return absint( $id );
    40             },
    41             explode( ",", $cleanedIds )
    42         );
     36        $cleanedIds = sanitize_text_field( $_GET['ids'] );
     37        $ids        = array_map(
     38            function ( $id ) {
     39                return absint( $id );
     40            },
     41            explode( ",", $cleanedIds )
     42        );
    4343
    44         Logger::debug( "Sending post contents for ids " . json_encode( $ids ) );
     44        Logger::debug( "Sending post contents for ids " . json_encode( $ids ) );
    4545
    46         $postContents = $this->get_post_contents_by_id_use_case->invoke( $ids );
     46        $postContents = $this->get_post_contents_by_id_use_case->invoke( $ids );
    4747
    48         $post_content_dtos = array_map(
    49             function ( PostContent $post_content ) {
    50                 return PostContentMapper::to_dto( $post_content );
    51             },
    52             $postContents
    53         );
     48        $post_content_dtos = array_map(
     49            function ( PostContent $post_content ) {
     50                return PostContentMapper::to_dto( $post_content );
     51            },
     52            $postContents
     53        );
    5454
    55         return PluginResponse::plugin_response()->body( $post_content_dtos );
    56     }
     55        return PluginResponse::plugin_response()->body( $post_content_dtos );
     56    }
    5757}
  • appful-app/trunk/includes/api/mapper/BlogInfoMapper.php

    r3028218 r3039311  
    77
    88class BlogInfoMapper {
    9     public static function to_dto( BlogInfo $blog_info ): BlogInfoDto {
    10         if ( $blog_info->get_stats() == null ) {
    11             $stats = null;
    12         } else {
    13             $stats = BlogStatsMapper::to_dto( $blog_info->get_stats() );
    14         }
     9    public static function to_dto( BlogInfo $blog_info ): BlogInfoDto {
     10        if ( $blog_info->get_stats() == null ) {
     11            $stats = null;
     12        } else {
     13            $stats = BlogStatsMapper::to_dto( $blog_info->get_stats() );
     14        }
    1515
    16         if($blog_info->get_hooks() == null) {
    17             $hooks = null;
    18         } else {
    19             $hooks = BlogHooksMapper::to_dto( $blog_info->get_hooks() );
    20         }
     16        if ( $blog_info->get_hooks() == null ) {
     17            $hooks = null;
     18        } else {
     19            $hooks = BlogHooksMapper::to_dto( $blog_info->get_hooks() );
     20        }
    2121
    22         return new BlogInfoDto(
    23             $blog_info->get_hostname(),
    24             $blog_info->get_site_url(),
    25             $blog_info->get_languages(),
    26             $blog_info->get_token(),
    27             $hooks,
    28             "3.1.21",
    29             $stats
    30         );
    31     }
     22        if ( $blog_info->get_settings() == null ) {
     23            $settings = null;
     24        } else {
     25            $settings = BlogSettingsMapper::to_dto( $blog_info->get_settings() );
     26        }
     27
     28        return new BlogInfoDto(
     29            $blog_info->get_hostname(),
     30            $blog_info->get_site_url(),
     31            $blog_info->get_languages(),
     32            $blog_info->get_token(),
     33            $hooks,
     34            "3.1.22",
     35            $stats,
     36            $settings
     37        );
     38    }
    3239}
  • appful-app/trunk/includes/domain/BlogInfo.php

    r3019874 r3039311  
    44
    55class BlogInfo {
    6     private string $hostname = "";
    7     private string $site_url = "";
    8     private array $languages = [];
    9     private string $token = "";
    10     private ?BlogHooks $hooks = null;
    11     private ?BlogStats $stats = null;
     6    private string $hostname = "";
     7    private string $site_url = "";
     8    private array $languages = [];
     9    private string $token = "";
     10    private ?BlogHooks $hooks = null;
     11    private ?BlogStats $stats = null;
     12    private ?BlogSettings $settings = null;
    1213
    13     public static function blog_info(
    14         string $hostname = "",
    15         string $site_url = "",
    16         array $languages = [],
    17         string $token = "",
    18         ?BlogHooks $hooks = null,
    19         ?BlogStats $stats = null
    20     ): BlogInfo {
    21         return ( new BlogInfo() )
    22             ->hostname( $hostname )
    23             ->site_url( $site_url )
    24             ->languages( $languages )
    25             ->token( $token )
    26             ->hooks( $hooks )
    27             ->stats( $stats );
    28     }
     14    private function __construct() {
     15    }
    2916
    30     public function languages( array $languages ): BlogInfo {
    31         $this->languages = $languages;
     17    public static function blog_info(): BlogInfo {
     18        return new BlogInfo();
     19    }
    3220
    33         return $this;
    34     }
     21    public function languages( array $languages ): BlogInfo {
     22        $this->languages = $languages;
    3523
    36     public function site_url( string $site_url ): BlogInfo {
    37         $this->site_url = $site_url;
     24        return $this;
     25    }
    3826
    39         return $this;
    40     }
     27    public function settings( ?BlogSettings $settings ): BlogInfo {
     28        $this->settings = $settings;
    4129
    42     public function hostname( string $hostname ): BlogInfo {
    43         $this->hostname = $hostname;
     30        return $this;
     31    }
    4432
    45         return $this;
    46     }
     33    public function site_url( string $site_url ): BlogInfo {
     34        $this->site_url = $site_url;
    4735
    48     public function token( string $token ): BlogInfo {
    49         $this->token = $token;
     36        return $this;
     37    }
    5038
    51         return $this;
    52     }
     39    public function hostname( string $hostname ): BlogInfo {
     40        $this->hostname = $hostname;
    5341
    54     public function hooks( ?BlogHooks $hooks ): BlogInfo {
    55         $this->hooks = $hooks;
     42        return $this;
     43    }
    5644
    57         return $this;
    58     }
     45    public function token( string $token ): BlogInfo {
     46        $this->token = $token;
    5947
    60     public function stats( ?BlogStats $stats ): BlogInfo {
    61         $this->stats = $stats;
     48        return $this;
     49    }
    6250
    63         return $this;
    64     }
     51    public function hooks( ?BlogHooks $hooks ): BlogInfo {
     52        $this->hooks = $hooks;
    6553
    66     public function get_site_url(): string {
    67         return $this->site_url;
    68     }
     54        return $this;
     55    }
    6956
    70     public function get_languages(): array {
    71         return $this->languages;
    72     }
     57    public function stats( ?BlogStats $stats ): BlogInfo {
     58        $this->stats = $stats;
    7359
    74     public function get_hostname(): string {
    75         return $this->hostname;
    76     }
     60        return $this;
     61    }
    7762
    78     public function get_token(): string {
    79         return $this->token;
    80     }
     63    public function get_site_url(): string {
     64        return $this->site_url;
     65    }
    8166
    82     public function get_hooks(): ?BlogHooks {
    83         return $this->hooks;
    84     }
     67    public function get_languages(): array {
     68        return $this->languages;
     69    }
    8570
    86     public function get_stats(): ?BlogStats {
    87         return $this->stats;
    88     }
     71    public function get_hostname(): string {
     72        return $this->hostname;
     73    }
     74
     75    public function get_token(): string {
     76        return $this->token;
     77    }
     78
     79    public function get_hooks(): ?BlogHooks {
     80        return $this->hooks;
     81    }
     82
     83    public function get_stats(): ?BlogStats {
     84        return $this->stats;
     85    }
     86
     87    public function get_settings(): ?BlogSettings {
     88        return $this->settings;
     89    }
    8990}
  • appful-app/trunk/includes/helper/Constants.php

    r3027388 r3039311  
    44
    55class Constants {
    6     public static bool $APPFUL_DEBUG = false;
     6    public static bool $APPFUL_DEBUG = false;
    77
    8     public static string $PLUGIN_ROOT_DIR = "/appful-app";
    9     public static string $PLUGIN_ROOT_FILE = "/appful-app.php";
     8    public static string $PLUGIN_ROOT_DIR = "/appful-app";
     9    public static string $PLUGIN_ROOT_FILE = "/appful-app.php";
    1010
    11     public static string $APPFUL_SESSION_ID_KEY = "appful-app_session_id";
    12     public static string $APPFUL_USERNAME_KEY = "appful-app_username";
    13     public static string $APPFUL_BLOG_ID_KEY = "appful-app_blog_id";
     11    public static string $APPFUL_SESSION_ID_KEY = "appful-app_session_id";
     12    public static string $APPFUL_USERNAME_KEY = "appful-app_username";
     13    public static string $APPFUL_BLOG_ID_KEY = "appful-app_blog_id";
    1414
    15     public static string $APPFUL_CLIENT_SESSION_KEY = "appful-app_client_token_id";
    16     public static string $APPFUL_LAST_ERROR_KEY = "appful-app_last_error";
    17     public static string $APPFUL_APPLE_APP_SITE_ASSOCIATION = "appful-app_apple_app_site_association";
    18     public static string $APPFUL_ANDROID_ASSET_LINK = "appful-app_android_asset_link";
     15    public static string $APPFUL_CLIENT_SESSION_KEY = "appful-app_client_token_id";
     16    public static string $APPFUL_LAST_ERROR_KEY = "appful-app_last_error";
     17    public static string $APPFUL_APPLE_APP_SITE_ASSOCIATION = "appful-app_apple_app_site_association";
     18    public static string $APPFUL_ANDROID_ASSET_LINK = "appful-app_android_asset_link";
     19    public static string $APPFUL_POST_SYNC_BATCH_SIZE_KEY = "appful-app_post_sync_batch_size";
    1920
    20     public static string $APPFUL_TERM_IMAGE_META_KEY = "appful-app_term_image";
     21    public static string $APPFUL_TERM_IMAGE_META_KEY = "appful-app_term_image";
    2122
    22     public static string $APPFUL_TAXONOMY_NAME = "appful";
    23     public static string $APPFUL_TAXONOMY_PUSH_TERM_NAME = "Don't send notification";
    24     public static string $APPFUL_TAXONOMY_PUSH_TERM_SLUG = "push";
     23    public static string $APPFUL_TAXONOMY_NAME = "appful";
     24    public static string $APPFUL_TAXONOMY_PUSH_TERM_NAME = "Don't send notification";
     25    public static string $APPFUL_TAXONOMY_PUSH_TERM_SLUG = "push";
    2526
    2627    public static string $APPFUL_API_URL = "https://api.wordpress.appful.io";
    2728
    28     public static string $BLOG_PATH = "/blogs";
    29     public static string $APPFUL_USER_PATH = "/appfulUsers";
    30     public static string $USER_PATH = "/users";
    31     public static string $POST_PATH = "/posts";
    32     public static string $APP_SETTINGS_PATH = "/app/settings";
    33     public static string $PAGE_PATH = "/pages";
    34     public static string $COMMENT_PATH = "/comments";
    35     public static string $ATTACHMENT_PATH = "/attachments";
    36     public static string $TAXONOMY_PATH = "/taxonomies";
    37     public static string $ROLE_PATH = "/roles";
     29    public static string $BLOG_PATH = "/blogs";
     30    public static string $APPFUL_USER_PATH = "/appfulUsers";
     31    public static string $USER_PATH = "/users";
     32    public static string $POST_PATH = "/posts";
     33    public static string $APP_SETTINGS_PATH = "/app/settings";
     34    public static string $PAGE_PATH = "/pages";
     35    public static string $COMMENT_PATH = "/comments";
     36    public static string $ATTACHMENT_PATH = "/attachments";
     37    public static string $TAXONOMY_PATH = "/taxonomies";
     38    public static string $ROLE_PATH = "/roles";
    3839
    39     public static string $API_VERSION_1 = "/v1";
     40    public static string $API_VERSION_1 = "/v1";
    4041
    41     public static int $POST_SYNC_CHUNK_SIZE = 70;
    42     public static int $PAGE_SYNC_CHUNK_SIZE = 10;
    43     public static int $COMMENT_SYNC_CHUNK_SIZE = 100;
    44     public static int $ATTACHMENT_SYNC_CHUNK_SIZE = 200;
    45     public static int $USER_SYNC_CHUNK_SIZE = 50;
    46     public static int $CATEGORY_SYNC_CHUNK_SIZE = 50;
    47     public static int $TAG_SYNC_CHUNK_SIZE = 50;
    48     public static int $ROLE_SYNC_CHUNK_SIZE = 50;
     42    public static int $POST_SYNC_CHUNK_SIZE = 10;
     43    public static int $PAGE_SYNC_CHUNK_SIZE = 5;
     44    public static int $COMMENT_SYNC_CHUNK_SIZE = 15;
     45    public static int $ATTACHMENT_SYNC_CHUNK_SIZE = 50;
     46    public static int $USER_SYNC_CHUNK_SIZE = 15;
     47    public static int $CATEGORY_SYNC_CHUNK_SIZE = 15;
     48    public static int $TAG_SYNC_CHUNK_SIZE = 15;
     49    public static int $ROLE_SYNC_CHUNK_SIZE = 15;
    4950}
  • appful-app/trunk/includes/use_cases/post/PostUseCaseManager.php

    r3027388 r3039311  
    66
    77class PostUseCaseManager {
    8     private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
    9     private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
    10     private GetPostSyncItemUseCase $get_post_sync_item_use_case;
     8    private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
     9    private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
     10    private GetPostSyncItemUseCase $get_post_sync_item_use_case;
    1111
    12     private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
    13     private SendPostSyncUseCase $send_post_sync_use_case;
     12    private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     13    private SendPostSyncUseCase $send_post_sync_use_case;
    1414
    15     private SyncTaxonomyPostsUseCase $sync_taxonomy_posts_use_case;
    16     private SyncPostsUseCase $sync_posts_use_case;
    17     private SyncPostUseCase $sync_post_use_case;
     15    private SyncTaxonomyPostsUseCase $sync_taxonomy_posts_use_case;
     16    private SyncPostsUseCase $sync_posts_use_case;
     17    private SyncPostUseCase $sync_post_use_case;
    1818
    19     public function __construct( BackendClient $backend_client ) {
    20         $this->get_post_sync_item_use_case           = new GetPostSyncItemUseCase();
    21         $this->get_post_sync_data_use_case           = new GetPostSyncItemsUseCase();
    22         $this->get_taxonomy_post_sync_items_use_case = new GetTaxonomyPostSyncItemsUseCase();
     19    private GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case;
     20    private SavePostSyncBatchSizeUseCase $save_post_sync_batch_size_use_case;
    2321
    24         $this->send_post_chunk_sync_use_case = new SendPostChunkSyncUseCase( $backend_client );
    25         $this->send_post_sync_use_case       = new SendPostSyncUseCase( $backend_client );
     22    public function __construct( BackendClient $backend_client ) {
     23        $this->get_post_sync_batch_size_use_case  = new GetPostSyncBatchSizeUseCase();
     24        $this->save_post_sync_batch_size_use_case = new SavePostSyncBatchSizeUseCase();
    2625
    27         $this->sync_posts_use_case          = new SyncPostsUseCase( $this->get_post_sync_data_use_case, $this->send_post_chunk_sync_use_case );
    28         $this->sync_post_use_case           = new SyncPostUseCase( $this->get_post_sync_item_use_case, $this->send_post_sync_use_case );
    29         $this->sync_taxonomy_posts_use_case = new SyncTaxonomyPostsUseCase( $this->get_taxonomy_post_sync_items_use_case, $this->send_post_chunk_sync_use_case );
    30     }
     26        $this->get_post_sync_item_use_case           = new GetPostSyncItemUseCase();
     27        $this->get_post_sync_data_use_case           = new GetPostSyncItemsUseCase();
     28        $this->get_taxonomy_post_sync_items_use_case = new GetTaxonomyPostSyncItemsUseCase();
    3129
    32     public function get_sync_post_use_case(): SyncPostUseCase {
    33         return $this->sync_post_use_case;
    34     }
     30        $this->send_post_chunk_sync_use_case = new SendPostChunkSyncUseCase( $backend_client );
     31        $this->send_post_sync_use_case       = new SendPostSyncUseCase( $backend_client );
    3532
    36     public function get_sync_posts_use_case(): SyncPostsUseCase {
    37         return $this->sync_posts_use_case;
    38     }
     33        $this->sync_posts_use_case          = new SyncPostsUseCase( $this->get_post_sync_data_use_case, $this->send_post_chunk_sync_use_case, $this->get_post_sync_batch_size_use_case );
     34        $this->sync_post_use_case           = new SyncPostUseCase( $this->get_post_sync_item_use_case, $this->send_post_sync_use_case );
     35        $this->sync_taxonomy_posts_use_case = new SyncTaxonomyPostsUseCase( $this->get_taxonomy_post_sync_items_use_case, $this->send_post_chunk_sync_use_case, $this->get_post_sync_batch_size_use_case );
     36    }
    3937
    40     public function get_sync_taxonomy_posts_use_case(): SyncTaxonomyPostsUseCase {
    41         return $this->sync_taxonomy_posts_use_case;
    42     }
     38    public function get_sync_post_use_case(): SyncPostUseCase {
     39        return $this->sync_post_use_case;
     40    }
     41
     42    public function get_sync_posts_use_case(): SyncPostsUseCase {
     43        return $this->sync_posts_use_case;
     44    }
     45
     46    public function get_sync_taxonomy_posts_use_case(): SyncTaxonomyPostsUseCase {
     47        return $this->sync_taxonomy_posts_use_case;
     48    }
     49
     50    public function get_post_sync_batch_size_use_case(): GetPostSyncBatchSizeUseCase {
     51        return $this->get_post_sync_batch_size_use_case;
     52    }
     53
     54    public function get_save_post_sync_batch_size_use_case(): SavePostSyncBatchSizeUseCase {
     55        return $this->save_post_sync_batch_size_use_case;
     56    }
    4357}
  • appful-app/trunk/includes/use_cases/post/SyncPostsUseCase.php

    r3027388 r3039311  
    44
    55use AppfulPlugin\Domain\SyncChunk;
    6 use AppfulPlugin\Helper\Constants;
    76use AppfulPlugin\Wp\WPPostManager;
    87
    98class SyncPostsUseCase {
    10     private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
    11     private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     9    private GetPostSyncItemsUseCase $get_post_sync_data_use_case;
     10    private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     11    private GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case;
    1212
    13     public function __construct(
    14         GetPostSyncItemsUseCase $get_post_sync_data_use_case,
    15         SendPostChunkSyncUseCase $send_post_chunk_sync_use_case
    16     ) {
    17         $this->get_post_sync_data_use_case   = $get_post_sync_data_use_case;
    18         $this->send_post_chunk_sync_use_case = $send_post_chunk_sync_use_case;
    19     }
     13    public function __construct(
     14        GetPostSyncItemsUseCase $get_post_sync_data_use_case,
     15        SendPostChunkSyncUseCase $send_post_chunk_sync_use_case,
     16        GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case
     17    ) {
     18        $this->get_post_sync_data_use_case       = $get_post_sync_data_use_case;
     19        $this->send_post_chunk_sync_use_case     = $send_post_chunk_sync_use_case;
     20        $this->get_post_sync_batch_size_use_case = $get_post_sync_batch_size_use_case;
     21    }
    2022
    21     public function invoke() {
    22         $sync_id    = uniqid();
    23         $batch_size = WPPostManager::get_post_count();
    24         $chunk_size = Constants::$POST_SYNC_CHUNK_SIZE;
     23    public function invoke() {
     24        $sync_id    = uniqid();
     25        $batch_size = WPPostManager::get_post_count();
     26        $chunk_size = $this->get_post_sync_batch_size_use_case->invoke();
    2527
    26         $chunk = 0;
    27         while ( true ) {
    28             $post_sync_items = $this->get_post_sync_data_use_case->invoke($chunk * $chunk_size, $chunk_size);
     28        $chunk = 0;
     29        while ( true ) {
     30            $post_sync_items = $this->get_post_sync_data_use_case->invoke( $chunk * $chunk_size, $chunk_size );
    2931
    30             $this->send_post_chunk_sync_use_case->invoke(
    31                 SyncChunk::syncChunk()
    32                          ->batch_id( $sync_id )
    33                          ->chunk_size( $chunk_size )
    34                          ->batch_size( $batch_size )
    35                          ->chunk_items( $post_sync_items )
    36             );
     32            $this->send_post_chunk_sync_use_case->invoke(
     33                SyncChunk::syncChunk()
     34                         ->batch_id( $sync_id )
     35                         ->chunk_size( $chunk_size )
     36                         ->batch_size( $batch_size )
     37                         ->chunk_items( $post_sync_items )
     38            );
    3739
    38             $chunk ++;
     40            $chunk ++;
    3941
    40             if ( count( $post_sync_items ) < $chunk_size ) {
    41                 break;
    42             }
    43         }
    44     }
     42            if ( count( $post_sync_items ) < $chunk_size ) {
     43                break;
     44            }
     45        }
     46    }
    4547}
  • appful-app/trunk/includes/use_cases/post/SyncTaxonomyPostsUseCase.php

    r3027388 r3039311  
    44
    55use AppfulPlugin\Domain\SyncChunk;
    6 use AppfulPlugin\Helper\Constants;
    76use AppfulPlugin\Wp\WPPostManager;
    87
    98class SyncTaxonomyPostsUseCase {
    10     private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
    11     private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     9    private GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case;
     10    private SendPostChunkSyncUseCase $send_post_chunk_sync_use_case;
     11    private GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case;
    1212
    13     public function __construct(
    14         GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case,
    15         SendPostChunkSyncUseCase $send_post_chunk_sync_use_case
    16     ) {
    17         $this->get_taxonomy_post_sync_items_use_case = $get_taxonomy_post_sync_items_use_case;
    18         $this->send_post_chunk_sync_use_case         = $send_post_chunk_sync_use_case;
    19     }
     13    public function __construct(
     14        GetTaxonomyPostSyncItemsUseCase $get_taxonomy_post_sync_items_use_case,
     15        SendPostChunkSyncUseCase $send_post_chunk_sync_use_case,
     16        GetPostSyncBatchSizeUseCase $get_post_sync_batch_size_use_case
     17    ) {
     18        $this->get_taxonomy_post_sync_items_use_case = $get_taxonomy_post_sync_items_use_case;
     19        $this->send_post_chunk_sync_use_case         = $send_post_chunk_sync_use_case;
     20        $this->get_post_sync_batch_size_use_case     = $get_post_sync_batch_size_use_case;
     21    }
    2022
    21     public function invoke( string $taxonomy, string $term_slug ) {
    22         $sync_id    = uniqid();
    23         $batch_size = WPPostManager::get_taxonomy_post_count( $taxonomy, $term_slug );
    24         $chunk_size = Constants::$POST_SYNC_CHUNK_SIZE;
     23    public function invoke( string $taxonomy, string $term_slug ) {
     24        $sync_id    = uniqid();
     25        $batch_size = WPPostManager::get_taxonomy_post_count( $taxonomy, $term_slug );
     26        $chunk_size = $this->get_post_sync_batch_size_use_case->invoke();
    2527
    26         $chunk = 0;
    27         while ( true ) {
    28             $post_sync_items = $this->get_taxonomy_post_sync_items_use_case->invoke( $taxonomy, $term_slug, $chunk * $chunk_size, $chunk_size );
     28        $chunk = 0;
     29        while ( true ) {
     30            $post_sync_items = $this->get_taxonomy_post_sync_items_use_case->invoke( $taxonomy, $term_slug, $chunk * $chunk_size, $chunk_size );
    2931
    30             $this->send_post_chunk_sync_use_case->invoke(
    31                 SyncChunk::syncChunk()
    32                          ->batch_id( $sync_id )
    33                          ->chunk_size( $chunk_size )
    34                          ->batch_size( $batch_size )
    35                          ->chunk_items( $post_sync_items )
    36             );
     32            $this->send_post_chunk_sync_use_case->invoke(
     33                SyncChunk::syncChunk()
     34                         ->batch_id( $sync_id )
     35                         ->chunk_size( $chunk_size )
     36                         ->batch_size( $batch_size )
     37                         ->chunk_items( $post_sync_items )
     38            );
    3739
    38             $chunk ++;
     40            $chunk ++;
    3941
    40             if ( count( $post_sync_items ) < $chunk_size ) {
    41                 break;
    42             }
    43         }
    44     }
     42            if ( count( $post_sync_items ) < $chunk_size ) {
     43                break;
     44            }
     45        }
     46    }
    4547}
  • appful-app/trunk/includes/wp/WPBlogManager.php

    r3019874 r3039311  
    66use AppfulPlugin\Domain\BlogHooks;
    77use AppfulPlugin\Domain\BlogInfo;
     8use AppfulPlugin\Domain\BlogSettings;
    89use AppfulPlugin\Domain\BlogStats;
    910use AppfulPlugin\Helper\ClientTokenManager;
     11use AppfulPlugin\UseCases\Post\GetPostSyncBatchSizeUseCase;
    1012use AppfulPlugin\Wp\Plugins\LanguageHelper;
    1113
    1214class WPBlogManager {
    13     public static function get_blog_info(): BlogInfo {
    14         return BlogInfo::blog_info()
    15                        ->hostname( self::get_hostname() )
    16                        ->site_url( self::get_site_url() )
    17                        ->languages( self::get_languages() )
    18                        ->token( ClientTokenManager::getToken() ?? ClientTokenManager::createSession() )
    19                        ->hooks( self::get_hooks() )
    20                        ->stats( self::get_stats() );
    21     }
     15    public static function get_blog_info(): BlogInfo {
     16        return BlogInfo::blog_info()
     17                       ->hostname( self::get_hostname() )
     18                       ->site_url( self::get_site_url() )
     19                       ->languages( self::get_languages() )
     20                       ->token( ClientTokenManager::getToken() ?? ClientTokenManager::createSession() )
     21                       ->hooks( self::get_hooks() )
     22                       ->stats( self::get_stats() )
     23                       ->settings( self::get_settings() );
     24    }
    2225
    23     private static function get_hooks(): BlogHooks {
    24         return BlogHooks::init()
    25                         ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT_HOOK )
    26                         ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER_HOOK )
    27                         ->get_page_content( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$GET_PAGE_CONTENT_HOOK );
    28     }
     26    private static function get_hooks(): BlogHooks {
     27        return BlogHooks::init()
     28                        ->create_comment( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$CREATE_COMMENT_HOOK )
     29                        ->authenticate_user( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$AUTHENTICATE_USER_HOOK )
     30                        ->get_page_content( self::get_site_url() . Endpoints::$HOOK . "/" . Endpoints::$GET_PAGE_CONTENT_HOOK );
     31    }
    2932
    30     private static function get_stats(): BlogStats {
    31         return BlogStats::init()
    32                         ->attachment_count( WPAttachmentManager::get_attachment_count() )
    33                         ->post_count( WPPostManager::get_post_count() )
    34                         ->user_count( WPUserManager::get_user_count() )
    35                         ->page_count( WPPageManager::get_page_count() )
    36                         ->comment_count( WPCommentManager::get_comment_count() );
    37     }
     33    private static function get_stats(): BlogStats {
     34        return BlogStats::init()
     35                        ->attachment_count( WPAttachmentManager::get_attachment_count() )
     36                        ->post_count( WPPostManager::get_post_count() )
     37                        ->user_count( WPUserManager::get_user_count() )
     38                        ->page_count( WPPageManager::get_page_count() )
     39                        ->comment_count( WPCommentManager::get_comment_count() );
     40    }
    3841
    39     private static function get_hostname(): string {
    40         $siteUrl = self::get_site_url();
     42    private static function get_settings(): BlogSettings {
     43        return BlogSettings::init()
     44                           ->post_sync_batch_size( ( new GetPostSyncBatchSizeUseCase() )->invoke() );
     45    }
    4146
    42         return parse_url( $siteUrl, PHP_URL_HOST );
    43     }
     47    private static function get_hostname(): string {
     48        $siteUrl = self::get_site_url();
    4449
    45     private static function get_site_url(): string {
    46         return get_site_url();
    47     }
     50        return parse_url( $siteUrl, PHP_URL_HOST );
     51    }
    4852
    49     private static function get_languages(): array {
    50         return LanguageHelper::get_languages();
    51     }
     53    private static function get_site_url(): string {
     54        return get_site_url();
     55    }
    5256
    53     public static function get_blog_language(): string {
    54         return substr( get_bloginfo( "language" ), 0, 2 ) ?? "";
    55     }
     57    private static function get_languages(): array {
     58        return LanguageHelper::get_languages();
     59    }
     60
     61    public static function get_blog_language(): string {
     62        return substr( get_bloginfo( "language" ), 0, 2 ) ?? "";
     63    }
    5664}
  • appful-app/trunk/includes/wp/WPOptionsManager.php

    r2936340 r3039311  
    66
    77class WPOptionsManager {
    8     private static function save_option( string $key, ?string $value ): bool {
    9         if ( $value == null ) {
    10             return delete_option( $key );
    11         }
     8    private static function save_option( string $key, ?string $value ): bool {
     9        if ( $value == null ) {
     10            return delete_option( $key );
     11        }
    1212
    13         $current_value = get_option( $key, null );
    14         if ( $current_value != null ) {
    15             return update_option( $key, $value );
    16         } else {
    17             return add_option( $key, $value );
    18         }
    19     }
     13        $current_value = get_option( $key, null );
     14        if ( $current_value != null ) {
     15            return update_option( $key, $value );
     16        } else {
     17            return add_option( $key, $value );
     18        }
     19    }
    2020
    21     private static function get_option( string $key, $default = null ) {
    22         return get_option( $key, $default );
    23     }
     21    private static function get_option( string $key, $default = null ) {
     22        return get_option( $key, $default );
     23    }
    2424
    25     public static function save_app_site_association( string $value ) {
    26         self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, $value );
    27     }
     25    public static function save_app_site_association( string $value ) {
     26        self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, $value );
     27    }
    2828
    29     public static function get_apple_app_site_association(): ?string {
    30         return self::get_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION );
    31     }
     29    public static function get_apple_app_site_association(): ?string {
     30        return self::get_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION );
     31    }
    3232
    33     public static function delete_app_site_association(): void {
    34         self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, null );
    35     }
     33    public static function delete_app_site_association(): void {
     34        self::save_option( Constants::$APPFUL_APPLE_APP_SITE_ASSOCIATION, null );
     35    }
    3636
    37     public static function save_asset_link( string $value ) {
    38         self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, $value );
    39     }
     37    public static function save_asset_link( string $value ) {
     38        self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, $value );
     39    }
    4040
    41     public static function get_android_asset_link(): ?string {
    42         return self::get_option( Constants::$APPFUL_ANDROID_ASSET_LINK );
    43     }
     41    public static function get_android_asset_link(): ?string {
     42        return self::get_option( Constants::$APPFUL_ANDROID_ASSET_LINK );
     43    }
    4444
    45     public static function delete_asset_link(): void {
    46         self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, null );
    47     }
     45    public static function delete_asset_link(): void {
     46        self::save_option( Constants::$APPFUL_ANDROID_ASSET_LINK, null );
     47    }
    4848
    49     public static function save_session_id( string $session_id ): void {
    50         self::save_option( Constants::$APPFUL_SESSION_ID_KEY, $session_id );
    51     }
     49    public static function save_session_id( string $session_id ): void {
     50        self::save_option( Constants::$APPFUL_SESSION_ID_KEY, $session_id );
     51    }
    5252
    53     public static function get_session_id(): ?string {
    54         return self::get_option( Constants::$APPFUL_SESSION_ID_KEY );
    55     }
     53    public static function get_session_id(): ?string {
     54        return self::get_option( Constants::$APPFUL_SESSION_ID_KEY );
     55    }
    5656
    57     public static function delete_session_id(): void {
    58         self::save_option( Constants::$APPFUL_SESSION_ID_KEY, null );
    59     }
     57    public static function delete_session_id(): void {
     58        self::save_option( Constants::$APPFUL_SESSION_ID_KEY, null );
     59    }
    6060
    61     public static function save_username( string $username ): void {
    62         self::save_option( Constants::$APPFUL_USERNAME_KEY, $username );
    63     }
     61    public static function save_username( string $username ): void {
     62        self::save_option( Constants::$APPFUL_USERNAME_KEY, $username );
     63    }
    6464
    65     public static function get_username(): ?string {
    66         return self::get_option( Constants::$APPFUL_USERNAME_KEY );
    67     }
     65    public static function get_username(): ?string {
     66        return self::get_option( Constants::$APPFUL_USERNAME_KEY );
     67    }
    6868
    69     public static function delete_username(): void {
    70         self::save_option( Constants::$APPFUL_USERNAME_KEY, null );
    71     }
     69    public static function delete_username(): void {
     70        self::save_option( Constants::$APPFUL_USERNAME_KEY, null );
     71    }
    7272
    73     public static function save_blog_id( string $blog_id ): void {
    74         self::save_option( Constants::$APPFUL_BLOG_ID_KEY, $blog_id );
    75     }
     73    public static function save_blog_id( string $blog_id ): void {
     74        self::save_option( Constants::$APPFUL_BLOG_ID_KEY, $blog_id );
     75    }
    7676
    77     public static function get_blog_id(): ?string {
    78         return self::get_option( Constants::$APPFUL_BLOG_ID_KEY );
    79     }
     77    public static function get_blog_id(): ?string {
     78        return self::get_option( Constants::$APPFUL_BLOG_ID_KEY );
     79    }
    8080
    81     public static function delete_blog_id(): void {
    82         self::save_option( Constants::$APPFUL_BLOG_ID_KEY, null );
    83     }
     81    public static function delete_blog_id(): void {
     82        self::save_option( Constants::$APPFUL_BLOG_ID_KEY, null );
     83    }
    8484
    85     public static function save_client_token( string $client_session ): void {
    86         self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, $client_session );
    87     }
     85    public static function save_client_token( string $client_session ): void {
     86        self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, $client_session );
     87    }
    8888
    89     public static function get_client_token(): ?string {
    90         return self::get_option( Constants::$APPFUL_CLIENT_SESSION_KEY );
    91     }
     89    public static function get_client_token(): ?string {
     90        return self::get_option( Constants::$APPFUL_CLIENT_SESSION_KEY );
     91    }
    9292
    93     public static function delete_client_token(): void {
    94         self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, null );
    95     }
     93    public static function delete_client_token(): void {
     94        self::save_option( Constants::$APPFUL_CLIENT_SESSION_KEY, null );
     95    }
    9696
    97     public static function save_last_sync_error( string $error ): void {
    98         self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, $error );
    99     }
     97    public static function save_last_sync_error( string $error ): void {
     98        self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, $error );
     99    }
    100100
    101     public static function get_last_sync_error(): ?string {
    102         return self::get_option( Constants::$APPFUL_LAST_ERROR_KEY );
    103     }
     101    public static function get_last_sync_error(): ?string {
     102        return self::get_option( Constants::$APPFUL_LAST_ERROR_KEY );
     103    }
    104104
    105     public static function delete_last_sync_error(): void {
    106         self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, null );
    107     }
     105    public static function delete_last_sync_error(): void {
     106        self::save_option( Constants::$APPFUL_LAST_ERROR_KEY, null );
     107    }
    108108
    109     public static function clean() {
    110         self::delete_session_id();
    111         self::delete_blog_id();
    112         self::delete_username();
    113         self::delete_app_site_association();
    114         self::delete_asset_link();
    115         self::delete_client_token();
    116     }
     109    public static function save_post_sync_batch_size( int $size ): void {
     110        self::save_option( Constants::$APPFUL_POST_SYNC_BATCH_SIZE_KEY, $size );
     111    }
     112
     113    public static function get_post_sync_batch_size(): ?int {
     114        return self::get_option( Constants::$APPFUL_POST_SYNC_BATCH_SIZE_KEY );
     115    }
     116
     117    public static function delete_post_sync_batch_size(): void {
     118        self::save_option( Constants::$APPFUL_POST_SYNC_BATCH_SIZE_KEY, null );
     119    }
     120
     121    public static function clean() {
     122        self::delete_session_id();
     123        self::delete_blog_id();
     124        self::delete_username();
     125        self::delete_app_site_association();
     126        self::delete_asset_link();
     127        self::delete_client_token();
     128        self::delete_post_sync_batch_size();
     129    }
    117130}
  • appful-app/trunk/lib/vendor/composer/autoload_classmap.php

    r3027388 r3039311  
    1414    'AppfulPlugin\\Api\\Dtos\\BlogHooksDto' => $baseDir . '/../includes/api/dtos/BlogHooksDto.php',
    1515    'AppfulPlugin\\Api\\Dtos\\BlogInfoDto' => $baseDir . '/../includes/api/dtos/BlogInfoDto.php',
     16    'AppfulPlugin\\Api\\Dtos\\BlogSettingsDto' => $baseDir . '/../includes/api/dtos/BlogSettingsDto.php',
    1617    'AppfulPlugin\\Api\\Dtos\\BlogStatsDto' => $baseDir . '/../includes/api/dtos/BlogStatsDto.php',
    1718    'AppfulPlugin\\Api\\Dtos\\CategoryDto' => $baseDir . '/../includes/api/dtos/CategoryDto.php',
     
    5657    'AppfulPlugin\\Api\\Handlers\\RequestHandler' => $baseDir . '/../includes/api/handlers/RequestHandler.php',
    5758    'AppfulPlugin\\Api\\Handlers\\RoleSyncRequestHandler' => $baseDir . '/../includes/api/handlers/RoleSyncRequestHandler.php',
     59    'AppfulPlugin\\Api\\Handlers\\SavePostSyncBatchSizeHandler' => $baseDir . '/../includes/api/handlers/SavePostSyncBatchSizeHandler.php',
    5860    'AppfulPlugin\\Api\\Handlers\\SyncRequestHandler' => $baseDir . '/../includes/api/handlers/SyncRequestHandler.php',
    5961    'AppfulPlugin\\Api\\Handlers\\TagSyncRequestHandler' => $baseDir . '/../includes/api/handlers/TagSyncRequestHandler.php',
     
    6365    'AppfulPlugin\\Api\\Mapper\\BlogHooksMapper' => $baseDir . '/../includes/api/mapper/BlogHooksMapper.php',
    6466    'AppfulPlugin\\Api\\Mapper\\BlogInfoMapper' => $baseDir . '/../includes/api/mapper/BlogInfoMapper.php',
     67    'AppfulPlugin\\Api\\Mapper\\BlogSettingsMapper' => $baseDir . '/../includes/api/mapper/BlogSettingsMapper.php',
    6568    'AppfulPlugin\\Api\\Mapper\\BlogStatsMapper' => $baseDir . '/../includes/api/mapper/BlogStatsMapper.php',
    6669    'AppfulPlugin\\Api\\Mapper\\CategoryMapper' => $baseDir . '/../includes/api/mapper/CategoryMapper.php',
     
    8891    'AppfulPlugin\\Domain\\BlogHooks' => $baseDir . '/../includes/domain/BlogHooks.php',
    8992    'AppfulPlugin\\Domain\\BlogInfo' => $baseDir . '/../includes/domain/BlogInfo.php',
     93    'AppfulPlugin\\Domain\\BlogSettings' => $baseDir . '/../includes/domain/BlogSettings.php',
    9094    'AppfulPlugin\\Domain\\BlogStats' => $baseDir . '/../includes/domain/BlogStats.php',
    9195    'AppfulPlugin\\Domain\\Category' => $baseDir . '/../includes/domain/Category.php',
     
    166170    'AppfulPlugin\\UseCases\\Page\\PullLocalPageContentUseCase' => $baseDir . '/../includes/use_cases/page/PullLocalPageContentUseCase.php',
    167171    'AppfulPlugin\\UseCases\\PostDeleteUseCase' => $baseDir . '/../includes/use_cases/PostDeleteUseCase.php',
     172    'AppfulPlugin\\UseCases\\Post\\GetPostSyncBatchSizeUseCase' => $baseDir . '/../includes/use_cases/post/GetPostSyncBatchSizeUseCase.php',
    168173    'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemUseCase' => $baseDir . '/../includes/use_cases/post/GetPostSyncItemUseCase.php',
    169174    'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemsUseCase' => $baseDir . '/../includes/use_cases/post/GetPostSyncItemsUseCase.php',
    170175    'AppfulPlugin\\UseCases\\Post\\GetTaxonomyPostSyncItemsUseCase' => $baseDir . '/../includes/use_cases/post/GetTaxonomyPostSyncItemsUseCase.php',
    171176    'AppfulPlugin\\UseCases\\Post\\PostUseCaseManager' => $baseDir . '/../includes/use_cases/post/PostUseCaseManager.php',
     177    'AppfulPlugin\\UseCases\\Post\\SavePostSyncBatchSizeUseCase' => $baseDir . '/../includes/use_cases/post/SavePostSyncBatchSizeUseCase.php',
    172178    'AppfulPlugin\\UseCases\\Post\\SendPostChunkSyncUseCase' => $baseDir . '/../includes/use_cases/post/SendPostChunkSyncUseCase.php',
    173179    'AppfulPlugin\\UseCases\\Post\\SendPostSyncUseCase' => $baseDir . '/../includes/use_cases/post/SendPostSyncUseCase.php',
  • appful-app/trunk/lib/vendor/composer/autoload_static.php

    r3027388 r3039311  
    211211        'AppfulPlugin\\Api\\Dtos\\BlogHooksDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogHooksDto.php',
    212212        'AppfulPlugin\\Api\\Dtos\\BlogInfoDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogInfoDto.php',
     213        'AppfulPlugin\\Api\\Dtos\\BlogSettingsDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogSettingsDto.php',
    213214        'AppfulPlugin\\Api\\Dtos\\BlogStatsDto' => __DIR__ . '/../..' . '/../includes/api/dtos/BlogStatsDto.php',
    214215        'AppfulPlugin\\Api\\Dtos\\CategoryDto' => __DIR__ . '/../..' . '/../includes/api/dtos/CategoryDto.php',
     
    253254        'AppfulPlugin\\Api\\Handlers\\RequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/RequestHandler.php',
    254255        'AppfulPlugin\\Api\\Handlers\\RoleSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/RoleSyncRequestHandler.php',
     256        'AppfulPlugin\\Api\\Handlers\\SavePostSyncBatchSizeHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/SavePostSyncBatchSizeHandler.php',
    255257        'AppfulPlugin\\Api\\Handlers\\SyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/SyncRequestHandler.php',
    256258        'AppfulPlugin\\Api\\Handlers\\TagSyncRequestHandler' => __DIR__ . '/../..' . '/../includes/api/handlers/TagSyncRequestHandler.php',
     
    260262        'AppfulPlugin\\Api\\Mapper\\BlogHooksMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogHooksMapper.php',
    261263        'AppfulPlugin\\Api\\Mapper\\BlogInfoMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogInfoMapper.php',
     264        'AppfulPlugin\\Api\\Mapper\\BlogSettingsMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogSettingsMapper.php',
    262265        'AppfulPlugin\\Api\\Mapper\\BlogStatsMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/BlogStatsMapper.php',
    263266        'AppfulPlugin\\Api\\Mapper\\CategoryMapper' => __DIR__ . '/../..' . '/../includes/api/mapper/CategoryMapper.php',
     
    285288        'AppfulPlugin\\Domain\\BlogHooks' => __DIR__ . '/../..' . '/../includes/domain/BlogHooks.php',
    286289        'AppfulPlugin\\Domain\\BlogInfo' => __DIR__ . '/../..' . '/../includes/domain/BlogInfo.php',
     290        'AppfulPlugin\\Domain\\BlogSettings' => __DIR__ . '/../..' . '/../includes/domain/BlogSettings.php',
    287291        'AppfulPlugin\\Domain\\BlogStats' => __DIR__ . '/../..' . '/../includes/domain/BlogStats.php',
    288292        'AppfulPlugin\\Domain\\Category' => __DIR__ . '/../..' . '/../includes/domain/Category.php',
     
    363367        'AppfulPlugin\\UseCases\\Page\\PullLocalPageContentUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/page/PullLocalPageContentUseCase.php',
    364368        'AppfulPlugin\\UseCases\\PostDeleteUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/PostDeleteUseCase.php',
     369        'AppfulPlugin\\UseCases\\Post\\GetPostSyncBatchSizeUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetPostSyncBatchSizeUseCase.php',
    365370        'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetPostSyncItemUseCase.php',
    366371        'AppfulPlugin\\UseCases\\Post\\GetPostSyncItemsUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetPostSyncItemsUseCase.php',
    367372        'AppfulPlugin\\UseCases\\Post\\GetTaxonomyPostSyncItemsUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/GetTaxonomyPostSyncItemsUseCase.php',
    368373        'AppfulPlugin\\UseCases\\Post\\PostUseCaseManager' => __DIR__ . '/../..' . '/../includes/use_cases/post/PostUseCaseManager.php',
     374        'AppfulPlugin\\UseCases\\Post\\SavePostSyncBatchSizeUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/SavePostSyncBatchSizeUseCase.php',
    369375        'AppfulPlugin\\UseCases\\Post\\SendPostChunkSyncUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/SendPostChunkSyncUseCase.php',
    370376        'AppfulPlugin\\UseCases\\Post\\SendPostSyncUseCase' => __DIR__ . '/../..' . '/../includes/use_cases/post/SendPostSyncUseCase.php',
  • appful-app/trunk/readme.txt

    r3028218 r3039311  
    66Tested up to: 6.4
    77Requires PHP: 7.4
    8 Stable tag: 3.1.21
     8Stable tag: 3.1.22
    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.