Skip to content

Commit

Permalink
Merge pull request #2455 from Codeinwp/feat/tc-connection
Browse files Browse the repository at this point in the history
feat: template cloud integration
  • Loading branch information
abaicus authored Nov 28, 2024
2 parents f5fe365 + da2f844 commit 1905666
Show file tree
Hide file tree
Showing 16 changed files with 1,504 additions and 81 deletions.
10 changes: 6 additions & 4 deletions inc/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function init() {
}

add_filter( 'otter_blocks_about_us_metadata', array( $this, 'about_page' ) );

add_action( 'parse_query', array( $this, 'pagination_support' ) );
}

Expand Down Expand Up @@ -83,6 +83,8 @@ public function autoload_classes() {
'\ThemeIsle\GutenbergBlocks\Integration\Form_Email',
'\ThemeIsle\GutenbergBlocks\Server\Form_Server',
'\ThemeIsle\GutenbergBlocks\Server\Prompt_Server',
'\ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud',
'\ThemeIsle\GutenbergBlocks\Server\Template_Cloud_Server',
);

$classnames = apply_filters( 'otter_blocks_autoloader', $classnames );
Expand Down Expand Up @@ -532,13 +534,13 @@ public function generate_svg_attachment_metadata( $metadata, $attachment_id ) {

/**
* Disable canonical redirect to make Posts pagination feature work.
*
*
* @param \WP_Query $request The query object.
*/
public function pagination_support( $request ) {
if (
true === $request->is_singular &&
-1 === $request->current_post &&
true === $request->is_singular &&
-1 === $request->current_post &&
true === $request->is_paged &&
(
! empty( $request->query_vars['page'] ) ||
Expand Down
9 changes: 6 additions & 3 deletions inc/plugins/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function register_menu_page() {
/**
* Add shortcut to the Blocks tab in Dashboard.
*/


add_submenu_page(
'otter',
Expand Down Expand Up @@ -122,7 +122,7 @@ public function add_inline_css() {
}
</style>
<?php

}

/**
Expand Down Expand Up @@ -222,7 +222,7 @@ public function enqueue_options_assets() {

/**
* Get the dashboard data to store in global object.
*
*
* @return array
*/
public function get_dashboard_data() {
Expand All @@ -236,6 +236,9 @@ public function get_dashboard_data() {
'stylesExist' => is_dir( $basedir ) || boolval( get_transient( 'otter_animations_parsed' ) ),
'hasPro' => Pro::is_pro_installed(),
'upgradeLink' => tsdk_translate_link( tsdk_utmify( Pro::get_url(), 'options', Pro::get_reference() ) ),
'upgradeLinkFromTc' => tsdk_utmify( Pro::get_url(), 'templatecloud' ),
'tcUpgradeLink' => tsdk_utmify( 'https://themeisle.com/plugins/templates-cloud/', 'templatecloud', 'otter-blocks' ),
'tcDocs' => 'https://docs.themeisle.com/article/2191-templates-cloud-collections',
'docsLink' => Pro::get_docs_url(),
'showFeedbackNotice' => $this->should_show_feedback_notice(),
'deal' => ! Pro::is_pro_installed() ? $offer->get_localized_data() : array(),
Expand Down
36 changes: 35 additions & 1 deletion inc/plugins/class-options-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace ThemeIsle\GutenbergBlocks\Plugins;

use ThemeIsle\GutenbergBlocks\Server\Template_Cloud_Server;
use ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud;

/**
* Class Options_Settings
*/
Expand Down Expand Up @@ -756,7 +759,7 @@ function ( $item ) {
'default' => true,
)
);

register_setting(
'themeisle_blocks_settings',
'themeisle_blocks_settings_prompt_actions',
Expand Down Expand Up @@ -813,6 +816,37 @@ function( $item ) {
),
)
);


register_setting(
'themeisle_blocks_settings',
Template_Cloud::SOURCES_SETTING_KEY,
array(
'type' => 'array',
'description' => __( 'The template cloud sources from which patterns will be loaded.', 'otter-blocks' ),
'sanitize_callback' => [ Template_Cloud_Server::class, 'sanitize_template_cloud_sources' ],
'show_in_rest' => array(
'schema' => array(
'type' => 'array',
'items' => array(
'type' => 'object',
'properties' => array(
'key' => array(
'type' => 'string',
),
'url' => array(
'type' => 'string',
),
'name' => array(
'type' => 'string',
),
),
),
),
),
'default' => [],
)
);
}

/**
Expand Down
Loading

0 comments on commit 1905666

Please sign in to comment.