first commit

This commit is contained in:
User A0264400
2026-04-01 23:20:16 +03:00
commit a766acdc90
23071 changed files with 4933189 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 145 144"><defs><style>.cls-1,.cls-2{fill:none;stroke:#f4812c;stroke-linecap:round;stroke-width:6px;}.cls-1{stroke-miterlimit:10;}.cls-2{stroke-linejoin:round;}</style></defs><title>template-library</title><line class="cls-1" x1="73" y1="16" x2="73" y2="67"/><line class="cls-1" x1="56" y1="55" x2="73" y2="67"/><line class="cls-1" x1="73" y1="67" x2="89" y2="55"/><polyline class="cls-2" points="96 36 130 36 130 131 15 131 15 36 54 36"/></svg>

After

Width:  |  Height:  |  Size: 530 B

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35.81 42.76"><defs><style>.cls-1{fill:#fff;}</style></defs><title>Untitled-1</title><g id="Logo_1" data-name="Logo 1"><path class="cls-1" d="M36.6,4.31A62.21,62.21,0,0,0,26,3.05C25.11,3,24.24,3,23.34,3H22A64,64,0,0,0,11.4,4a45.7,45.7,0,0,0-5.31,1.3v12.4H11.4V9.62a61.72,61.72,0,0,1,9.28-1.19V32L24,33.16,27.32,32V8.37a63,63,0,0,1,9.28,1v8.4h5.31v-12A42.36,42.36,0,0,0,36.6,4.31Z" transform="translate(-6.09 -3)"/><polygon class="cls-1" points="30.5 23.53 30.5 27.49 19.89 34.76 17.91 36.13 15.92 34.76 5.3 27.49 5.3 23.53 0 23.53 0 30.48 5.3 34.13 15.92 41.39 17.91 42.76 19.89 41.39 30.5 34.13 35.81 30.48 35.81 23.53 30.5 23.53"/></g></svg>

After

Width:  |  Height:  |  Size: 866 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,892 @@
<?php
/**
* Templateberg Connect
*
* @since 1.0.0
*/
if (! class_exists('Templateberg_Connect')) {
/**
* Class Templateberg_Connect.
*/
class Templateberg_Connect
{
private static $page_slug = 'templateberg';
private static $id = 'templateberg-connect';
private static $disconnect_id = 'templateberg-disconnect';
private static $purchase_id = 'templateberg-payments';
private static $purchase_templates = 'templateberg-purchase-templates';
const ACCOUNT_URL = 'https://templateberg.com/wp-login.php';
/*Editor Gutenberg Templates*/
const TEMPLATE_URL = 'https://templateberg.com/wp-json/connect/v1/get_templates/';
/*Editor Gutenberg Purchase Templates*/
const PURCHASE_URL = 'https://templateberg.com/wp-json/connect/v1/purchase/';
/*Editor Get Template data to import*/
const TEMPLATE_DATA_URL = 'https://templateberg.com/wp-json/connect/v1/get_template_data/';
/*Admin Page Templates*/
private static $current_theme_purchase_id = 'templateberg-current-theme-payments';
private static $current_theme_purchase_templates = 'templateberg-current-theme-purchase-templates';
const GUTENBERG_TEMPLATES_URL = 'https://templateberg.com/wp-json/connect/v1/gutenberg_templates/';
const THEME_TEMPLATES_URL = 'https://templateberg.com/wp-json/connect/v1/theme_templates/';
const CURRENT_THEME_TEMPLATES_URL = 'https://templateberg.com/wp-json/connect/v1/current_theme_templates/';
const CURRENT_THEME_PURCHASE_URL = 'https://templateberg.com/wp-json/connect/v1/purchase_current_theme_demos/';
const THEME_TEMPLATE_DATA_URL = 'https://templateberg.com/wp-json/connect/v1/get_theme_template_data/';
/**
* Main Templateberg_Connect Instance
* Initialize the class and set its properties.
*
* @since 1.0.0
* @return object $instance Templateberg_Connect Instance
*/
public static function instance()
{
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if (null === $instance) {
$instance = new Templateberg_Connect();
}
// Always return the instance
return $instance;
}
/**
* Create nonce
*
* @since 1.0.0
*/
private function create_nonce()
{
return wp_create_nonce(self::$id);
}
/**
* Check if user has account
*
* @since 1.0.0
*/
public function has_account()
{
if (!get_user_meta(get_current_user_id(), self::$id, true)) {
return false;
}
if (!is_array(maybe_unserialize(get_user_meta(get_current_user_id(), self::$id, true)))) {
return false;
}
return true;
}
/**
* Get Account
*
* @since 1.0.0
*/
public function get_account($add_additional = true)
{
$account_info = maybe_unserialize(get_user_meta(get_current_user_id(), self::$id, true));
if (!$add_additional) {
return $account_info;
}
if (!$account_info) {
return $account_info;
}
$user = wp_get_current_user();
$additional_info = array(
'redirect_url' => $this->get_redirect_url(),
'site_url' => get_site_url(),
'home_url' => get_home_url(),
'local-user-id' => absint($user->ID),/*int*/
'local-user-email' => sanitize_email($user->user_email),/*text*/
);
return array_merge(
$account_info,
$additional_info
);
}
/**
* Get Purchase
*
* @since 1.0.0
*/
public function get_purchase()
{
return maybe_unserialize(get_user_meta(get_current_user_id(), self::$purchase_id, true));
}
/**
* Set Purchase
*
* @since 1.0.0
*/
public function set_purchase($prepare_data)
{
update_user_meta(get_current_user_id(), self::$purchase_id, $prepare_data);
if (empty($prepare_data)) {
$this->set_purchase_templates('');
}
}
/**
* Set Purchase templates
*
* @since 1.0.0
*/
public function set_purchase_templates($templates_list)
{
if (is_array($templates_list)) {
update_user_meta(get_current_user_id(), self::$purchase_templates, $templates_list);
} else {
update_user_meta(get_current_user_id(), self::$purchase_templates, '');
}
}
/**
* Get Purchase Templates ids
*
* @since 1.0.0
*/
public function get_purchase_templates_id()
{
$templates_list = $this->get_purchase_templates();
$all_ids = array();
if (is_array($templates_list)) {
foreach ($templates_list as $template) {
$all_ids[] = $template['id'];
}
}
return $all_ids;
}
/**
* Get Purchase templates
*
* @since 1.0.0
*/
public function get_purchase_templates()
{
return maybe_unserialize(get_user_meta(get_current_user_id(), self::$purchase_templates, true));
}
/**
* Get Free Templates
*
* @since 1.0.0
*/
public function get_free_templates()
{
return array(
array(
'title' => __('Agency', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-10-home-01.jpg',
),
array(
'title' => __('Business', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/medical-template.jpg',
),
array(
'title' => __('Agency', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-03-home.jpg',
),
array(
'title' => __('Business', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-13-home.jpg',
),
array(
'title' => __('Agency', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-12-home.jpg',
),
array(
'title' => __('Business', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-13-home.jpg',
),
array(
'title' => __('Agency', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-10-home-01.jpg',
),
array(
'title' => __('Business', 'templateberg'),
'screenshot_url' => TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-02-home-01.jpg',
),
);
}
/**
* Set Free templates
*
* @since 1.0.0
*/
public function set_free_templates($prepare_data)
{
$templates = array();
if (is_array($prepare_data)) {
foreach ($prepare_data as $data) {
array_push($templates, array(
'title' => $data['title'],
'screenshot_url' => $data['screenshot_url'],
));
}
}
set_transient('templateberg_edt_free', $templates);
}
/**
* Get Slug
*
* @since 1.0.4
*/
public function get_slug()
{
return self::$page_slug;
}
/**
* Check if current screen
*
* @since 1.0.0
*/
public function is_current_screen()
{
if (get_current_screen() ->base === 'toplevel_page_'.self::$page_slug ||
get_current_screen() ->base === 'templateberg_page_'.templateberg_gutenberg_templates()->get_slug() ||
get_current_screen() ->base === 'templateberg_page_'.templateberg_theme_templates()->get_slug()
) {
return true;
}
return false;
}
/**
* Get Redirect Url
*
* @since 1.0.0
*/
public function get_redirect_url()
{
return add_query_arg(array(
'_wpnonce' => $this->create_nonce(),
), get_admin_url());
}
/**
* Get Connect Url
*
* @since 1.0.0
*/
public function get_remote_connect_url($is_reset = false)
{
$user = wp_get_current_user();
return add_query_arg(array(
'redirect_url' => $this->get_redirect_url(),
'site_url' => get_site_url(),
'home_url' => get_home_url(),
'email' => $user->user_email,
'from' => isset($_GET['page']) && 'templateberg' === $_GET['page']?'tb-dashboard':'wp-dashboard',
'reset' =>$is_reset
), self::ACCOUNT_URL);
}
/**
* Get Disconnect Url
*
* @since 1.0.0
*/
public function get_remote_disconnect_url()
{
return add_query_arg(array(
'_wpnonce' => $this->create_nonce(),
self::$disconnect_id => 'templateberg.com',
'user-id' => get_current_user_id(),
), get_admin_url());
}
/**
* Get Templates Url
*
* @since 1.0.0
*/
public function get_template_url($paged = 1)
{
if (!templateberg_connect()->has_account()) {
return false;
}
return add_query_arg(array(
'account'=>templateberg_connect()->get_account(),
'paged'=>$paged
), self::TEMPLATE_URL);
}
/**
* Get Purchase Url
*
* @since 1.0.0
*/
public function get_purchase_url()
{
if (!templateberg_connect()->has_account()) {
return false;
}
$args = templateberg_gutentor_connect()->add_args(array(
'account'=>templateberg_connect()->get_account(),
'theme'=>templateberg_get_current_theme_info(),
));
return add_query_arg($args, self::PURCHASE_URL);
}
/**
* Get Template Data Url
*
* @since 1.0.0
*/
public function get_template_data_url($template)
{
if (!templateberg_connect()->has_account()) {
return false;
}
$args = templateberg_gutentor_connect()->add_args(array(
'account' =>templateberg_connect()->get_account(),
'template' =>$template
));
return add_query_arg($args, self::TEMPLATE_DATA_URL);
}
/**
* Get Gutenberg Templates Url
*
* @since 1.0.4
*/
public function get_gutenberg_tempaltes_url($paged = 1)
{
if (!templateberg_connect()->has_account()) {
return add_query_arg(
array(
'paged'=>$paged
),
self::GUTENBERG_TEMPLATES_URL
);
}
return add_query_arg(
array(
'paged'=>$paged,
'account'=>templateberg_connect()->get_account(),
),
self::GUTENBERG_TEMPLATES_URL
);
}
/**
* Get Themes Templates Url
*
* @since 1.0.4
*/
public function get_theme_tempaltes_url($paged = 1)
{
if (!templateberg_connect()->has_account()) {
return add_query_arg(
array(
'paged'=>$paged
),
self::THEME_TEMPLATES_URL
);
}
return add_query_arg(
array(
'paged'=>$paged,
'account'=>templateberg_connect()->get_account()
),
self::THEME_TEMPLATES_URL
);
}
/**
* Get Themes Templates Url
*
* @since 1.0.4
*/
public function get_current_theme_tempaltes_url($paged = 1, $theme = [])
{
if (!templateberg_connect()->has_account()) {
return add_query_arg(
array(
'paged'=>$paged,
'theme'=>!empty($theme)?$theme:templateberg_get_current_theme_info(),
),
self::CURRENT_THEME_TEMPLATES_URL
);
}
return add_query_arg(
array(
'paged'=>$paged,
'account'=>templateberg_connect()->get_account(),
'theme'=>!empty($theme)?$theme:templateberg_get_current_theme_info(),
),
self::CURRENT_THEME_TEMPLATES_URL
);
}
/**
* Get Purchase Url
*
* @since 1.0.4
*/
public function get_current_theme_purchase_url()
{
if (!templateberg_connect()->has_account()) {
return false;
}
return add_query_arg(
array(
'account'=>templateberg_connect()->get_account(),
'theme'=>templateberg_get_current_theme_info(),
),
self::CURRENT_THEME_PURCHASE_URL
);
}
/**
* Set Purchase
*
* @since 1.0.4
*/
public function set_current_theme_purchase($prepare_data)
{
update_user_meta(get_current_user_id(), self::$current_theme_purchase_id, $prepare_data);
if (empty($prepare_data)) {
$this->set_current_theme_purchase_templates('');
}
}
/**
* Set Purchase templates
*
* @since 1.0.4
*/
public function set_current_theme_purchase_templates($templates_list)
{
if (is_array($templates_list)) {
update_user_meta(get_current_user_id(), self::$current_theme_purchase_templates, $templates_list);
} else {
update_user_meta(get_current_user_id(), self::$current_theme_purchase_templates, '');
}
}
/**
* Get Purchase Templates ids
*
* @since 1.0.4
*/
public function get_current_theme_purchase_templates_id()
{
$templates_list = $this->get_current_theme_purchase_templates();
$all_ids = array();
if (is_array($templates_list)) {
foreach ($templates_list as $template) {
$all_ids[] = absint($template['id']);
}
}
return $all_ids;
}
/**
* Get Purchase templates
*
* @since 1.0.4
*/
public function get_current_theme_purchase_templates()
{
return maybe_unserialize(
get_user_meta(
get_current_user_id(),
self::$current_theme_purchase_templates,
true
)
);
}
/**
* Get Template Data Url
*
* @since 1.0.4
*/
public function get_theme_template_data_url($template)
{
if (!templateberg_connect()->has_account()) {
return false;
}
return add_query_arg(array(
'account' =>templateberg_connect()->get_account(),
'template' =>$template
), self::THEME_TEMPLATE_DATA_URL);
}
/**
* Run the method
*
* @since 1.0.0
*/
public function run()
{
add_action('admin_init', array( __CLASS__, 'connect' ), -1);
add_action('admin_init', array( __CLASS__, 'disconnect' ), -1);
add_action('admin_menu', array( __CLASS__, 'admin_pages' ));
add_action('admin_init', array( __CLASS__, 'redirect' ));
add_action('wp_ajax_templateberg_gutentor', array( $this, 'install_gutentor' ));
add_action('wp_ajax_templateberg_advanced_import', array( $this, 'advanced_import' ));
}
/**
* Admin Page Menu and submenu page
*
* @since 1.0.0
*/
public static function admin_pages()
{
add_menu_page(
esc_html__('Templateberg', 'templateberg'),
esc_html__('Templateberg', 'templateberg'),
'manage_options',
self::$page_slug,
array( __CLASS__, 'account' ),
'data:image/svg+xml;base64,' . base64_encode(
'<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35.81 42.76"><defs><style>.cls-1{fill:#fff;}</style></defs><title>Untitled-1</title><g id="Logo_1" data-name="Logo 1"><path class="cls-1" d="M36.6,4.31A62.21,62.21,0,0,0,26,3.05C25.11,3,24.24,3,23.34,3H22A64,64,0,0,0,11.4,4a45.7,45.7,0,0,0-5.31,1.3v12.4H11.4V9.62a61.72,61.72,0,0,1,9.28-1.19V32L24,33.16,27.32,32V8.37a63,63,0,0,1,9.28,1v8.4h5.31v-12A42.36,42.36,0,0,0,36.6,4.31Z" transform="translate(-6.09 -3)"/><polygon class="cls-1" points="30.5 23.53 30.5 27.49 19.89 34.76 17.91 36.13 15.92 34.76 5.3 27.49 5.3 23.53 0 23.53 0 30.48 5.3 34.13 15.92 41.39 17.91 42.76 19.89 41.39 30.5 34.13 35.81 30.48 35.81 23.53 30.5 23.53"/></g></svg>'
),
110
);
}
/**
* Get Admin URl
*
* @since 1.0.0
*/
public function get_admin_url()
{
return menu_page_url(self::$page_slug, false);
}
/**
* Redirect to plugin page when plugin activated
*
* @since 1.0.0
*/
public static function redirect()
{
if (get_option('__templateberg_do_redirect')) {
update_option('__templateberg_do_redirect', false);
if (! is_multisite()) {
exit(wp_redirect(templateberg_connect()->get_admin_url()));
}
}
}
/**
* Load account templates
*
* @since 1.0.0
*/
public static function account()
{
if (isset($_GET['connecting'])) {
require_once TEMPLATEBERG_PATH . 'includes/admin/templates/connecting.php';
} else {
if (templateberg_connect()->has_account()) {
require_once TEMPLATEBERG_PATH . 'includes/admin/templates/account.php';
} else {
require_once TEMPLATEBERG_PATH . 'includes/admin/templates/getting-started.php';
}
}
}
/**
* Connect
*
* @since 1.0.0
*/
public static function connect()
{
if (isset($_GET[self::$id]) && $_GET[self::$id] == 'templateberg.com') {
if (!isset($_GET['_wpnonce']) ||
!isset($_GET['key']) ||
!isset($_GET['token']) ||
!isset($_GET['email']) ||
!isset($_GET['user-name']) ||
!isset($_GET['user-id']) ||
!isset($_GET['site-id']) ||
! wp_verify_nonce($_GET['_wpnonce'], self::$id)
) {
$invalid = esc_html__('Sorry, we could not connect. Please try again.', 'templateberg');
wp_die($invalid, $invalid, [
'link_url' => admin_url(),
'link_text' => esc_html__('Back to Admin', 'templateberg'),
]);
}
$prepare_data = array(
'key' => sanitize_text_field($_GET['key']),/*text*/
'token' => sanitize_text_field($_GET['token']),/*text*/
'email' => sanitize_email($_GET['email']),/*email*/
'user-name' => sanitize_text_field($_GET['user-name']),/*text*/
'user-id' => sanitize_text_field($_GET['user-id']),/*text*/
'site-id' => sanitize_text_field($_GET['site-id']),/*text*/
);
update_user_meta(get_current_user_id(), self::$id, $prepare_data);
$connect_url = templateberg_connect()->get_admin_url().'&connecting=true';
if (isset($_GET['isPopup'])) {
$connect_url .= '&isPopup=true';
}
wp_redirect($connect_url);
exit;
}
}
/**
* Disconnect
*
* @since 1.0.0
*/
public static function disconnect()
{
if (isset($_GET[self::$disconnect_id]) && $_GET[self::$disconnect_id] == 'templateberg.com') {
if (!isset($_GET['_wpnonce']) ||
!isset($_GET['user-id']) ||
get_current_user_id() != $_GET['user-id'] ||
! wp_verify_nonce($_GET['_wpnonce'], self::$id)
) {
$invalid = esc_html__('Sorry, we could not disconnect. Please try again.', 'templateberg');
wp_die($invalid, $invalid, [
'link_url' => admin_url(),
'link_text' => esc_html__('Back to Admin', 'templateberg'),
]);
}
delete_user_meta(get_current_user_id(), self::$id);
wp_redirect(templateberg_connect()->get_admin_url());
exit;
}
}
/**
* FAQ Array
* @access Private
* @return array
*/
public function faq()
{
return array(
array(
'q' => esc_html__('What is Templateberg?', 'templateberg'),
'a' => esc_html__('A collection of pre-designed template and template kits library for WordPress. Templateberg includes a variety of templates for all kinds of websites from any niche to multipurpose including blog, magazine, eCommerce, travel, business, medical, construction, photography, education, fitness, automotive, portfolio, restaurant, multipurpose and much more. Templateberg facilitates to import of pre-designed template with starter content on the user website so that user can quickly build a beautiful website with WordPress.', 'templateberg'),
),
array(
'q' => esc_html__('What is a Gutenberg block?', 'templateberg'),
'a' => esc_html__('A section of a website page created with Gutenberg or Gutenberg Addons plugin. It is the most modern way to design a website. The possibility is endless to create any page design by importing and combing the block section.', 'templateberg'),
),
array(
'q' => esc_html__('What is a Gutenberg template?', 'templateberg'),
'a' => esc_html__('A full-page pre-designed of a single page of a website with starter content created with Gutenberg block. It can be a home page, about, service, contact, pop-ups, products, pricing or any landing pages.', 'templateberg'),
),
array(
'q' => esc_html__('What is a Gutenberg template kit?', 'templateberg'),
'a' => esc_html__('A collection of cohesive pre-designed Gutenberg templates with all pages for a niche/multipurpose website focusing on a similar design concept.', 'templateberg'),
),
array(
'q' => esc_html__('What is Gutentor?', 'templateberg'),
'a' => sprintf(esc_html__('Gutentor is a WordPress plugin based on WordPress Block (Gutenberg) Editor, modern drag & drop WordPress page builder Know more about it on %1$sGutentor official website%2$s.', 'templateberg'), "<a href='https://www.gutentor.com/' target='_blank'>", '</a>'),
),
array(
'q' => esc_html__('What is a WordPress Theme Template Kit?', 'templateberg'),
'a' => esc_html__('A pre-designed starter content for a specific theme that you can simply import on your site with a click. In other words, it can be called Demo Content for the theme.', 'templateberg'),
),
array(
'q' => esc_html__('How Gutenberg Template Kit is different from Theme Template Kit?', 'templateberg'),
'a' => esc_html__('Gutenberg Template Kit is designed on WordPress Gutenberg Block Editor whereas Theme Template Kit is designed for the specific theme. Templates from Gutenberg Template Kits can be imported individually on a single page/post but when you import Theme Template Kit all content and pages import at once. Gutenberg Template Kit will work on any Theme but Theme Template Kit will work on a single theme it is created from.', 'templateberg'),
),
);
}
private function install_plugin($plugin_info)
{
$plugin = $plugin_info['plugin'];
$slug = $plugin_info['slug'];
$status = array(
'install' => 'plugin',
'slug' => sanitize_key(wp_unslash($slug)),
);
if (is_plugin_active_for_network($plugin) || is_plugin_active($plugin)) {
// Plugin is activated
wp_send_json_success($status);
}
if (! current_user_can('install_plugins')) {
$status['errorMessage'] = __('Sorry, you are not allowed to install plugins on this site.', 'templateberg');
wp_send_json_error($status);
}
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
// Looks like a plugin is installed, but not active.
if (file_exists(WP_PLUGIN_DIR . '/' . $slug)) {
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
$status['plugin'] = $plugin;
$status['pluginName'] = $plugin_data['Name'];
if (current_user_can('activate_plugin', $plugin) && is_plugin_inactive($plugin)) {
$result = activate_plugin($plugin);
if (is_wp_error($result)) {
$status['errorCode'] = $result->get_error_code();
$status['errorMessage'] = $result->get_error_message();
wp_send_json_error($status);
}
wp_send_json_success($status);
}
}
$api = plugins_api(
'plugin_information',
array(
'slug' => sanitize_key(wp_unslash($slug)),
'fields' => array(
'sections' => false,
),
)
);
if (is_wp_error($api)) {
$status['errorMessage'] = $api->get_error_message();
wp_send_json_error($status);
}
$status['pluginName'] = $api->name;
$skin = new WP_Ajax_Upgrader_Skin();
$upgrader = new Plugin_Upgrader($skin);
$result = $upgrader->install($api->download_link);
if (defined('WP_DEBUG') && WP_DEBUG) {
$status['debug'] = $skin->get_upgrade_messages();
}
if (is_wp_error($result)) {
$status['errorCode'] = $result->get_error_code();
$status['errorMessage'] = $result->get_error_message();
wp_send_json_error($status);
} elseif (is_wp_error($skin->result)) {
$status['errorCode'] = $skin->result->get_error_code();
$status['errorMessage'] = $skin->result->get_error_message();
wp_send_json_error($status);
} elseif ($skin->get_errors()->get_error_code()) {
$status['errorMessage'] = $skin->get_error_messages();
wp_send_json_error($status);
} elseif (is_null($result)) {
require_once(ABSPATH . 'wp-admin/includes/file.php');
WP_Filesystem();
global $wp_filesystem;
$status['errorCode'] = 'unable_to_connect_to_filesystem';
$status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.', 'templateberg');
// Pass through the error from WP_Filesystem if one was raised.
if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
$status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
}
wp_send_json_error($status);
}
$install_status = install_plugin_install_status($api);
if (current_user_can('activate_plugin', $install_status['file']) && is_plugin_inactive($install_status['file'])) {
$result = activate_plugin($install_status['file']);
if (is_wp_error($result)) {
$status['errorCode'] = $result->get_error_code();
$status['errorMessage'] = $result->get_error_message();
wp_send_json_error($status);
}
}
wp_send_json_success($status);
}
/**
* Get Started Notice
* Active callback of wp_ajax
* return void
*/
public function install_gutentor()
{
check_ajax_referer('templateberg_nonce', 'security');
$slug = 'gutentor';
$plugin = 'gutentor/gutentor.php';
/*prevent gutentor to redirect*/
update_option('__gutentor_do_redirect', false);
$this->install_plugin(
array(
'slug'=>$slug,
'plugin'=>$plugin,
)
);
}
/**
* Install Advanced Import
* Active callback of wp_ajax
* return void
*/
public function advanced_import()
{
check_ajax_referer('templateberg_nonce', 'security');
$slug = 'advanced-import';
$plugin = 'advanced-import/advanced-import.php';
/*prevent gutentor to redirect*/
update_option('__gutentor_do_redirect', false);
$this->install_plugin(
array(
'slug'=>$slug,
'plugin'=>$plugin,
)
);
}
}
}
/**
* Begins execution of the hooks.
*
* @since 1.0.0
*/
function templateberg_connect()
{
return Templateberg_Connect::instance();
}
templateberg_connect()->run();

View File

@@ -0,0 +1,178 @@
<?php
/**
* Templateberg Connect to Gutentor
*
* @since 1.0.0
*/
if ( ! class_exists( 'Templateberg_Gutentor_Connect' ) ) {
/**
* Class Templateberg_Gutentor_Connect.
*/
class Templateberg_Gutentor_Connect {
/**
* Main Templateberg_Gutentor_Connect Instance
* Initialize the class and set its properties.
*
* @since 1.0.0
* @return object $instance Templateberg_Gutentor_Connect Instance
*/
public static function instance() {
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if ( null === $instance ) {
$instance = new Templateberg_Gutentor_Connect();
}
// Always return the instance
return $instance;
}
/**
* Add Gutentor args
*
* @since 1.1.4
*/
public function add_args( $args ) {
if ( $this->has_valid_license() ) {
$args['gutentor'] = array(
'license' => gutentor_pro_license_init()->get_license_key(),
'url' => home_url(),
'environment' => function_exists( 'wp_get_environment_type' ) ?
wp_get_environment_type() : 'production',
);
}
return $args;
}
/**
* If gutentor pro license is valid
*
* @since 1.1.4
*
* return bool
*/
public function has_valid_license() {
$license_data = templateberg_gutentor_connect()->get_license_info();
if ( ! $license_data || ! isset( $license_data->license ) || 'valid' !== $license_data->license ) {
return false;
}
return true;
}
/**
* If gutentor pro license info
*
* @since 1.1.4
*
* return bool||object
*/
public static function get_license_info() {
// Store the $license_data locally
static $license_data = null;
// Only set the license they haven't been set previously
if ( null === $license_data ) {
if ( ! function_exists( 'gutentor_pro_license_init' ) ||
! function_exists( 'gutentor_pro_edd_plugin_installer' ) ) {
$license_data = false;
} else {
if ( ! gutentor_pro_license_init()->menu_slug ) {
gutentor_pro_license_init()->run();
}
$license_data = gutentor_pro_edd_plugin_installer()->check_license();
}
}
// Always return the $license_data
return $license_data;
}
/**
* Get Gutentor Remaining Template Kits
*
* @since 1.1.4
*/
public function get_total_template_kits() {
$license_data = templateberg_gutentor_connect()->get_license_info();
if ( ! $license_data || ! isset( $license_data->license ) || 'valid' !== $license_data->license ) {
return false;
}
if ( 1 === absint( $license_data->license_limit ) ) {
return 12;
} elseif ( 5 === absint( $license_data->license_limit ) ) {
return 33;
} elseif ( 25 === absint( $license_data->license_limit ) ) {
return 55;
} else {
return -1;
}
}
/**
* Get Gutentor Remaining Template Kits
*
* @since 1.1.4
*/
public function get_imported_template_kits() {
if ( ! metadata_exists( 'user', get_current_user_id(), 'templateberg-gutentor-imd-tmls' ) ) {
return array();
}
$imported = get_user_meta( get_current_user_id(), 'templateberg-gutentor-imd-tmls', true );
$imported = json_decode( $imported, true );
return array_unique( $imported );
}
/**
* Set Gutentor Imported Template Kits
*
* @since 1.1.4
*/
public function add_imported_template_kits( $gutentor_info ) {
if ( ! isset( $gutentor_info['template_kits_used'] ) ||
! is_array( $gutentor_info['template_kits_used'] ) ||
empty( $gutentor_info['template_kits_used'] )
) {
return;
}
update_user_meta(
get_current_user_id(),
'templateberg-gutentor-imd-tmls',
wp_json_encode( array_unique( $gutentor_info ) )
);
}
/**
* Get remaining tempalte kits.
*
* @since 1.1.4
*/
function get_remaining_template_kits() {
$total_num = templateberg_gutentor_connect()->get_total_template_kits();
$used_template_kits = templateberg_gutentor_connect()->get_imported_template_kits();
$used_num = count( $used_template_kits );
return $total_num - $used_num;
}
}
}
/**
* Begins execution of the hooks.
*
* @since 1.0.0
*/
function templateberg_gutentor_connect() {
return Templateberg_Gutentor_Connect::instance();
}

View File

@@ -0,0 +1,264 @@
<div class="tb-all_content_wrap">
<?php
$account_info = templateberg_connect()->get_account();
require_once TEMPLATEBERG_PATH . 'includes/admin/templates/header.php';
?>
<div class="tb-account">
<div class="tb-account__content">
<div class="tb-container">
<div class="tb-row">
<div class="tb-col-3">
<div class="tb-account__details">
<div class="tb-account__profile tb-text__center">
<div class="tb-account__pic">
<?php echo get_avatar($account_info['email'], 100); ?>
</div>
<div class="tb-account__info">
<h5>
<a href="https://templateberg.com/dashboard/">
<?php echo esc_html($account_info['user-name']); ?>
</a>
</h5>
</div>
</div>
</div>
<div class="tb-account__details">
<h6> <?php esc_html_e('Contact Information', 'templateberg'); ?></h6>
<ul>
<li>
<span class="dashicons dashicons-email"></span>
<strong>
<?php esc_html_e('Support:', 'templateberg'); ?>
</strong>
<a href="https://templateberg.com/contact/">
<?php esc_html_e('Create A Ticket', 'templateberg'); ?>
</a>
</li>
<li>
<span class="dashicons dashicons-email"></span>
<strong>
<?php esc_html_e('Email:', 'templateberg'); ?>
</strong>
<a href="mailto:support@templateberg.com">
<?php esc_html_e('support@templateberg.com', 'templateberg'); ?>
</a>
</li>
</ul>
<h6><?php esc_html_e('Social Network', 'templateberg'); ?></h6>
<ul class="tb-social__links">
<li>
<a href="https://www.facebook.com/templateberg">
<span class="dashicons dashicons-facebook-alt"></span>
</a>
</li>
<li>
<a href="https://twitter.com/templateberg">
<span class="dashicons dashicons-twitter"></span>
</a>
</li>
<li>
<a href="https://www.linkedin.com/in/templateberg/">
<span class="dashicons dashicons-linkedin"></span>
</a>
</li>
</ul>
</div>
</div>
<div class="tb-col-9">
<div class="tb-account__connection">
<div class="tb-row">
<div class="tb-col-12">
<h3 class="tb-account__heading">
<?php esc_html_e('Connections', 'templateberg'); ?>
</h3>
</div>
<div class="tb-col-6">
<div class="tb-account__details">
<h6><?php esc_html_e('Site Connection', 'templateberg'); ?></h6>
<div class="tb-connection__wrap">
<div class="tb-connection__pic">
<?php
$site_icon = admin_url('images/w-logo-blue.png');
if (get_site_icon_url()) {
$site_icon = get_site_icon_url();
} elseif (get_theme_mod('custom_logo')) {
$custom_logo_id = get_theme_mod('custom_logo');
$image = wp_get_attachment_image_src($custom_logo_id, 'full');
$site_icon = $image[0];
}
?>
<img
src="<?php echo esc_url($site_icon)?>"
alt="<?php echo esc_url(get_bloginfo('name')); ?>"
width="80"
height="80"
/>
</div>
<div class="tb-connection__desc">
<p>
<?php esc_html_e(
'Your Site is connected to Templateberg.com',
'templateberg'
);
?>
<span>
<?php esc_html_e(
'Enjoy Templateberg.',
'templateberg'
);
?>
</span>
</p>
<a id="tb-open-manage-connection"
href="#"
class="tb-btn tb-btn__primary">
<?php esc_html_e('Manage Connection', 'templateberg'); ?>
</a>
</div>
</div>
</div>
</div>
<div class="tb-col-6">
<div class="tb-account__details">
<h6><?php esc_html_e('Account Connection', 'templateberg'); ?></h6>
<div class="tb-connection__wrap">
<div class="tb-connection__pic">
<?php echo get_avatar($account_info['email'], 80)?>
</div>
<div class="tb-connection__desc">
<p>
<?php esc_html_e('Connected as', 'templateberg'); ?>
<strong>
<?php
echo esc_html($account_info['user-name']);
?>
</strong>
<span><?php echo esc_html($account_info['email']);?></span>
</p>
<a href="https://templateberg.com/dashboard/"
target="_blank"
class="tb-btn tb-btn__primary">
<?php esc_html_e('Manage Account', 'templateberg'); ?>
</a>
</div>
</div>
</div>
</div>
</div>
<div class="tb-purchase__info">
<div class="tb-row">
<div class="tb-col-12">
<h3 class="tb-global__heading tb-account__heading">
<?php esc_html_e('Purchase Information', 'templateberg'); ?>
<a href="#" class="tb-data__sync tb-data__purchase_sync">
<i class="dashicons dashicons-image-rotate"></i>
<?php esc_html_e('Sync', 'templateberg'); ?>
</a>
</h3>
</div>
<div class="tb-col-12 tb-purchase__data">
<?php
templateberg_get_payment_info_html()
?>
</div>
</div>
</div>
<div class="tb-templates">
<div class="tb-row">
<div class="tb-col-12">
<h3 class="tb-account__heading">
<?php esc_html_e('Available Templates', 'templateberg'); ?>
</h3>
<a href="https://templateberg.com/wordpress-themes-template-kits/" class="tb-btn tb-btn__primary" target="_blank">
<?php esc_html_e('Themes Template Kits', 'templateberg'); ?>
</a>
<a href="https://templateberg.com/gutenberg-templates/" class="tb-btn tb-btn__primary" target="_blank">
<?php esc_html_e('Gutenberg Templates', 'templateberg'); ?>
</a>
</div>
</div>
<div class="tb-templates__wrap">
<div class="tb-templates__list">
<?php
templateberg_get_free_templates_html()
?>
</div>
</div>
</div>
<?php
require_once TEMPLATEBERG_PATH . 'includes/admin/templates/faq.php';
?>
</div>
</div>
</div>
</div>
</div>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="tb-manage-connection" class="hidden">
<div class="tb-manage-connection-wrap">
<div class="tb-manage__body">
<p class="tb-manage__info">
<?php esc_html_e('Templateberg power you to create site quickly and easily.', 'templateberg'); ?>
<?php esc_html_e("You don't have to spend hours trying to create a template and block design.", 'templateberg'); ?>
<?php esc_html_e("With a click the block and template will import on your site and you can change text, image and customize it for your needs.", 'templateberg'); ?>
<?php esc_html_e("Once you disconnect Templateberg, these features will no longer be available and you may no longer create design faster.", 'templateberg'); ?>
</p>
<h4 class="tb-manage__title"><?php esc_html_e('Templateberg power you to create any of the following websites.', 'templateberg'); ?></h4>
<ul class="tb-manage__tempList">
<li><?php esc_html_e('Blog', 'templateberg'); ?></li>
<li><?php esc_html_e('News & Magazine', 'templateberg'); ?></li>
<li><?php esc_html_e('Multipurpose', 'templateberg'); ?></li>
<li><?php esc_html_e('Ecommerce/WooCommerce', 'templateberg'); ?></li>
<li><?php esc_html_e('Easy Digital Downloads', 'templateberg'); ?></li>
<li><?php esc_html_e('Business', 'templateberg'); ?></li>
<li><?php esc_html_e('Finance', 'templateberg'); ?></li>
<li><?php esc_html_e('Automotive', 'templateberg'); ?></li>
<li><?php esc_html_e('Consultant', 'templateberg'); ?></li>
<li><?php esc_html_e('Medical', 'templateberg'); ?></li>
<li><?php esc_html_e('Education', 'templateberg'); ?></li>
<li><?php esc_html_e('Photography', 'templateberg'); ?></li>
<li><?php esc_html_e('Construction', 'templateberg'); ?></li>
<li><?php esc_html_e('Travel', 'templateberg'); ?></li>
<li><?php esc_html_e('Fitness', 'templateberg'); ?></li>
<li><?php esc_html_e('Restaurant', 'templateberg'); ?></li>
<li><?php esc_html_e('Lawyer', 'templateberg'); ?></li>
<li><?php esc_html_e('Charity', 'templateberg'); ?></li>
<li><?php esc_html_e('Portfolio', 'templateberg'); ?></li>
<li><?php esc_html_e('Beauty', 'templateberg'); ?></li>
<li><?php esc_html_e('And many more....', 'templateberg'); ?></li>
</ul>
<div class="tb-info__box">
<div class="tb-manage__help tb-text__center">
<p><?php esc_html_e('Have a question? Wed love to help! Send a question to the Templateberg support team.', 'templateberg'); ?></p>
<a id="tb-send-question-btn" class="tb-manage-help__link tb-btn tb-btn__primary tb-btn__lg" href="https://templateberg.com/contact/" rel="noopener noreferrer" target="_blank">
<?php esc_html_e('Send a question', 'templateberg'); ?>
</a>
</div>
</div>
</div>
<div class="tb-manage__footer">
<p><?php esc_html_e('Are you sure you want to disconnect?', 'templateberg'); ?></p>
<div class="tb-manage__button-row">
<a id="tb-cancel-btn" type="button" class="tb-btn tb-btn__primary">
<?php esc_html_e('Cancel', 'templateberg'); ?>
</a>
<a id="tb-reset-btn" href="<?php echo esc_url(templateberg_connect()->get_remote_connect_url(true))?>" target="_blank" type="button" class="tb-btn tb-btn__sucess tb-btn__reset">
<?php esc_html_e('Reset Connect', 'templateberg'); ?>
</a>
<a type="button" href="<?php echo esc_url(templateberg_connect()->get_remote_disconnect_url())?>" class="tb-btn tb-btn__default">
<?php esc_html_e('Disconnect', 'templateberg'); ?>
</a>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,7 @@
<div class="tb-connecting">
<div class="tb-connecting__loaders">
<div class="tb-connecting__lines"></div>
<div class="tb-connecting__lines"></div>
<div class="tb-connecting__lines"></div>
</div>
</div>

View File

@@ -0,0 +1,28 @@
<div class="tb-accordion__wrap">
<h3>
<?php
esc_attr_e('Frequently Asked Questions', 'templateberg');
?>
</h3>
<?php
$faq = templateberg_connect()->faq();
foreach ($faq as $key => $setting) {
echo "<div class='tb-accordion'>";
echo "<div class='tb-accordion__header'>";
echo "<h4 class='tb-accordion__heading'>";
echo "<a data-toggle='collapse' href='#tb-faq__" . esc_attr($key) . "'>";
echo '<span>';
echo esc_html($setting['q']);
echo '</span>';
echo '</a>';
echo '</h4>';
echo '</div>';
echo "<div id='tb-faq__" . esc_attr($key) . "' class='hidden tb-accordion__bodywrap'>";
echo "<div class='tb-accordion__body'>";
echo wp_kses_post($setting['a']);
echo '</div>';
echo '</div>';
echo '</div>';
}
?>
</div>

View File

@@ -0,0 +1,92 @@
<div class="tb-all_content_wrap">
<div class="tb-getting_started">
<div class="tb-global__header">
<div class="tb-container">
<div class="tb-row">
<div class="tb-col-7">
<div class="tb-global__caption">
<h2 class="tb-global__htitle">
<?php echo esc_html__('Welcome to Templateberg', 'templateberg'); ?>
</h2>
</div>
</div>
</div>
</div>
</div>
<div class="tb-container">
<div class="tb-row">
<div class="tb-col-6">
<div class="tb-connect__notice tb-text__center">
<div class="tb-connect__icon">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/logo-48x48.png');?>" alt="<?php esc_attr_e('Templateberg', 'templateberg');?>">
</div>
<h4 class="tb-connect__title">
<?php echo esc_html__('Get access to hundreds of free WordPress templates by creating free account.', 'templateberg'); ?>
</h4>
<p class="tb-connect__desc">
<?php echo esc_html__("Templateberg power you to create site quickly and easily. You don't have to spend hours trying to create a template and block design. With a click your favourite template design will import on your site and you can change text, image and customize it for your needs.", 'templateberg'); ?>
<?php echo esc_html__("Clicking the button below will also install and activate the Gutentor Plugin since most of the templates are built with it.", 'templateberg'); ?>
</p>
<p class="tb-connect__gutentor">
</p>
<a id="tb-connect-btn" href="<?php echo esc_url(templateberg_connect()->get_remote_connect_url())?>" target="_blank" class="tb-btn tb-btn__primary tb-btn__lg"><?php echo esc_html__('Get Started With Templateberg', 'templateberg'); ?></a>
</div>
</div>
<div class="tb-col-6">
<div class="tb-templates tb-template__landing">
<div class="tb-templates__wrap">
<div class="tb-templates__list">
<div class="tb-row tb-template__heading_wrap">
<div class="tb-col-12">
<h3 class="tb-account__heading">
<?php echo esc_html__('Free Templates', 'templateberg'); ?>
</h3>
</div>
</div>
<div class="tb-row">
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-10-home-01.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/medical-template.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-03-home.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-13-home.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-12-home.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-13-home.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-13-home.jpg')?>" />
</div>
<div class="tb-col-3">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/cosmoswp_demo-02-home-01.jpg')?>" />
</div>
<div class="tb-col-12 tb-text__center">
<a href="https://templateberg.com/gutenberg-templates/" class="tb-btn tb-btn__primary" target="_blank">
<?php echo esc_html__('Gutenberg Templates', 'templateberg'); ?>
</a>
<a href="https://templateberg.com/wordpress-themes-template-kits/" class="tb-btn tb-btn__primary" target="_blank">
<?php echo esc_html__('Theme Template Kits', 'templateberg'); ?>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,16 @@
<div class="tb-global__header">
<div class="tb-container">
<div class="tb-global__caption">
<h2 class="tb-global__htitle">
<?php echo esc_html__('Welcome to Templateberg', 'templateberg'); ?>
</h2>
<p class="tb-global__desc">
<?php echo esc_html__("Templateberg power you to create site quickly and easily. You don't have to spend hours trying to create a template and block design. With a click your favourite template design will import on your site and you can change text, image and customize it for your needs.", 'templateberg'); ?>
</p>
<a href="<?php echo esc_url(admin_url('post-new.php?post_type=page')); ?>" target="_blank" class="tb-btn tb-btn__primary tb-btn__lg">
<?php echo esc_html__('Get Started With New Page', 'templateberg'); ?>
</a>
</div>
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/prospective-image-640x214.png')?>" alt="<?php esc_attr_e('Template Kits', 'templateberg'); ?>"/>
</div>
</div>

View File

@@ -0,0 +1,32 @@
<?php
/**
* Fired during plugin activation
*
* @link https://www.templateberg.com/
* @since 1.0.0
*
* @package Templateberg
*/
/**
* Fired during plugin activation.
*
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.0.0
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg_Activator {
/**
* Short Description. (use period)
*
* Long Description.
*
* @since 1.0.0
*/
public static function activate() {
update_option( '__templateberg_do_redirect', true );
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Fired during plugin deactivation
*
* @link https://www.templateberg.com/
* @since 1.0.0
*
* @package Templateberg
*/
/**
* Fired during plugin deactivation.
*
* This class defines all code necessary to run during the plugin's deactivation.
*
* @since 1.0.0
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg_Deactivator
{
/**
* Short Description. (use period)
*
* Long Description.
*
* @since 1.0.0
*/
public static function deactivate()
{
update_option('__templateberg_do_redirect', false);
}
}

View File

@@ -0,0 +1,276 @@
<?php
/**
* The Templateberg theme hooks callback functionality of the plugin.
*
* @link https://www.templateberg.com/
* @since 1.0.0
*
* @package Templateberg
*/
/**
* The Templateberg theme hooks callback functionality of the plugin.
*
* Since Templateberg theme is hooks base theme, this file is main callback to add/remove/edit the functionality of the Templateberg Plugin
*
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg_Hooks {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
*/
public function __construct() {
}
/**
* Main Templateberg_Hooks Instance
* Initialize the class and set its properties.
*
* @since 1.0.0
* @return object $instance Templateberg_Hooks Instance
*/
public static function instance() {
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if ( null === $instance ) {
$instance = new Templateberg_Hooks();
$instance->plugin_name = TEMPLATEBERG_PLUGIN_NAME;
$instance->version = TEMPLATEBERG_VERSION;
}
// Always return the instance
return $instance;
}
/**
* Callback functions for enqueue_block_editor_assets,
* Enqueue Gutenberg block assets for backend only.
*
* @since 1.0.0
* @access public
*
* @param null
* @return void
*/
public function block_editor_assets() { // phpcs:ignore
$dependencies = array( 'jquery', 'lodash', 'wp-api', 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-keycodes', 'wp-plugins', 'wp-rich-text', 'wp-viewport' );
if ( templateberg_is_edit_page() ) {
array_push( $dependencies, 'wp-editor', 'wp-edit-post' );
}
// Scripts.
wp_enqueue_script(
'templateberg-editor', // Handle.
TEMPLATEBERG_URL . 'dist/blocks.build.js', // Block.build.js: We register the block here. Built with Webpack.
$dependencies, // Dependencies, defined above.
TEMPLATEBERG_VERSION, // Version: File modification time.
true // Enqueue the script in the footer.
);
wp_set_script_translations( 'templateberg-editor', 'templateberg' );
wp_localize_script(
'templateberg-editor',
'templateberg',
array(
'nonce' => wp_create_nonce( 'templateberg_nonce' ),
'gutentor' => array(
'active' => templateburg_is_gutentor_active(),
),
'user' => array(
'id' => get_current_user_id(),
),
'connectUrl' => esc_url( templateberg_connect()->get_remote_connect_url() ),
'templatebergWhiteSvg' => TEMPLATEBERG_URL . 'assets/svg/templateberg-white-svg.svg',
'templateLibrarySvg' => TEMPLATEBERG_URL . 'assets/svg/template-library.svg',
'templatebergLogo' => esc_url( TEMPLATEBERG_URL . 'assets/img/logo-48x48.png' ),
'itemCurrent' => array(),
'plugin_url' => admin_url( 'plugins.php' ),
)
);
// Styles.
wp_enqueue_style(
'templateberg-editor', // Handle.
TEMPLATEBERG_URL . 'dist/blocks.editor.build.css',
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
TEMPLATEBERG_VERSION // Version: File modification time.
);
wp_style_add_data( 'templateberg-editor', 'rtl', 'replace' );
}
/**
* Callback functions for admin_enqueue_scripts,
* Enqueue Admin page assets for backend only.
*
* @since 1.0.0
* @access public
*
* @param null
* @return void
*/
public function admin_scripts() { // phpcs:ignore
if ( ! templateberg_connect()->is_current_screen() ) {
return;
}
// Scripts.
wp_enqueue_script(
'templateberg-dashboard', // Handle.
TEMPLATEBERG_URL . 'dist/admin.min.js', // Block.build.js: We register the block here. Built with Webpack.
array( 'jquery', 'jquery-ui-dialog' ), // Dependencies, defined above.
TEMPLATEBERG_VERSION, // Version: File modification time.
true // Enqueue the script in the footer.
);
wp_localize_script(
'templateberg-dashboard',
'templateberg',
array(
'restNonce' => wp_create_nonce( 'wp_rest' ),
'restUrl' => esc_url_raw( rest_url() ),
'account' => templateberg_connect()->get_account(),
'advancedImport' => array(
'active' => templateburg_is_advanced_import_active(),
),
'purchase_url' => templateberg_connect()->get_purchase_url(),
'admin_url' => templateberg_connect()->get_admin_url(),
'nonce' => wp_create_nonce( 'templateberg_nonce' ),
'msg' => array(
'not_connected' => __( 'Error! Not Connected to templateberg.com', 'templateberg' ),
'failed' => __( 'Error! Fail to sync.', 'templateberg' ),
),
'has_templates' => array(
'current_theme' => templateberg_has_templates( 'current-theme' ),
'current_theme_nothing' => templateberg_current_theme_is_nothing(),
'available_themes' => templateberg_has_templates( 'available-themes' ),
'gutenberg_templates' => templateberg_has_templates( 'gutenberg-templates' ),
),
)
);
// Styles.
wp_enqueue_style(
'templateberg-dashboard', // Handle.
TEMPLATEBERG_URL . 'dist/admin.css',
array( 'wp-jquery-ui-dialog' ), // Dependencies, defined above.
TEMPLATEBERG_VERSION // Version: File modification time.
);
if ( templateburg_is_advanced_import_active() ) {
advanced_import_admin()->enqueue_scripts( 'appearance_page_advanced-import' );
}
}
/**
* Callback functions for block_categories,
* Adding Block Categories
*
* @since 1.0.0
* @access public
*
* @param array $categories
* @return array
*/
public function add_block_categories( $categories ) {
return array_merge(
array(
array(
'slug' => 'templateberg-modules',
'title' => __( 'Templateberg', 'templateberg' ),
),
),
$categories
);
}
/**
* Register Favourites Templates User Meta
* templateberg-fav-gt : templateberg-favourites-gutenberg-templates
*
* Common callback function of rest_api_init and admin_init
* Schema: http://json-schema.org/draft-04/schema#
*
* @since 1.1.5
*
* @param null.
* @return void
*/
public function register_user_meta_favourites() {
register_meta(
'user',
'templateberg-fav-gt',
array(
'single' => true,
'type' => 'array',
'show_in_rest' => array(
'schema' => array(
'type' => 'array',
'items' => array(
'type' => 'integer',
),
),
),
)
);
}
/**
* Add plugin menu items.
*
* @access public
*
* @since 1.0.0
* @param string[] $actions An array of plugin action links. By default this can include
* 'activate', 'deactivate', and 'delete'. With Multisite active
* this can also include 'network_active' and 'network_only' items.
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
* @param array $plugin_data An array of plugin data. See get_plugin_data()
* and the {@see 'plugin_row_meta'} filter for the list
* of possible values.
* @param string $context The plugin context. By default this can include 'all',
* 'active', 'inactive', 'recently_activated', 'upgrade',
* 'mustuse', 'dropins', and 'search'.
* @return array settings schema for this plugin.
*/
public function add_plugin_links( $actions, $plugin_file, $plugin_data, $context ) {
$actions[] = '<a href="' . esc_url( menu_page_url( 'templateberg', false ) ) . '">' . esc_html__( 'Getting Started', 'templateberg' ) . '</a>';
return $actions;
}
}
/**
* Begins execution of the hooks.
*
* @since 1.0.0
*/
function templateberg_hooks() {
return Templateberg_Hooks::instance();
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* Define the internationalization functionality
*
* Loads and defines the internationalization files for this plugin
* so that it is ready for translation.
*
* @link https://www.templateberg.com/
* @since 1.0.0
*
* @package Templateberg
*/
/**
* Define the internationalization functionality.
*
* Loads and defines the internationalization files for this plugin
* so that it is ready for translation.
*
* @since 1.0.0
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg_i18n
{
/**
* Load the plugin text domain for translation.
*
* @since 1.0.0
*/
public function load_plugin_textdomain()
{
load_plugin_textdomain(
'templateberg',
false,
dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
);
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Register all actions and filters for the plugin
*
* @link https://www.templateberg.com/
* @since 1.0.0
*
* @package Templateberg
*/
/**
* Register all actions and filters for the plugin.
*
* Maintain a list of all hooks that are registered throughout
* the plugin, and register them with the WordPress API. Call the
* run function to execute the list of actions and filters.
*
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg_Loader
{
/**
* The array of actions registered with WordPress.
*
* @since 1.0.0
* @access protected
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
*/
protected $actions;
/**
* The array of filters registered with WordPress.
*
* @since 1.0.0
* @access protected
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
*/
protected $filters;
/**
* Initialize the collections used to maintain the actions and filters.
*
* @since 1.0.0
*/
public function __construct()
{
$this->actions = array();
$this->filters = array();
}
/**
* Add a new action to the collection to be registered with WordPress.
*
* @since 1.0.0
* @param string $hook The name of the WordPress action that is being registered.
* @param object $component A reference to the instance of the object on which the action is defined.
* @param string $callback The name of the function definition on the $component.
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
*/
public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
{
$this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
}
/**
* Add a new filter to the collection to be registered with WordPress.
*
* @since 1.0.0
* @param string $hook The name of the WordPress filter that is being registered.
* @param object $component A reference to the instance of the object on which the filter is defined.
* @param string $callback The name of the function definition on the $component.
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
*/
public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
{
$this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
}
/**
* A utility function that is used to register the actions and hooks into a single
* collection.
*
* @since 1.0.0
* @access private
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
* @param string $hook The name of the WordPress filter that is being registered.
* @param object $component A reference to the instance of the object on which the filter is defined.
* @param string $callback The name of the function definition on the $component.
* @param int $priority The priority at which the function should be fired.
* @param int $accepted_args The number of arguments that should be passed to the $callback.
* @return array The collection of actions and filters registered with WordPress.
*/
private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
{
$hooks[] = array(
'hook' => $hook,
'component' => $component,
'callback' => $callback,
'priority' => $priority,
'accepted_args' => $accepted_args,
);
return $hooks;
}
/**
* Register the filters and actions with WordPress.
*
* @since 1.0.0
*/
public function run()
{
foreach ($this->filters as $hook) {
add_filter($hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args']);
}
foreach ($this->actions as $hook) {
add_action($hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args']);
}
}
}

View File

@@ -0,0 +1,240 @@
<?php
/**
* The file that defines the core plugin class
*
* A class definition that includes attributes and functions used to
* add/remove/edit the functionality of the Templateberg Plugin
*
* @link https://www.templateberg.com/
* @since 1.0.0
*
* @package Templateberg
*/
/**
* The core plugin class.
*
* This is used to define internationalization, admin-specific hooks, and
* functionality of the plugin
*
* Also maintains the unique identifier of this plugin as well as the current
* version of the plugin.
*
* @since 1.0.0
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg {
/**
* The loader that's responsible for maintaining and registering all hooks that power
* the plugin.
*
* @since 1.0.0
* @access protected
* @var Templateberg_Loader $loader Maintains and registers all hooks for the plugin.
*/
protected $loader;
/**
* The unique identifier of this plugin.
*
* @since 1.0.0
* @access protected
* @var string $plugin_name The string used to uniquely identify this plugin.
*/
protected $plugin_name;
/**
* Full Name of plugin.
*
* @since 1.0.0
* @access protected
* @var string $plugin_full_name The string used to uniquely identify this plugin.
*/
protected $plugin_full_name;
/**
* The current version of the plugin.
*
* @since 1.0.0
* @access protected
* @var string $version The current version of the plugin.
*/
protected $version;
/**
* Main Instance
*
* Insures that only one instance of Templateberg exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @since 1.0.0
* @access public
*
* @return object
*/
public static function instance() {
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if ( null === $instance ) {
$instance = new Templateberg();
do_action( 'templateberg_loaded' );
}
// Always return the instance
return $instance;
}
/**
* Define the core functionality of the plugin.
*
* Set the plugin name and the plugin version that can be used throughout the plugin.
* Load the dependencies, define the locale, and set the hooks for the admin area and
* the public-facing side of the site.
*
* @since 1.0.0
*/
public function run() {
$this->version = TEMPLATEBERG_VERSION;
$this->plugin_name = TEMPLATEBERG_PLUGIN_NAME;
$this->plugin_full_name = 'Templateberg';
$this->load_dependencies();
$this->set_locale();
$this->define_hooks();
$this->load_hooks();
}
/**
* Load the required dependencies for this plugin.
*
* Include the following files that make up the plugin:
*
* - Templateberg_Loader. Orchestrates the hooks of the plugin.
* - Templateberg_i18n. Defines internationalization functionality.
* - Templateberg. Defines all hooks for the admin area.
* - Templateberg_Public. Defines all hooks for the public side of the site.
*
* Create an instance of the loader which will be used to register the hooks
* with WordPress.
*
* @since 1.0.0
* @access private
*/
private function load_dependencies() {
require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-loader.php';
require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-i18n.php';
/*Functions*/
require_once TEMPLATEBERG_PATH . 'includes/functions.php';
/*Hooks*/
require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-hooks.php';
/*Admin*/
require_once TEMPLATEBERG_PATH . 'includes/admin/class-templateberg-gutentor-connect.php';
require_once TEMPLATEBERG_PATH . 'includes/admin/class-templateberg-connect.php';
/*Templates*/
require_once TEMPLATEBERG_PATH . 'includes/lists/templateberg-template-lists-data.php';
require_once TEMPLATEBERG_PATH . 'includes/lists/class-templateberg-gutenberg-templates.php';
require_once TEMPLATEBERG_PATH . 'includes/lists/class-templateberg-themes-template-kits.php';
/*Rest API*/
require_once TEMPLATEBERG_PATH . 'includes/admin/class-templateberg-template-api.php';
$this->loader = new Templateberg_Loader();
}
/**
* Define the locale for this plugin for internationalization.
*
* Uses the Templateberg_i18n class in order to set the domain and to register the hook
* with WordPress.
*
* @since 1.0.0
* @access private
*/
private function set_locale() {
$plugin_i18n = new Templateberg_i18n();
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
}
/**
* Register all of the hooks related to the admin area functionality
* of the plugin.
*
* @since 1.0.0
* @access private
*/
private function define_hooks() {
$plugin_hooks = templateberg_hooks();
/*Hook : Admin page*/
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_hooks, 'admin_scripts' );
$this->loader->add_action( 'plugin_action_links_templateberg/templateberg.php', $plugin_hooks, 'add_plugin_links', 10, 4 );
/*Hook: Editor assets.*/
$this->loader->add_action( 'enqueue_block_editor_assets', $plugin_hooks, 'block_editor_assets' );
$this->loader->add_action( 'block_categories_all', $plugin_hooks, 'add_block_categories', 9999 );
/*Add Favourites Templates User Meta*/
$this->loader->add_action( 'rest_api_init', $plugin_hooks, 'register_user_meta_favourites' );
$this->loader->add_action( 'admin_init', $plugin_hooks, 'register_user_meta_favourites' );
}
/**
* Run the loader to execute all of the hooks with WordPress.
*
* @since 1.0.0
*/
public function load_hooks() {
$this->loader->run();
}
/**
* The name of the plugin used to uniquely identify it within the context of
* WordPress and to define internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
*/
public function get_plugin_name() {
return $this->plugin_name;
}
/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 1.0.0
* @return Templateberg_Loader Orchestrates the hooks of the plugin.
*/
public function get_loader() {
return $this->loader;
}
/**
* Retrieve the version number of the plugin.
*
* @since 1.0.0
* @return string The version number of the plugin.
*/
public function get_version() {
return $this->version;
}
}

View File

@@ -0,0 +1,726 @@
<?php
if ( ! function_exists( 'templateberg_is_edit_page' ) ) {
function templateberg_is_edit_page() {
// make sure we are on the backend
if ( ! is_admin() ) {
return false;
}
global $pagenow;
return in_array( $pagenow, array( 'post.php', 'post-new.php' ) );
}
}
if ( ! function_exists( 'templateberg_get_payment_info_html' ) ) {
function templateberg_get_payment_info_html() {
$payment_info = templateberg_connect()->get_purchase();
if ( is_array( $payment_info ) && ! empty( $payment_info ) ) {
?>
<div class="tb-purchase__wrap">
<div class="tb-purchase__id">
<span class="tb-purchase__title"><?php echo esc_html__( 'ID', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__type">
<span class="tb-purchase__title"><?php echo esc_html__( 'Type', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__type">
<span class="tb-purchase__title"><?php echo esc_html__( 'Name', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__date">
<span class="tb-purchase__title"><?php echo esc_html__( 'Date', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__amount">
<span class="tb-purchase__title"><?php echo esc_html__( 'Amount', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__limit">
<span class="tb-purchase__title"><?php echo esc_html__( 'Limit', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__plan">
<span class="tb-purchase__title"><?php echo esc_html__( 'Plan', 'templateberg' ); ?></span>
</div>
<div class="tb-purchase__link">
<span class="tb-purchase__title"><?php echo esc_html__( 'Details', 'templateberg' ); ?></span>
</div>
</div>
<?php
foreach ( $payment_info as $pi ) {
?>
<div class="tb-purchase__wrap">
<div class="tb-purchase__id">
<span class="tb-purchase__desc">
<?php echo isset( $pi['id'] ) ? esc_html( $pi['id'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__type">
<span class="tb-purchase__desc">
<?php echo isset( $pi['type'] ) ? esc_html( $pi['type'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__type">
<span class="tb-purchase__desc">
<?php echo isset( $pi['title'] ) ? wp_kses_post( $pi['title'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__date">
<span class="tb-purchase__desc">
<?php echo isset( $pi['date'] ) ? esc_html( $pi['date'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__amount">
<span class="tb-purchase__desc">
<?php echo isset( $pi['amount'] ) ? esc_html( $pi['amount'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__limit">
<span class="tb-purchase__desc">
<?php echo isset( $pi['limit'] ) ? esc_html( $pi['limit'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__plan">
<span class="tb-purchase__desc">
<?php echo isset( $pi['plan'] ) ? esc_html( $pi['plan'] ) : ''; ?>
</span>
</div>
<div class="tb-purchase__plan">
<span class="tb-purchase__desc">
<?php echo wp_kses_post( $pi['details'] ); ?>
</span>
</div>
</div>
<?php
}
} else {
?>
<div class="tb-info__box">
<?php echo esc_html__( 'No payment information found', 'templateberg' ); ?>
</div>
<?php
}
}
}
if ( ! function_exists( 'templateberg_get_free_templates_html' ) ) {
function templateberg_get_free_templates_html() {
$free_templates = templateberg_connect()->get_free_templates();
if ( is_array( $free_templates ) && ! empty( $free_templates ) ) {
echo '<div class="tb-row">';
foreach ( $free_templates as $ft ) {
?>
<div class="tb-col-3">
<img src="<?php echo esc_url( $ft['screenshot_url'] ); ?>" alt="<?php echo esc_attr( $ft['title'] ); ?>"/>
</div>
<?php
}
echo '</div>';
} else {
?>
<div class="tb-info__box">
<?php echo esc_html__( 'No template information found', 'templateberg' ); ?>
</div>
<?php
}
}
}
/**
* check if Gutentor activated
*/
if ( ! function_exists( 'templateburg_is_gutentor_active' ) ) {
function templateburg_is_gutentor_active() {
return class_exists( 'Gutentor' ) ? true : false;
}
}
/**
* check if Gutentor activated
*/
if ( ! function_exists( 'templateburg_is_advanced_import_active' ) ) {
function templateburg_is_advanced_import_active() {
return class_exists( 'Advanced_Import' ) ? true : false;
}
}
/**
* Get Transients by prefix
*
* @param $prefix string Prefix of Transients
* without _transient_
*
* @return array|boolean Array of Transients or false if no Transients
*/
if ( ! function_exists( 'templateberg_get_transients_by_prefix' ) ) {
function templateberg_get_transients_by_prefix( $prefix ) {
global $wpdb;
/*Add Prefix*/
$prefix = $wpdb->esc_like( '_transient_' . $prefix );
/*SQL*/
$sql = "SELECT `option_name` FROM $wpdb->options WHERE `option_name` LIKE '%s'";
/*Get transients*/
$transients = $wpdb->get_results(
$wpdb->prepare(
$sql,
$prefix . '%'
),
ARRAY_A
);
/*Return*/
if ( $transients && ! is_wp_error( $transients ) ) {
return $transients;
}
/*No transients, return false*/
return false;
}
}
/**
* Delete Transients by prefix
*
* @param $prefix string Prefix of Transients
* without _transient_
*
* @return array|boolean Array of found Transients and deleted Transients options name
* or false if no Transients
*/
if ( ! function_exists( 'templateberg_delete_transients_by_prefix' ) ) {
function templateberg_delete_transients_by_prefix( $prefix ) {
$transients = templateberg_get_transients_by_prefix( $prefix );
if ( ! $transients ) {
return false;
}
$deleted = array();
/*Loop through found transients*/
foreach ( $transients as $transient ) {
$deleted[] = $transient['option_name'];
delete_transient( str_replace( '_transient_', '', $transient['option_name'] ) );
}
/*
Return an array of total transients
and deleted transients option_name*/
return array(
'found' => count( $transients ),
'deleted' => $deleted,
);
}
}
/**
* Function create pagination
*
* @param [array] $attr
* @return String
*/
if ( ! function_exists( 'templateberg_pagination' ) ) {
function templateberg_pagination( $paged = false, $max_num_pages = false ) {
$da_link = get_post_type_archive_link( 'download' );
$nextDisabled = ( $paged + 1 ) > $max_num_pages ? 'tb-list__page-disabled' : '';
$prevDisabled = ( $paged - 1 ) < 1 ? 'tb-list__page-disabled' : '';
$prevPage = ( $paged - 1 ) < 1 ? 1 : $paged - 1;
$nextPage = ( $paged + 1 ) > $max_num_pages ? $max_num_pages : $paged + 1;
$phtml = '';
$phtml .= '<div class="tb-list__navigation"><nav aria-label="Page navigation"><ul class="tb-list__pagination">';
$phtml .= '<li class="tb-list__page-item ' . $prevDisabled . '"><a class="tb-list__page-link" href="' . esc_url( $da_link ) . 'page/' . $prevPage . '" data-gpage="' . esc_html( $prevPage ) . '">' . esc_html__( 'Previous', 'templateberg' ) . '</a></li>';
if ( ! $paged ) {
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
}
if ( ! $max_num_pages ) {
global $wp_query;
$max_num_pages = $wp_query->max_num_pages;
if ( ! $max_num_pages ) {
$max_num_pages = 1;
}
}
$mid_pages = $paged >= 3 ? array( $paged - 1, $paged, $paged + 1 ) : array( 1, 2, 3 );
if ( $max_num_pages > 1 ) {
if ( ! in_array( 1, $mid_pages ) ) {
$is_active = $paged == 1 ? ' tb-list__page-active' : '';
$phtml .= '<li class="tb-list__page-item ' . $is_active . '">
<a class="tb-list__page-link" href="' . esc_url( $da_link ) . 'page/1" data-gpage="1">' . __( '1', 'templateberg' ) . '</a>
</li>';
}
if ( $paged > 3 ) {
$phtml .= '<li class="tb-list__page-item tb-list__pagination-dots"><a class="tb-list__page-link" href="#">...</a></li>';
}
foreach ( $mid_pages as $i ) {
if ( $max_num_pages >= $i ) {
$is_active = $paged == $i ? ' tb-list__page-active' : '';
$phtml .= '<li class="tb-list__page-item' . $is_active . '">
<a class="tb-list__page-link" href="' . esc_url( $da_link ) . 'page/' . $i . '" data-gpage="' . $i . '">' . __( $i, 'templateberg' ) . '</a>
</li>';
}
}
if ( $max_num_pages > $paged + 1 ) {
if ( $max_num_pages > 3 ) {
$phtml .= '<li class="tb-list__page-item tb-list__pagination-dots"><a class="tb-list__page-link" href="#">...</a></li>';
}
if ( $max_num_pages > 3 ) {
$is_active = $paged == $max_num_pages ? ' tb-list__page-active' : '';
$phtml .= '<li class="tb-list__page-item ' . $is_active . '">
<a class="tb-list__page-link" href="' . esc_url( $da_link ) . 'page/' . $max_num_pages . '" data-gpage="' . $max_num_pages . '">' . __( $max_num_pages, 'templateberg' ) . '</a>
</li>';
}
}
}
$phtml .= ' <li class="tb-list__page-item ' . $nextDisabled . '"><a class="tb-list__page-link" href="' . esc_url( $da_link ) . 'page/' . $nextPage . '" data-gpage="' . esc_html( $nextPage ) . '">' . esc_html__( 'Next', 'templateberg' ) . '</a></li>';
$phtml .= '</ul></nav></div>';
return $phtml;
}
}
/**
* Function to get Current Theme Info
*
* @param [array] $attr
* @return array
*/
if ( ! function_exists( 'templateberg_get_current_theme_info' ) ) {
function templateberg_get_current_theme_info() {
return array(
'template' => get_template(),
'stylesheet' => get_stylesheet(),
'author' => wp_get_theme()->get( 'Author' ),
);
}
}
/**
* Function to get Current Theme Button
*
* @param [array] $attr
* @return boolean
*/
if ( ! function_exists( 'templateberg_is_current_theme_template_available' ) ) {
function templateberg_is_current_theme_template_available( $item ) {
$is_available = false;
if ( ! isset( $item['is_pro'] ) || ! $item['is_pro'] ) {
$is_available = true;
} elseif ( empty( templateberg_connect()->get_current_theme_purchase_templates_id() ) ) {
$is_available = false;
} elseif ( in_array( $item['id'], templateberg_connect()->get_current_theme_purchase_templates_id() ) ) {
$is_available = true;
}
return $is_available;
}
}
/**
* Function check if templates has set up
*
* @param [array] $attr
* @return boolean
*/
if ( ! function_exists( 'templateberg_has_templates' ) ) {
function templateberg_has_templates( $type, $theme_slug = '' ) {
$is_available = false;
switch ( $type ) {
case 'current-theme':
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
if ( $theme_slug ) {
$theme = $theme_slug;
} else {
$theme = get_stylesheet();
}
$themes_list = templateberg_get_current_theme_templates( $paged, $theme );
if ( $themes_list && 'nothing' !== $themes_list ) {
$is_available = true;
}
break;
case 'available-themes':
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$themes_list = templateberg_get_theme_templates( $paged );
if ( $themes_list ) {
$is_available = true;
}
break;
default:
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$templates_list = templateberg_get_gutenberg_templates( $paged );
if ( $templates_list ) {
$is_available = true;
}
break;
}
return $is_available;
}
}
/**
* Function set gutenberg templates
*
* @param [array] $attr
* @return boolean
*/
if ( ! function_exists( 'templateberg_set_gutenberg_templates' ) ) {
function templateberg_set_gutenberg_templates( $templates_list, $paged = 1 ) {
$is_set = false;
$message = array();
if ( set_transient( 'templateberg_gt_' . $paged, $templates_list, WEEK_IN_SECONDS ) !== true ) {
global $wp_filesystem;
if ( ! $wp_filesystem ) {
require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php';
}
$upload_dir = wp_upload_dir();
$dir = trailingslashit( $upload_dir['basedir'] ) . 'templateberg' . DIRECTORY_SEPARATOR;
WP_Filesystem();
if ( ! $wp_filesystem->is_dir( $dir ) ) {
$message[] = $dir . __( ' not exists', 'templateberg' );
if ( $wp_filesystem->mkdir( $dir ) ) {
$message[] = $dir . __( ' created', 'templateberg' );
} else {
$message[] = $dir . __( ' create permission issue', 'templateberg' );
}
} else {
$message[] = $dir . __( ' exists', 'templateberg' );
}
$templates_list = wp_json_encode( $templates_list );
if ( $wp_filesystem->put_contents( $dir . 'gt-' . $paged . '.json', $templates_list, 0644 ) ) {
$is_set = true;
$message[] = __( 'Successfully created file ', 'templateberg' ) . 'gt-' . $paged . '.json';
} else {
$message[] = __( 'Permission denied to create file ', 'templateberg' ) . 'gt-' . $paged . '.json';
}
} else {
$is_set = true;
}
return $is_set;
}
}
/**
* Function get gutenberg templates
*
* @param [array] $attr
* @return boolean
*/
if ( ! function_exists( 'templateberg_get_gutenberg_templates' ) ) {
function templateberg_get_gutenberg_templates( $paged = 1 ) {
$templates_list = get_transient( 'templateberg_gt_' . $paged );
if ( ! $templates_list ) {
$upload_dir = wp_upload_dir();
$file_dir = $upload_dir['basedir'] . '/templateberg/' . 'gt-' . $paged . '.json';
if ( file_exists( $file_dir ) ) {
$file_url = $upload_dir['baseurl'] . '/templateberg/' . 'gt-' . $paged . '.json';
$body_args = array(
/*API version*/
'api_version' => TEMPLATEBERG_VERSION,
/*lang*/
'site_lang' => get_bloginfo( 'language' ),
);
$raw_json = wp_safe_remote_get(
$file_url,
array(
'timeout' => 100,
'body' => $body_args,
)
);
if ( ! is_wp_error( $raw_json ) ) {
$templates_list = json_decode( wp_remote_retrieve_body( $raw_json ), true );
} else {
$templates_list = false;
}
}
}
return $templates_list;
}
}
/**
* Function set editor templates
*
* @param [array] $templates_list
* @param [int] $paged
* @return boolean
*/
if ( ! function_exists( 'templateberg_set_editor_templates' ) ) {
function templateberg_set_editor_templates( $templates_list, $paged = 1 ) {
$is_set = false;
$message = array();
ob_start();
$is_transient_saved = set_transient( 'templateberg_edt_' . $paged, $templates_list, WEEK_IN_SECONDS );
ob_clean();
if ( $is_transient_saved !== true ) {
global $wp_filesystem;
if ( ! $wp_filesystem ) {
require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php';
}
$upload_dir = wp_upload_dir();
$dir = trailingslashit( $upload_dir['basedir'] ) . 'templateberg' . DIRECTORY_SEPARATOR;
WP_Filesystem();
if ( ! $wp_filesystem->is_dir( $dir ) ) {
$message[] = $dir . __( ' not exists', 'templateberg' );
if ( $wp_filesystem->mkdir( $dir ) ) {
$message[] = $dir . __( ' created', 'templateberg' );
} else {
$message[] = $dir . __( ' create permission issue', 'templateberg' );
}
} else {
$message[] = $dir . __( ' exists', 'templateberg' );
}
$templates_list = wp_json_encode( $templates_list );
if ( $wp_filesystem->put_contents( $dir . 'edt-' . $paged . '.json', $templates_list, 0644 ) ) {
$is_set = true;
$message[] = __( 'Successfully created file ', 'templateberg' ) . 'edt-' . $paged . '.json';
} else {
$message[] = __( 'Permission denied to create file ', 'templateberg' ) . 'edt-' . $paged . '.json';
}
} else {
$is_set = true;
}
return $is_set;
}
}
/**
* Function get editor templates
*
* @param [int] $paged
* @return array
*/
if ( ! function_exists( 'templateberg_get_editor_templates' ) ) {
function templateberg_get_editor_templates( $paged = 1 ) {
$templates_list = get_transient( 'templateberg_edt_' . $paged );
if ( ! $templates_list ) {
$upload_dir = wp_upload_dir();
$file_dir = $upload_dir['basedir'] . '/templateberg/' . 'edt-' . $paged . '.json';
if ( file_exists( $file_dir ) ) {
$file_url = $upload_dir['baseurl'] . '/templateberg/' . 'edt-' . $paged . '.json';
$body_args = array(
/*API version*/
'api_version' => TEMPLATEBERG_VERSION,
/*lang*/
'site_lang' => get_bloginfo( 'language' ),
);
$raw_json = wp_safe_remote_get(
$file_url,
array(
'timeout' => 100,
'body' => $body_args,
)
);
if ( ! is_wp_error( $raw_json ) ) {
$templates_list = json_decode( wp_remote_retrieve_body( $raw_json ), true );
} else {
$templates_list = false;
}
}
}
return $templates_list;
}
}
/**
* Function set theme templates
*
* @param [array] $templates_list
* @param [int] $paged
* @return boolean
*/
if ( ! function_exists( 'templateberg_set_theme_templates' ) ) {
function templateberg_set_theme_templates( $templates_list, $paged = 1 ) {
$is_set = false;
$message = array();
if ( set_transient( 'templateberg_tt_' . $paged, $templates_list, 'WEEK_IN_SECONDS' ) !== true ) {
global $wp_filesystem;
if ( ! $wp_filesystem ) {
require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php';
}
$upload_dir = wp_upload_dir();
$dir = trailingslashit( $upload_dir['basedir'] ) . 'templateberg' . DIRECTORY_SEPARATOR;
WP_Filesystem();
if ( ! $wp_filesystem->is_dir( $dir ) ) {
$message[] = $dir . __( ' not exists', 'templateberg' );
if ( $wp_filesystem->mkdir( $dir ) ) {
$message[] = $dir . __( ' created', 'templateberg' );
} else {
$message[] = $dir . __( ' create permission issue', 'templateberg' );
}
} else {
$message[] = $dir . __( ' exists', 'templateberg' );
}
$templates_list = wp_json_encode( $templates_list );
if ( $wp_filesystem->put_contents( $dir . 'tt-' . $paged . '.json', $templates_list, 0644 ) ) {
$is_set = true;
$message[] = __( 'Successfully created file ', 'templateberg' ) . 'tt-' . $paged . '.json';
} else {
$message[] = __( 'Permission denied to create file ', 'templateberg' ) . 'tt-' . $paged . '.json';
}
} else {
$is_set = true;
}
return $is_set;
}
}
/**
* Function get editor templates
*
* @param [int] $paged
* @return array
*/
if ( ! function_exists( 'templateberg_get_theme_templates' ) ) {
function templateberg_get_theme_templates( $paged = 1 ) {
$templates_list = get_transient( 'templateberg_tt_' . $paged );
if ( ! $templates_list ) {
$upload_dir = wp_upload_dir();
$file_dir = $upload_dir['basedir'] . '/templateberg/' . 'tt-' . $paged . '.json';
if ( file_exists( $file_dir ) ) {
$file_url = $upload_dir['baseurl'] . '/templateberg/' . 'tt-' . $paged . '.json';
$body_args = array(
/*API version*/
'api_version' => TEMPLATEBERG_VERSION,
/*lang*/
'site_lang' => get_bloginfo( 'language' ),
);
$raw_json = wp_safe_remote_get(
$file_url,
array(
'timeout' => 100,
'body' => $body_args,
)
);
if ( ! is_wp_error( $raw_json ) ) {
$templates_list = json_decode( wp_remote_retrieve_body( $raw_json ), true );
} else {
$templates_list = false;
}
}
}
return $templates_list;
}
}
/**
* Function set current theme templates
*
* @param [array] $templates_list
* @param [int] $paged
* @return boolean
*/
if ( ! function_exists( 'templateberg_set_current_theme_templates' ) ) {
function templateberg_set_current_theme_templates( $templates_list, $paged = 1, $theme_slug = '' ) {
$is_set = false;
$message = array();
if ( $theme_slug ) {
$theme = $theme_slug;
} else {
$theme = get_stylesheet();
}
if ( set_transient( 'templateberg_ct_' . $theme . '_templates_' . $paged, $templates_list, 'WEEK_IN_SECONDS' ) !== true ) {
global $wp_filesystem;
if ( ! $wp_filesystem ) {
require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php';
}
$upload_dir = wp_upload_dir();
$dir = trailingslashit( $upload_dir['basedir'] ) . 'templateberg' . DIRECTORY_SEPARATOR;
WP_Filesystem();
if ( ! $wp_filesystem->is_dir( $dir ) ) {
$message[] = $dir . __( ' not exists', 'templateberg' );
if ( $wp_filesystem->mkdir( $dir ) ) {
$message[] = $dir . __( ' created', 'templateberg' );
} else {
$message[] = $dir . __( ' create permission issue', 'templateberg' );
}
} else {
$message[] = $dir . __( ' exists', 'templateberg' );
}
$templates_list = wp_json_encode( $templates_list );
if ( $wp_filesystem->put_contents( $dir . 'ct-' . $theme . '-' . $paged . '.json', $templates_list, 0644 ) ) {
$is_set = true;
$message[] = __( 'Successfully created file ', 'templateberg' ) . 'ct-' . $theme . '-' . $paged . '.json';
} else {
$message[] = __( 'Permission denied to create file ', 'templateberg' ) . 'ct-' . $theme . '-' . $paged . '.json';
}
} else {
$is_set = true;
}
return $is_set;
}
}
/**
* Function get current theme templates
*
* @param [int] $paged
* @return array
*/
if ( ! function_exists( 'templateberg_get_current_theme_templates' ) ) {
function templateberg_get_current_theme_templates( $paged = 1, $theme_slug = '' ) {
if ( $theme_slug ) {
$theme = $theme_slug;
} else {
$theme = get_stylesheet();
}
$templates_list = get_transient( 'templateberg_ct_' . $theme . '_templates_' . $paged );
if ( ! $templates_list ) {
$upload_dir = wp_upload_dir();
$file_dir = $upload_dir['basedir'] . '/templateberg/' . 'ct-' . $theme . '-' . $paged . '.json';
if ( file_exists( $file_dir ) ) {
$file_url = $upload_dir['baseurl'] . '/templateberg/' . 'ct-' . $theme . '-' . $paged . '.json';
$body_args = array(
/*API version*/
'api_version' => TEMPLATEBERG_VERSION,
/*lang*/
'site_lang' => get_bloginfo( 'language' ),
);
$raw_json = wp_safe_remote_get(
$file_url,
array(
'timeout' => 100,
'body' => $body_args,
)
);
if ( ! is_wp_error( $raw_json ) ) {
$templates_list = json_decode( wp_remote_retrieve_body( $raw_json ), true );
} else {
$templates_list = false;
}
}
}
return $templates_list;
}
}
/**
* Function check if templates has set up
*
* @param [array] $attr
* @return boolean
*/
if ( ! function_exists( 'templateberg_current_theme_is_nothing' ) ) {
function templateberg_current_theme_is_nothing() {
$is_available = false;
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$theme = get_stylesheet();
$themes_list = templateberg_get_current_theme_templates( $paged, $theme );
if ( 'nothing' === $themes_list ) {
$is_available = true;
}
return $is_available;
}
}

View File

@@ -0,0 +1,106 @@
<?php
/**
* Templateberg Gutenberg Templates
*
* @since 1.0.4
*/
if (! class_exists('Templateberg_Gutenberg_Templates')) {
/**
* Class Templateberg_Gutenberg_Templates.
*/
class Templateberg_Gutenberg_Templates
{
private static $page_slug = 'templateberg-gutenberg-templates';
/**
* Main Templateberg_Gutenberg_Templates Instance
* Initialize the class and set its properties.
*
* @since 1.0.0
* @return object $instance Templateberg_Gutenberg_Templates Instance
*/
public static function instance()
{
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if (null === $instance) {
$instance = new Templateberg_Gutenberg_Templates();
}
// Always return the instance
return $instance;
}
/**
* Get Slug
*
* @since 1.0.4
*/
public function get_slug()
{
return self::$page_slug;
}
/**
* Run the method
*
* @since 1.0.0
*/
public function run()
{
add_action('admin_menu', array( __CLASS__, 'admin_pages' ), 99);
}
/**
* Admin Page Menu and submenu page
*
* @since 1.0.0
*/
public static function admin_pages()
{
add_submenu_page(
templateberg_connect()->get_slug(),
esc_html__('Gutenberg Templates', 'templateberg'),
esc_html__('Gutenberg Templates', 'templateberg'),
'manage_options',
self::$page_slug,
array( __CLASS__, 'gutenberg_templates' )
);
}
/**
* Load account templates
*
* @since 1.0.0
*/
public static function gutenberg_templates()
{
?>
<div class="tb-gutenberg-templates" style="display: none">
<?php
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/gutenberg.php';
?>
</div>
<?php
}
}
}
/**
* Begins execution of the hooks.
*
* @since 1.0.0
*/
function templateberg_gutenberg_templates()
{
return Templateberg_Gutenberg_Templates::instance();
}
templateberg_gutenberg_templates()->run();

View File

@@ -0,0 +1,201 @@
<?php
/**
* Templateberg Theme Templates
*
* @since 1.0.4
*/
if (! class_exists('Templateberg_Theme_Templates')) {
/**
* Class Templateberg_Theme_Templates.
*/
class Templateberg_Theme_Templates
{
private static $page_slug = 'templateberg-themes-template-kits';
/**
* Main Templateberg_Theme_Templates Instance
* Initialize the class and set its properties.
*
* @since 1.0.0
* @return object $instance Templateberg_Theme_Templates Instance
*/
public static function instance()
{
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if (null === $instance) {
$instance = new Templateberg_Theme_Templates();
}
// Always return the instance
return $instance;
}
/**
* Get Slug
*
* @since 1.0.4
*/
public function get_slug()
{
return self::$page_slug;
}
/**
* Run the method
*
* @since 1.0.0
*/
public function run()
{
add_action('admin_menu', array( __CLASS__, 'admin_pages' ), 99);
add_filter('advanced_import_current_url', array( $this, 'alter_url' ), 99, 2);
add_action('admin_init', array( $this, 'admin_only' ), -10);
add_filter('advanced_import_menu_hook_suffix', array( $this, 'add_hook_suffix' ), 99);
}
/**
* Admin Page Menu and submenu page
*
* @since 1.0.0
*/
public static function admin_pages()
{
add_submenu_page(
templateberg_connect()->get_slug(),
esc_html__('Themes Template Kits', 'templateberg'),
esc_html__('Themes Template Kits', 'templateberg'),
'manage_options',
self::$page_slug,
array( __CLASS__, 'theme_templates' )
);
}
public function is_selected_theme()
{
if (isset($_GET['type']) && 'selected' === $_GET['type'] && isset($_GET['theme']) && isset($_GET['slug'])) {
return true;
}
return false;
}
/**
* Load account templates
*
* @since 1.0.0
*/
public static function theme_templates()
{
$active = isset($_GET['type']) && $_GET['type']?$_GET['type']:'current';
?>
<div class="tb-themes-template-kits" style="display: none">
<div class="tb-list__theme_type_header">
<div class="tb-list__theme_type_links">
<a href="#"
class="tb-list__current_theme tb-list__theme_type-btn tb-list__theme_type
<?php echo $active==='current'?'tb-list__theme_type-btn-active':''?>"
data-type="current"
>
<i class="dashicons dashicons-admin-appearance"></i>
<?php
printf(esc_html__('%s Theme Template Kits', 'templateberg'), wp_get_theme()) . '</h1>';
?>
</a>
<?php
if (templateberg_theme_templates()->is_selected_theme()) {
?>
<a href="#"
class="tb-list__current_theme tb-list__theme_type-btn tb-list__theme_type tb-list__theme_type-btn-active"
data-type="selected"
>
<i class="dashicons dashicons-admin-appearance"></i>
<?php
printf(esc_html__('%s Theme Template Kits', 'templateberg'), esc_html($_GET['theme'])) . '</h1>';
?>
</a>
<?php
}
?>
<a
href="#"
class="tb-list__available_theme tb-list__theme_type-btn tb-list__theme_type
<?php echo $active==='available'?'tb-list__theme_type-btn-active':''?>"
data-type="available"
>
<i class="dashicons dashicons-grid-view"></i>
<?php
esc_html_e('Available Template Kits', 'templateberg');
?>
</a>
</div>
</div>
<!--if( tempaltebergGetUrlParameter('type') &&
tempaltebergGetUrlParameter('theme') &&
tempaltebergGetUrlParameter('slug')
)-->
<?php
if ($active==='available') {
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/theme.php';
} elseif (templateberg_theme_templates()->is_selected_theme()) {
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/current-theme.php';
} else {
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/current-theme.php';
}
?>
</div>
<?php
}
public function alter_url($current_url, $pagenow)
{
if ((get_current_screen() && get_current_screen() ->base === 'templateberg_page_'.templateberg_theme_templates()->get_slug()) ||
(isset($_GET['page']) && self::$page_slug === $_GET['page'])
) {
$current_url = admin_url('admin.php?page='.templateberg_theme_templates()->get_slug());
if (isset($_GET['type'])) {
$current_url = $current_url.'&type='.$_GET['type'];
}
}
return $current_url;
}
public function admin_only()
{
$template = get_option('template');
add_filter('advanced_import_' . $template . '_required_plugins', array( $this, 'add_plugins' ), 99, 2);
}
public function add_plugins($plugins)
{
$plugins[] = 'gutentor/gutentor.php';
$plugins[] = 'templateberg/templateberg.php';
return $plugins;
}
public function add_hook_suffix($hook_suffix)
{
$hook_suffix[] = 'templateberg_page_'.self::$page_slug;
return $hook_suffix;
}
}
}
/**
* Begins execution of the hooks.
*
* @since 1.0.0
*/
function templateberg_theme_templates()
{
return Templateberg_Theme_Templates::instance();
}
templateberg_theme_templates()->run();

View File

@@ -0,0 +1,315 @@
<?php
/**
* Fired during plugin activation.
*
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.0.0
* @package Templateberg
* @author Templateberg <info@templateberg.com>
*/
class Templateberg_Template_Lists_Data {
public $data = array();
public $tab = 'block';
public $bCats = array();
public $bFreeCats = array();
public $bProCats = array();
public $tCats = array();
public $tFreeCats = array();
public $tProCats = array();
public $tkCats = array();
public $tkFreeCats = array();
public $tkProCats = array();
public $countItems = array();
public $countFreeItems = array();
public $countProItems = array();
public $tkCount = array();
/*Theme*/
public $allThemeCats = array();
public $allThemeFreeCats = array();
public $allThemeProCats = array();
public $normalThemeCats = array();
public $normalThemeFreeCats = array();
public $normalThemeProCats = array();
public $gutenbergThemeCats = array();
public $gutenbergThemeFreeCats = array();
public $gutenbergThemeProCats = array();
public $fseThemeCats = array();
public $fseThemeFreeCats = array();
public $fseThemeProCats = array();
public $elementorThemeCats = array();
public $elementorThemeFreeCats = array();
public $elementorThemeProCats = array();
/**
* Main Instance
*
* Insures that only one instance of Templateberg_Template_Lists_Data exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @since 1.0.0
* @access public
*
* @return object
*/
public static function instance() {
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been ran previously
if ( null === $instance ) {
$instance = new self();
}
// Always return the instance
return $instance;
}
public function set_counts( $type, $o, $all = false ) {
if ( $all ) {
if ( ! isset( $this->countItems[ $type ]['all'] ) ) {
$this->countItems[ $type ]['all'] = 1;
} else {
++$this->countItems[ $type ]['all'];
}
} elseif ( ! isset( $this->countItems[ $type ][ $o ] ) ) {
$this->countItems[ $type ][ $o ] = 1;
} else {
++$this->countItems[ $type ][ $o ];
}
}
public function set_free_counts( $type, $o, $all = false ) {
if ( $all ) {
if ( ! isset( $this->countFreeItems[ $type ]['all-free'] ) ) {
$this->countFreeItems[ $type ]['all-free'] = 1;
} else {
++$this->countFreeItems[ $type ]['all-free'];
}
} elseif ( ! isset( $this->countFreeItems[ $type ][ $o ] ) ) {
$this->countFreeItems[ $type ][ $o ] = 1;
} else {
++$this->countFreeItems[ $type ][ $o ];
}
}
public function set_pro_counts( $type, $o, $all = false ) {
if ( $all ) {
if ( ! isset( $this->countProItems[ $type ]['all-pro'] ) ) {
$this->countProItems[ $type ]['all-pro'] = 1;
} else {
++$this->countProItems[ $type ]['all-pro'];
}
} elseif ( ! isset( $this->countProItems[ $type ][ $o ] ) ) {
$this->countProItems[ $type ][ $o ] = 1;
} else {
++$this->countProItems[ $type ][ $o ];
}
}
/**
* Run functionality with hooks
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function run( $templates_list ) {
if ( is_array( $templates_list ) ) {
foreach ( $templates_list as $list ) {
$type = $list['type'];
if ( ! isset( $this->data[ $type ] ) ) {
$this->data[ $type ] = array();
}
array_push( $this->data[ $type ], $list );
$this->set_counts( $type, '', true );
if ( isset( $list['is_pro'] ) ) {
$this->set_pro_counts( $type, '', true );
} else {
$this->set_free_counts( $type, '', true );
}
if ( isset( $list['categories'] ) ) {
if ( 'template-kits' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->tkProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->tkFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
array_push( $this->tkCats, $cat );
$this->set_counts( $type, $cat );
}
} elseif ( 'templates' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->tProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->tFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
array_push( $this->tCats, $cat );
$this->set_counts( $type, $cat );
}
} elseif ( 'blocks' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->bProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->bFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
array_push( $this->bCats, $cat );
$this->set_counts( $type, $cat );
}
}
}
/*Templates per Template kit Count*/
if ( 'templates' === $type && isset( $list['template_kit_id'] ) ) {
if ( ! isset( $this->tkCount[ $list['template_kit_id'] ] ) ) {
$this->tkCount[ $list['template_kit_id'] ] = 1;
} else {
++$this->tkCount[ $list['template_kit_id'] ];
}
}
}
}
}
/**
* Setup WordPress Themes
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function setup_themes( $themes_list ) {
$this->tab = 'all';
$this->data['all'] = array();
$this->tab = 'purchased';
$this->data['purchased'] = array();
if ( $themes_list && is_array( $themes_list ) ) {
foreach ( $themes_list as $list ) {
$type = '';
if ( isset( $list['type'] ) ) {
$type = $list['type'];
}
if ( ! $type || ! isset( $this->data[ $type ] ) ) {
$this->data[ $type ] = array();
}
array_push( $this->data[ $type ], $list );
$this->set_counts( $type, '', true );
array_push( $this->data['all'], $list );
$this->set_counts( 'all', '', true );
if ( isset( $list['is_pro'] ) ) {
$this->set_pro_counts( $type, '', true );
$this->set_pro_counts( 'all', '', true );
/*Test*/
if ( templateberg_is_current_theme_template_available( $list ) ) {
array_push( $this->data['purchased'], $list );
$this->set_counts( 'all', '', true );
}
/*Test*/
} else {
$this->set_free_counts( $type, '', true );
$this->set_free_counts( 'all', '', true );
}
if ( isset( $list['categories'] ) ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->allThemeProCats, $cat );
$this->set_pro_counts( 'all', $cat );
} else {
array_push( $this->allThemeFreeCats, $cat );
$this->set_free_counts( 'all', $cat );
}
array_push( $this->allThemeCats, $cat );
$this->set_counts( 'all', $cat );
}
if ( 'normal' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->normalThemeProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->normalThemeFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
}
array_push( $this->normalThemeCats, $cat );
$this->set_counts( $type, $cat );
} elseif ( 'gutenberg' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->gutenbergThemeProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->gutenbergThemeFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
array_push( $this->gutenbergThemeCats, $cat );
$this->set_counts( $type, $cat );
}
} elseif ( 'full-site-editing' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->fseThemeProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->fseThemeFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
array_push( $this->fseThemeCats, $cat );
$this->set_counts( $type, $cat );
}
} elseif ( 'elementor' === $type ) {
foreach ( $list['categories'] as $cat ) {
if ( isset( $list['is_pro'] ) ) {
array_push( $this->elementorThemeProCats, $cat );
$this->set_pro_counts( $type, $cat );
} else {
array_push( $this->elementorThemeFreeCats, $cat );
$this->set_free_counts( $type, $cat );
}
array_push( $this->elementorThemeCats, $cat );
$this->set_counts( $type, $cat );
}
}
}
}
}
}
public function get_type() {
if ( $_GET['type'] ) {
return $_GET['type'];
} else {
return 'block';
}
}
}
if ( ! function_exists( 'templateberg_template_lists_data' ) ) {
function templateberg_template_lists_data() {
return Templateberg_Template_Lists_Data::instance();
}
}

View File

@@ -0,0 +1,369 @@
<link rel="stylesheet" id="templateberg-dashboard-shortcode-css" href="<?php echo TEMPLATEBERG_URL . 'dist/list.css'; ?>" type="text/css" media="all">
<?php
$active = isset( $_GET['type'] ) && $_GET['type'] ? $_GET['type'] : 'current';
if ( templateberg_theme_templates()->is_selected_theme() ) {
$theme = $_GET['slug'];
} else {
$theme = get_stylesheet();
}
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/theme-buy-preview.php';
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/getting-started.php';
if ( ! templateberg_has_templates( 'current-theme', $theme ) ) {
?>
<div class="tb-connect__notice tb-text__center">
<div class="tb-connect__icon">
<img src="<?php echo TEMPLATEBERG_URL . 'assets/img/logo-48x48.png'; ?>" alt="Templateberg">
</div>
<h4 class="tb-connect__title">
<?php
esc_html_e( 'You need to click on the Refresh button below or The current theme does not have Templates on Templateberg.', 'templateberg' );
?>
</h4>
<p class="tb-connect__desc">
<?php
esc_html_e( "Templateberg power you to create site quickly and easily. You don't have to spend hours trying to create a template and block design. With a click your favourite template design will import on your site and you can change text, image and customize it for your needs.", 'templateberg' );
?>
<p class="tb-connect__gutentor">
</p>
<a href="#" class="tb-btn tb-btn__primary tb-btn__lg tb-current-themes-template-kits-refresh"><?php esc_html_e( 'Refresh', 'templateberg' ); ?></a>
<a href="#" class="tb-btn tb-btn__primary tb-btn__lg tb-list__theme_type" data-type="available"><?php esc_html_e( 'View Available Themes Template Kits', 'templateberg' ); ?></a>
</div>
<?php
return;
}
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$themes_list_popular = get_transient( 'templateberg_ct_p_' . $paged );
$themes_list = templateberg_get_current_theme_templates( $paged, $theme );
$max_pages = get_transient( 'templateberg_ct_' . $theme . '_max' );
$total_themes = get_transient( 'templateberg_ct_' . $theme . '_total' );
$purchased_items = get_transient( 'templateberg_ct_' . $theme . '_total' );
$current_theme_purchase_id = templateberg_connect()->get_current_theme_purchase_templates_id();
/**
* Create Instance for Templateberg_Template_Lists_Data
*
* @since 1.0.0
* @access public
*
* @param
*
* @return object
*/
templateberg_template_lists_data()->setup_themes( $themes_list );
$data = templateberg_template_lists_data()->data;
echo '<div class="ai-content-blocker hidden">';
echo '<div class="ai-notification-title"><p>' . esc_html__( 'Processing... Please do not refresh this page or do not go to other url!', 'templateberg' ) . '</p></div>';
echo '<div id="ai-demo-popup"></div>';
echo '</div>';
?>
<div class="tb-list__template" role="document">
<div class="tb-list__sidebar">
<div class="tb-list__search">
<input class="tb-list__searchinput" type="text" id="" placeholder="Search" value="">
<i class="fas fa-search" tabindex="-1"></i>
</div>
<div class="tb-list__categories"><h3><?php echo esc_html__( 'Categories', 'templateberg' ); ?></h3>
<div class="tb-list__categories-filter-wrap">
<ul class="tb-list__categories-wrap-tab">
<li class="tb-list__categories-tab-item tb-filter-active" data-id="all"><?php echo esc_html__( 'All', 'templateberg' ); ?></li>
<li class="tb-list__categories-tab-item" data-id="free"><?php echo esc_html__( 'Free', 'templateberg' ); ?></li>
<li class="tb-list__categories-tab-item" data-id="pro"><?php echo esc_html__( 'Pro', 'templateberg' ); ?></li>
</ul>
</div>
<ul class="tb-list__cat_lists tb-cat-lists-all tb-cats-content-active">
<?php
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countItems;
if ( isset( $count_items['all'] ) ) {
$current_tab_cats = $count_items['all'];
}
if ( ! empty( $current_tab_cats ) ) {
foreach ( $current_tab_cats as $cat => $count ) {
if ( $cat === 'all' ) {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html__( 'All Items', 'templateberg' ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
} else {
?>
<li class="">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html( ucwords( str_replace( '-', ' ', $cat ) ) ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
}
}
}
?>
</ul>
<ul class="tb-list__cat_lists tb-cat-lists-free">
<?php
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countFreeItems;
if ( isset( $count_items['all'] ) ) {
$current_tab_cats = $count_items['all'];
}
if ( ! empty( $current_tab_cats ) ) {
foreach ( $current_tab_cats as $cat => $count ) {
if ( $cat === 'all-free' ) {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html__( 'All Items', 'templateberg' ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
} else {
?>
<li class="">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html( ucwords( str_replace( '-', ' ', $cat ) ) ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
}
}
}
?>
</ul>
<ul class="tb-list__cat_lists tb-cat-lists-pro">
<?php
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countProItems;
if ( isset( $count_items['all'] ) ) {
$current_tab_cats = $count_items['all'];
}
if ( ! empty( $current_tab_cats ) ) {
foreach ( $current_tab_cats as $cat => $count ) {
if ( $cat === 'all-pro' ) {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html__( 'All Items', 'templateberg' ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
} else {
?>
<li class="">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html( ucwords( str_replace( '-', ' ', $cat ) ) ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
}
}
}
?>
</ul>
</div>
</div>
<div class="tb-list__container">
<div>
<span class="tb-list__btn"><i class="fas fa-bars"></i></span>
</div>
<div class="tb-list__header">
<div class="tb-list__links">
<a href="#" class="tb-list__cat_btn" data-type="purchased">
<i class="fas fa-history"></i>
<?php echo esc_html__( 'Purchased', 'templateberg' ); ?>
</a>
<a href="#" class="tb-list__cat_btn is-selected" data-type="all">
<i class="fas fa-images"></i>
<?php echo esc_html__( 'All', 'templateberg' ); ?>
</a>
<?php
$current_tab_data = $data['all'];
if ( isset( $data['normal'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="normal">
<i class="fas fa-images"></i>
<?php echo esc_html__( 'Normal', 'templateberg' ); ?>
</a>
<?php
}
if ( isset( $data['gutenberg'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="gutenberg">
<i class="far fa-file"></i>
<?php echo esc_html__( 'Gutenberg', 'templateberg' ); ?>
</a>
<?php
}
if ( isset( $data['full-site-editing'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="full-site-editing">
<i class="fas fa-th-large"></i>
<?php echo esc_html__( 'Full Site Editing', 'templateberg' ); ?>
</a>
<?php
}
if ( isset( $data['elementor'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="elementor">
<i class="fas fa-th-large"></i>
<?php echo esc_html__( 'Elementor', 'templateberg' ); ?>
</a>
<?php
}
?>
</div>
<div class="tb-list__actions">
<div class="tb-list__sorting">
<label for="tb-list__sorting_select"><?php echo esc_html__( 'Sort by', 'templateberg' ); ?> :</label>
<select name="tb-list__sorting" id="tb-list__sorting_select">
<option value="newest" selected><?php echo esc_html__( 'Newest Items', 'templateberg' ); ?></option>
<option value="popularity"><?php echo esc_html__( 'Popular Items', 'templateberg' ); ?></option>
</select>
</div>
<!--Added-->
<div class="tb-current-themes-template-kits-refresh">
<span class="dashicon dashicons dashicons-image-rotate"></span>
</div>
</div>
</div>
<div class="tb-list__content">
<?php
if ( ! empty( $current_tab_data ) ) {
foreach ( $current_tab_data as $item ) {
?>
<div aria-label="<?php echo esc_attr( $item['title'] ); ?>"
class="tb-list__item tb-list__active_theme" data-id="<?php echo esc_attr( $item['id'] ); ?>"
data-type="<?php echo isset( $item['type'] ) ? esc_attr( $item['type'] ) : ''; ?>">
<div class="tb-list__item_preview">
<img src="<?php echo esc_url( $item['screenshot_url'] ); ?>" loading="lazy" alt="<?php echo esc_attr( $item['title'] ); ?>" />
<span class="tb-list__author"><i class="fas fa-user"></i>
<?php
echo esc_html__( 'By : ', 'templateberg' ) .
esc_html( ucwords( $item['author'] ) );
?>
</span>
</div>
<div class="tb-list__item_footer">
<div class="tb-list__item_price">
<?php
$tb_download_price = (int) $item['price'];
?>
<span>
<?php
if ( $tb_download_price > 0 ) :
echo wp_kses_post( $item['price_with_symbol'] );
else :
echo esc_html__( 'Free', 'templateberg' );
endif;
?>
</span>
</div>
<div class="tb-list__item_meta">
<h4>
<a class="tb-list__item_title_link" href="<?php echo esc_url( $item['permalink'] ); ?>" target="_blank" rel="noopener">
<?php echo esc_attr( $item['title'] ); ?>
</a>
</h4>
<?php
if ( isset( $item['theme'] ) ) {
?>
<span class="tb-list__item-theme">
<span class="tb-list__item-theme--link" data-theme_slug="<?php echo esc_attr( $item['theme']['slug'] ); ?>" ><span class="dashicons dashicons-saved"></span><?php echo esc_attr( $item['theme']['name'] ); ?></span>
</span>
<?php
}
?>
</div>
<div class="tb-list__item_actions">
<a class="tb-item__preview_link" href="<?php echo esc_url( $item['demo_url'] ); ?>" target="_blank"><?php echo esc_html__( 'Preview', 'templateberg' ); ?></a>
<?php
if ( templateberg_is_current_theme_template_available( $item ) ) {
?>
<a class="tb-list__item_btn tb-list__item_buy_btn"
data-id="<?php echo esc_attr( $item['id'] ); ?>"
data-is_pro="<?php echo esc_attr( ( $tb_download_price > 0 ) ? 'pro' : 'free' ); ?>"
data-is_available="yes"
data-theme_name="<?php echo esc_attr( $item['theme']['name'] ); ?>"
data-theme_slug="<?php echo esc_attr( $item['theme']['slug'] ); ?>"
href="<?php echo esc_url( $item['permalink'] ); ?>" target="_blank"
rel="noopener"
>
<?php
echo esc_html__( 'Import', 'templateberg' );
?>
</a>
<?php
} else {
?>
<a class="tb-list__item_btn tb-list__item_buy_btn"
data-id="<?php echo esc_attr( $item['id'] ); ?>"
data-is_pro="<?php echo esc_attr( ( $tb_download_price > 0 ) ? 'pro' : 'free' ); ?>"
data-is_available="no"
data-theme_name="<?php echo esc_attr( $item['theme']['name'] ); ?>"
data-theme_slug="<?php echo esc_attr( $item['theme']['slug'] ); ?>"
href="<?php echo esc_url( $item['permalink'] ); ?>"
target="_blank"
rel="noopener"
>
<?php
echo esc_html__( 'Purchase', 'templateberg' );
?>
</a>
<?php
}
?>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<?php
echo templateberg_pagination( $paged, $max_pages );
?>
</div>
</div>
<?php
// Scripts.
wp_enqueue_script(
'templateberg-current-theme', // Handle.
TEMPLATEBERG_URL . 'dist/current.min.js', // Block.build.js: We register the block here. Built with Webpack.
array( 'jquery' ), // Dependencies, defined above.
TEMPLATEBERG_VERSION, // Version: File modification time.
true // Enqueue the script in the footer.
);
wp_localize_script(
'templateberg-current-theme',
'templateberg_current_theme',
array(
'restNonce' => wp_create_nonce( 'wp_rest' ),
'restUrl' => esc_url_raw( rest_url() ),
'purchasesIds' => $current_theme_purchase_id,
'popularThemes' => $themes_list_popular,
'allThemes' => $themes_list,
'text' => array(
'import' => esc_html__( 'Import', 'templateberg' ),
'purchase' => esc_html__( 'Purchase', 'templateberg' ),
'preview' => esc_html__( 'Preview', 'templateberg' ),
'noItem' => esc_html__( 'No item on selected categories!', 'templateberg' ),
'allItems' => esc_html__( 'All Items', 'templateberg' ),
'by' => esc_html__( 'By', 'templateberg' ),
'templates' => esc_html__( 'Templates', 'templateberg' ),
),
)
);

View File

@@ -0,0 +1,35 @@
<div class="tb-theme-popup" style="display: none">
<div class="tb-theme-popup__wrap">
<div class="tb-theme-popup__close">
<span class="dashicon dashicons dashicons-no-alt"></span>
</div>
<div class="tb-theme-popup__body">
<div class="tb-connect__notice tb-text__center">
<div class="tb-connect__icon">
<img
src='<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/logo-48x48.png');?>'
alt="<?php esc_attr_e('Templateberg', 'templateberg');?>"
/>
</div>
<h3 class="tb-connect__title">
<?php esc_html_e('Get access to hundreds of free templates by creating free account.', 'templateberg')?>
</h3>
<p class="tb-connect__desc">
<?php
esc_html_e("Templateberg power you to create site quickly and easily. You don't have to spend hours trying to create a template and block design. With a click your favourite template design will import on your site and you can change text, image and customize it for your needs.", 'templateberg');
esc_html_e("Clicking the button below will install and activate the Gutentor Plugin since most of the templates are built with it.", 'templateberg');
?>
</p>
<a id="tb-connect-btn"
href='<?php echo esc_url(templateberg_connect()->get_remote_connect_url());?>'
target="_blank"
class="tb-btn tb-btn__primary tb-btn__lg">
<?php
esc_html_e('Get Started With Templateberg', 'templateberg')
?>
</a>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,131 @@
<!--Loading HTML-->
<div id="tb-list__popup_loader" class="tb-modal__overlay" style="display:none;">
<div class="tb-preview__main_loader">
<div class="tb-preview__main_loading">
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
</div>
</div>
<!--purchase button-->
</div>
<!--Buy now Popup-->
<div id="tb-list__item_buy_popup" class="tb-modal__overlay" style="display:none;">
<div class="tb-preview__main_loader">
<div class="tb-preview__main_loading">
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
</div>
</div>
<!--purchase button-->
</div>
<!--Preview-->
<div id="tb-list__item_preview" class="tb-preview__wrapper" style="display: none">
<div class="tb-preview__sidebar">
<div class="tb-preview__header">
<div class="tb-preview__actions">
<button type="button" class="tb-preview__close">
</button>
<button type="button" class="tb-preview__prev">
</button>
<button type="button" class="tb-preview__next">
</button>
</div>
</div>
<div class="tb-preview__sidebar-content">
<h4><?php echo esc_html__('Click', 'templateberg'); ?></h4>
<div class="tb-preview__thumb">
<img>
</div>
<div class="tb-preview__author">
<i class="fas fa-user"></i>
<?php echo esc_html__('By :', 'templateberg'); ?><span><?php echo esc_html__('Gutentor', 'templateberg'); ?></span>
</div>
<button type="button" tabindex="0" class="tb-list__item_btn tb-list__item_buy_btn" data-id="<?php echo esc_attr(get_the_ID())?>" data-is_pro="free">
</button>
</div>
<div class="tb-preview__footer">
<button type="button" class="tb-preview__collapse-btn">
<span class="tb-preview__collapse-arrow"></span>
<span class="tb-preview__collapse-label"><?php echo esc_html__('Hide Controls', 'templateberg'); ?></span>
</button>
<div class="tb-preview__devices-wrapper">
<div class="tb-preview__devices">
<button type="button" class="tb-preview__desktop active" aria-pressed="true" data-device="desktop">
<span class="screen-reader-text"><?php echo esc_html__('Enter desktop preview mode', 'templateberg'); ?></span>
</button>
<button type="button" class="tb-preview__tablet" aria-pressed="false" data-device="tablet">
<span class="screen-reader-text"><?php echo esc_html__('Enter tablet preview mode', 'templateberg'); ?></span>
</button>
<button type="button" class="tb-preview__mobile" aria-pressed="false" data-device="mobile">
<span class="screen-reader-text"><?php echo esc_html__('Enter mobile preview mode', 'templateberg'); ?></span>
</button>
</div>
</div>
</div>
</div>
<div class="tb-preview__main">
<div class="tb-preview__main_loader">
<div class="tb-preview__main_loading">
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
</div>
</div>
<iframe id="tb-preview__frame" title="<?php esc_attr_e('Preview', 'templateberg'); ?>"></iframe>
</div>
</div>
<!--Free Information-->
<div id="tb-list__item_free_popup" class="tb-modal__overlay" style="display: none">
<div class="tb-modal">
<div class="tb-modal__header">
<h3 class="tb-modal__title"><?php esc_html_e('Free Design Templates', 'templateberg');?></h3>
<a href="#" class="tb-modal__cancel">
<!-- <i class="fas fa-times"></i> -->
<span class="dashicons dashicons-no-alt"></span>
</a>
</div>
<div class="tb-modal__content-wrap">
<section class="tb-modal__content">
<div class="tb-modal__content-info">
<h2 class="tb-modal__content-h"><?php esc_html_e('1. Getting Started ( Free License )', 'templateberg');?></h2>
<p class="tb-modal__content-p"><?php printf(esc_html__('Once you install the plugin. Go to %1$sDashboard =&gt; Templateberg.%2$s', 'templateberg'), "<strong>", '</strong>')?></p>
<p class="tb-modal__content-p"><?php printf(esc_html__('Click on %1$sGet Started with Templateberg.%2$s', 'templateberg'), "<strong>", '</strong>')?></p>
<p class="tb-modal__content-p"><?php esc_html_e('A new window will open follow the step to automatically setup license key on your site.', 'templateberg');?></p>
</div>
<div class="tb-modal__content-img-wrap">
<img class="" src="https://templateberg.com/wp-content/uploads/2021/02/getstarted.png">
</div>
</section>
<section class="tb-modal__content">
<div class="tb-modal__content-img-wrap">
<img class="" src="https://templateberg.com/wp-content/uploads/2021/02/import.png">
</div>
<div class="tb-modal__content-info">
<h2 class="tb-modal__content-h"><?php esc_html_e('2. Import', 'templateberg');?></h2>
<p class="tb-modal__content-p">
<?php printf(esc_html__(' Edit any Gutenberg Enabled Page or Post. %1$sYou will see %2$sTemplateberg%3$s button at the top left of the editor.', 'templateberg'), "<br><br>", '<strong>', '</strong>')?>
<p class="tb-modal__content-p">
<?php esc_html_e('Click on it, you are ready to inset any available template kits, templates and blocks', 'templateberg');?>
</p>
</div>
</section>
<section class="tb-modal__content">
<div class="tb-modal__content-info">
<h2 class="tb-modal__content-h"><?php esc_html_e('3. Customizing', 'templateberg');?></h2>
<p class="tb-modal__content-p">
<?php esc_html_e('After importing design, you can customize content and design to meet your site requirements.', 'templateberg');?>
</p>
</div>
<div class="tb-modal__content-img-wrap">
<img class="" src="https://templateberg.com/wp-content/uploads/2021/02/customization.png">
</div>
</section>
</div>
</div>
</div>

View File

@@ -0,0 +1,257 @@
<?php
$paged = get_query_var('paged')?get_query_var('paged'):1;
$templates_list = templateberg_get_gutenberg_templates($paged);
$templates_list_popular = get_transient('templateberg_gt_p_'.$paged);
$total_posts = get_transient('templateberg_gt_total');
$max_pages = get_transient('templateberg_gt_max');
/**
* Create Instance for Templateberg_Template_Lists_Data
*
* @since 1.0.0
* @access public
*
* @param
*
* @return object
*/
templateberg_template_lists_data()->run($templates_list);
$data = templateberg_template_lists_data()->data;
?>
<link rel="stylesheet" id="templateberg-dashboard-shortcode-css" href="<?php echo TEMPLATEBERG_URL . 'dist/list.css' ?>" type="text/css" media="all">
<div class="tb-list__template" role="document">
<div class="tb-list__sidebar">
<div class="tb-list__search">
<input class="tb-list__searchinput" type="text" id="" placeholder="Search" value="">
<i class="fas fa-search" tabindex="-1"></i>
</div>
<div class="tb-list__categories"><h3><?php echo esc_html__('Categories', 'templateberg'); ?></h3>
<div class="tb-list__categories-filter-wrap">
<ul class="tb-list__categories-wrap-tab">
<li class="tb-list__categories-tab-item tb-filter-active" data-id="all"><?php echo esc_html__('All', 'templateberg'); ?></li>
<li class="tb-list__categories-tab-item" data-id="free"><?php echo esc_html__('Free', 'templateberg'); ?></li>
<li class="tb-list__categories-tab-item" data-id="pro"><?php echo esc_html__('Pro', 'templateberg'); ?></li>
</ul>
</div>
<ul class="tb-list__cat_lists tb-cat-lists-all tb-cats-content-active">
<?php
$current_tab = '';
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countItems;
if (isset($data['template-kits'])) {
$current_tab ='template-kits';
$current_tab_cats =$count_items['template-kits'];
} elseif (isset($data['templates'])) {
$current_tab ='templates';
$current_tab_cats =$count_items['templates'];
} elseif (isset($data['blocks'])) {
$current_tab ='blocks';
$current_tab_cats =$count_items['blocks'];
}
if (!empty($current_tab_cats)) {
foreach ($current_tab_cats as $cat => $count) {
if ($cat === 'all') {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr($cat);?>"><?php echo esc_html__('All Items', 'templateberg'); ?><span><?php echo $count;?></span></a>
</li>
<?php
} else {
?>
<li class=""><a href="#" data-cat="<?php echo esc_attr($cat);?>"><?php echo esc_html(ucwords(str_replace("-", " ", $cat)));?><span><?php echo $count;?></span></a></li>
<?php
}
}
}
?>
</ul>
<ul class="tb-list__cat_lists tb-cat-lists-free">
<?php
$count_items = templateberg_template_lists_data()->countFreeItems;
if (!empty($current_tab_cats)) {
foreach ($current_tab_cats as $cat => $count) {
if ($cat === 'all-free') {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr($cat);?>"><?php echo esc_html__('All Items', 'templateberg'); ?><span><?php echo $count;?></span></a>
</li>
<?php
} else {
?>
<li class=""><a href="#" data-cat="<?php echo esc_attr($cat);?>"><?php echo esc_html(ucwords(str_replace("-", " ", $cat)));?><span><?php echo $count;?></span></a></li>
<?php
}
}
}
?>
</ul>
<ul class="tb-list__cat_lists tb-cat-lists-pro">
<?php
$count_items = templateberg_template_lists_data()->countProItems;
if (!empty($current_tab_cats)) {
foreach ($current_tab_cats as $cat => $count) {
if ($cat === 'all-pro') {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr($cat);?>"><?php echo esc_html__('All Items', 'templateberg'); ?><span><?php echo $count;?></span></a>
</li>
<?php
} else {
?>
<li class=""><a href="#" data-cat="<?php echo esc_attr($cat);?>"><?php echo esc_html(ucwords(str_replace("-", " ", $cat)));?><span><?php echo $count;?></span></a></li>
<?php
}
}
}
?>
</ul>
</div>
</div>
<div class="tb-list__container">
<div>
<span class="tb-list__btn"><i class="fas fa-bars"></i></span>
</div>
<div class="tb-list__header">
<div class="tb-list__links">
<?php
$current_tab_data = array();
if (isset($data['template-kits'])) {
if (empty($current_tab_data)) {
$current_tab_data = $data['template-kits'];
}
?>
<a href="#" class="tb-list__cat_btn <?php echo $current_tab ==='template-kits'?'is-selected':'';?>" data-type="template-kits">
<i class="fas fa-images"></i>
<?php echo esc_html__('Template Kits', 'templateberg'); ?>
</a>
<?php
}
if (isset($data['templates'])) {
if (empty($current_tab_data)) {
$current_tab_data = $data['templates'];
}
?>
<a href="#" class="tb-list__cat_btn <?php echo $current_tab ==='templates'?'is-selected':'';?>" data-type="templates">
<i class="far fa-file"></i>
<?php echo esc_html__('Templates', 'templateberg'); ?>
</a>
<?php
}
if (isset($data['blocks'])) {
if (empty($current_tab_data)) {
$current_tab_data = $data['blocks'];
}
?>
<a href="#" class="tb-list__cat_btn <?php echo $current_tab ==='blocks'?'is-selected':'';?>" data-type="blocks">
<i class="fas fa-th-large"></i>
<?php echo esc_html__('Blocks', 'templateberg'); ?>
</a>
<?php
}
?>
</div>
<div class="tb-list__actions">
<div class="tb-list__sorting">
<label for="tb-list__sorting_select"><?php echo esc_html__('Sort by:', 'templateberg'); ?></label>
<select name="tb-list__sorting" id="tb-list__sorting_select">
<option value="newest" selected><?php echo esc_html__('Newest Items', 'templateberg'); ?></option>
<option value="popularity"><?php echo esc_html__('Popular Items', 'templateberg'); ?></option>
</select>
</div>
<!--Added-->
<div class="tb-gutenberg-templates-refresh">
<span class="dashicon dashicons dashicons-image-rotate"></span>
</div>
</div>
</div>
<div class="tb-list__content">
<?php
if (!empty($current_tab_data)) {
foreach ($current_tab_data as $item) {
?>
<div aria-label="<?php echo esc_attr($item['title'])?>" class="tb-list__item" data-id="<?php echo esc_attr($item['id'])?>" data-type="<?php echo esc_attr($item['type']);?>">
<div class="tb-list__item_preview">
<img src="<?php echo esc_url($item['screenshot_url']);?>" loading="lazy">
<span class="tb-list__author"><i class="fas fa-user"></i>
<?php echo esc_html__('By : ', 'templateberg').esc_html(ucwords($item['author'])); ?>
</span>
</div>
<div class="tb-list__item_footer">
<div class="tb-list__item_price">
<?php $tb_download_price = (int) $item['price']; ?>
<span>
<?php
if ($tb_download_price > 0) :
echo wp_kses_post($item['price_with_symbol']);
else :
echo esc_html__('Free', 'templateberg');
endif;
?>
</span>
</div>
<div class="tb-list__item_meta">
<h4>
<a class="tb-list__item_title_link" href="<?php echo esc_url($item['permalink'])?>" target="_blank" rel="noopener">
<?php echo esc_attr($item['title'])?>
</a>
</h4>
<?php
if (isset($item['templates']) && is_array($item['templates']) && count($item['templates'])) {
echo '<span class="tb-list__item-tk-count">'.count($item['templates']).' Templates</span>';
}
?>
</div>
<div class="tb-list__item_actions">
<a class="tb-item__preview_link" href="<?php echo esc_url($item['demo_url']);?>" target="_blank"><?php echo esc_html__('Preview', 'templateberg'); ?></a>
<a class="tb-list__item_btn tb-list__item_buy_btn" data-id="<?php echo esc_attr($item['id'])?>" data-is_pro="<?php echo esc_attr(( $tb_download_price > 0 ) ? 'pro' : 'free'); ?>" href="<?php echo esc_url($item['permalink'])?>" target="_blank" rel="noopener">
<?php if ($tb_download_price > 0) :
echo esc_html__('Purchase', 'templateberg');
else :
echo esc_html__('Get It Free', 'templateberg');
endif;
?>
</a>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<?php
echo templateberg_pagination($paged, $max_pages);
?>
</div>
</div>
<?php
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/gutenberg-buy-preview.php';
// Scripts.
wp_enqueue_script(
'templateberg-gutenberg', // Handle.
TEMPLATEBERG_URL . 'dist/gutenberg.min.js', // Block.build.js: We register the block here. Built with Webpack.
array( 'jquery' ), // Dependencies, defined above.
TEMPLATEBERG_VERSION, // Version: File modification time.
true // Enqueue the script in the footer.
);
wp_localize_script(
'templateberg-gutenberg',
'templateberg_gutenberg',
array(
'restNonce' => wp_create_nonce('wp_rest'),
'restUrl' => esc_url_raw(rest_url()),
'currentTab' => $current_tab,
'popularList' => $templates_list_popular,
'normalList' => $templates_list,
'text' => array(
'preview' => esc_html__('Preview', 'templateberg'),
'purchase' => esc_html__('Purchase', 'templateberg'),
'noItem' => esc_html__('No item on selected categories!', 'templateberg'),
'allItems' => esc_html__('All Items', 'templateberg'),
'by' => esc_html__('By', 'templateberg'),
'templates' => esc_html__('Templates', 'templateberg'),
),
)
);

View File

@@ -0,0 +1,161 @@
<!--Loading HTML-->
<div id="tb-list__popup_loader" class="tb-modal__overlay" style="display:none;">
<div class="tb-preview__main_loader">
<div class="tb-preview__main_loading">
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
</div>
</div>
<!--purchase button-->
</div>
<!--Buy now Popup-->
<div id="tb-list__item_buy_popup" class="tb-modal__overlay" style="display:none;">
<div class="tb-preview__main_loader">
<div class="tb-preview__main_loading">
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
</div>
</div>
<!--purchase button-->
</div>
<!--Preview-->
<div id="tb-list__item_preview" class="tb-preview__wrapper" style="display: none">
<div class="tb-preview__sidebar">
<div class="tb-preview__header">
<div class="tb-preview__actions">
<button type="button" class="tb-preview__close">
</button>
<button type="button" class="tb-preview__prev">
</button>
<button type="button" class="tb-preview__next">
</button>
</div>
</div>
<div class="tb-preview__sidebar-content">
<h4><?php echo esc_html__('Click', 'templateberg'); ?></h4>
<div class="tb-preview__thumb">
<img>
</div>
<div class="tb-preview__author">
<i class="fas fa-user"></i>
<?php echo esc_html__('By :', 'templateberg'); ?><span><?php echo esc_html__('Gutentor', 'templateberg'); ?></span>
</div>
<button type="button" tabindex="0" class="tb-list__item_btn tb-list__item_buy_btn" data-id="<?php echo esc_attr(get_the_ID())?>" data-is_pro="free">
</button>
</div>
<div class="tb-preview__footer">
<button type="button" class="tb-preview__collapse-btn">
<span class="tb-preview__collapse-arrow"></span>
<span class="tb-preview__collapse-label"><?php echo esc_html__('Hide Controls', 'templateberg'); ?></span>
</button>
<div class="tb-preview__devices-wrapper">
<div class="tb-preview__devices">
<button type="button" class="tb-preview__desktop active" aria-pressed="true" data-device="desktop">
<span class="screen-reader-text"><?php echo esc_html__('Enter desktop preview mode', 'templateberg'); ?></span>
</button>
<button type="button" class="tb-preview__tablet" aria-pressed="false" data-device="tablet">
<span class="screen-reader-text"><?php echo esc_html__('Enter tablet preview mode', 'templateberg'); ?></span>
</button>
<button type="button" class="tb-preview__mobile" aria-pressed="false" data-device="mobile">
<span class="screen-reader-text"><?php echo esc_html__('Enter mobile preview mode', 'templateberg'); ?></span>
</button>
</div>
</div>
</div>
</div>
<div class="tb-preview__main">
<div class="tb-preview__main_loader">
<div class="tb-preview__main_loading">
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
<div class="tb-preview__lines"></div>
</div>
</div>
<iframe id="tb-preview__frame" title="<?php esc_attr_e('Preview', 'templateberg'); ?>"></iframe>
</div>
</div>
<!--Free Information-->
<div id="tb-list__item_free_popup" class="tb-modal__overlay" style="display: none">
<div class="tb-modal">
<div class="tb-modal__header">
<h3 class="tb-modal__title"><?php esc_html_e('First Install Theme and After Import Demo', 'templateberg');?></h3>
<a href="#" class="tb-modal__cancel">
<span class="dashicons dashicons-no-alt"></span>
</a>
</div>
<div class="tb-modal__content-wrap">
<section class="tb-modal__content">
<div class="tb-modal__content-info">
<h2 class="tb-modal__content-h">
<?php printf(esc_html__('1. First Install and Activate %1$s %2$s Theme', 'templateberg'), "<a href='".admin_url('theme-install.php?search=')."' target='_blank' class='tb-modal__theme_install_link'>", '</a>')?>
</h2>
<p class="tb-modal__content-p">
<?php printf(esc_html__('Another theme is activated currently, to install this template kit first you need to install %1$s %2$s Theme', 'templateberg'), "<a href='".admin_url('theme-install.php?search=')."' target='_blank' class='tb-modal__theme_install_link'>", '</a>')?>
</p>
<p class="tb-modal__content-p">
<?php esc_html_e('Please install and activate the Theme.', 'templateberg');?>
</p>
</div>
<div class="tb-modal__content-img-wrap">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/theme-install.png');?>" alt="<?php esc_attr_e('Templateberg', 'templateberg');?>">
</div>
</section>
<section class="tb-modal__content">
<div class="tb-modal__content-img-wrap">
<img src="<?php echo esc_url(TEMPLATEBERG_URL . 'assets/img/theme-template-kits.png');?>" alt="<?php esc_attr_e('Templateberg', 'templateberg');?>">
</div>
<div class="tb-modal__content-info">
<h2 class="tb-modal__content-h">
<?php printf(esc_html__('2. Come back to %1$s Templateberg Themes Template Kits %2$s', 'templateberg'), "<a href='".admin_url('admin.php?page='.templateberg_theme_templates()->get_slug())."' class='tb-modal__comeback_link'>", '</a>')?>
</h2>
<p class="tb-modal__content-p">
<?php esc_html_e('After installing and activating the required theme, come back to Templateberg Themes Template Kits.', 'templateberg');?>
</p>
<p class="tb-modal__content-p">
<?php esc_html_e('And Install the template kit.', 'templateberg');?>
</p>
</div>
</section>
</div>
</div>
</div>
<div class="tb-notice" style="display: none">
<div class="tb-notice-links">
<div class="tb-notice-events">
<div class="tb-notice-info">
<p></p>
</div>
<div class="tb-notice-events-btn">
<a class="tb-event-sure" href="#" target="_blank">
<span class="dashicons dashicons-thumbs-up"></span>
<?php esc_html_e('Sure', 'templateberg');?>
</a>
<button type="button" class="tb-event-may-be-later">
<span class="dashicons dashicons-calendar"></span>
<?php esc_html_e('Maybe Later', 'templateberg');?>
</button>
</div>
<div class="tb-notice-events-btn">
<a class="tb-event-purchase" href="https://templateberg.com/dashboard/?action=purchases" target="_blank">
<span class="dashicons dashicons-admin-users"></span>
<?php esc_html_e('Purchases', 'templateberg');?>
</a>
<a class="tb-event-support" href="https://templateberg.com/dashboard/?action=support" target="_blank">
<span class="dashicons dashicons-editor-help"></span>
<?php esc_html_e('Contact Support', 'templateberg');?>
</a>
</div>
</div>
<button type="button" aria-label="<?php esc_attr_e('Close settings', 'templateberg');?>" class="tb-notice-close">
<span class="dashicon dashicons dashicons-no-alt"></span>
</button>
</div>
</div>

View File

@@ -0,0 +1,316 @@
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$themes_list = templateberg_get_theme_templates( $paged );
$themes_list_popular = get_transient( 'templateberg_tt_p_' . $paged );
$total_themes = get_transient( 'templateberg_tt_total' );
$max_pages = get_transient( 'templateberg_tt_max' );
/**
* Create Instance for Templateberg_Template_Lists_Data
*
* @since 1.0.0
* @access public
*
* @param
*
* @return object
*/
templateberg_template_lists_data()->setup_themes( $themes_list );
$data = templateberg_template_lists_data()->data;
$current_theme = get_stylesheet();
?>
<link rel="stylesheet" id="templateberg-dashboard-shortcode-css" href="<?php echo TEMPLATEBERG_URL . 'dist/list.css'; ?>" type="text/css" media="all">
<div class="tb-list__template" role="document">
<div class="tb-list__sidebar">
<div class="tb-list__search">
<input class="tb-list__searchinput" type="text" id="" placeholder="<?php esc_attr_e( 'Search', 'templateberg' ); ?>" value="">
<i class="fas fa-search" tabindex="-1"></i>
</div>
<div class="tb-list__categories"><h3><?php echo esc_html__( 'Categories', 'templateberg' ); ?></h3>
<div class="tb-list__categories-filter-wrap">
<ul class="tb-list__categories-wrap-tab">
<li class="tb-list__categories-tab-item tb-filter-active" data-id="all"><?php echo esc_html__( 'All', 'templateberg' ); ?></li>
<li class="tb-list__categories-tab-item" data-id="free"><?php echo esc_html__( 'Free', 'templateberg' ); ?></li>
<li class="tb-list__categories-tab-item" data-id="pro"><?php echo esc_html__( 'Pro', 'templateberg' ); ?></li>
</ul>
</div>
<ul class="tb-list__cat_lists tb-cat-lists-all tb-cats-content-active">
<?php
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countItems;
if ( isset( $count_items['all'] ) ) {
$current_tab_cats = $count_items['all'];
}
if ( ! empty( $current_tab_cats ) ) {
foreach ( $current_tab_cats as $cat => $count ) {
if ( $cat === 'all' ) {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html__( 'All Items', 'templateberg' ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
} else {
?>
<li class="">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html( ucwords( str_replace( '-', ' ', $cat ) ) ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
}
}
}
?>
</ul>
<ul class="tb-list__cat_lists tb-cat-lists-free">
<?php
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countFreeItems;
if ( isset( $count_items['all'] ) ) {
$current_tab_cats = $count_items['all'];
}
if ( ! empty( $current_tab_cats ) ) {
foreach ( $current_tab_cats as $cat => $count ) {
if ( $cat === 'all-free' ) {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html__( 'All Items', 'templateberg' ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
} else {
?>
<li class="">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html( ucwords( str_replace( '-', ' ', $cat ) ) ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
}
}
}
?>
</ul>
<ul class="tb-list__cat_lists tb-cat-lists-pro">
<?php
$current_tab_cats = array();
$count_items = templateberg_template_lists_data()->countProItems;
if ( isset( $count_items['all'] ) ) {
$current_tab_cats = $count_items['all'];
}
if ( ! empty( $current_tab_cats ) ) {
foreach ( $current_tab_cats as $cat => $count ) {
if ( $cat === 'all-pro' ) {
?>
<li class="tb-list__current_item">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html__( 'All Items', 'templateberg' ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
} else {
?>
<li class="">
<a href="#" data-cat="<?php echo esc_attr( $cat ); ?>">
<?php echo esc_html( ucwords( str_replace( '-', ' ', $cat ) ) ); ?>
<span><?php echo $count; ?></span>
</a>
</li>
<?php
}
}
}
?>
</ul>
</div>
</div>
<div class="tb-list__container">
<div>
<span class="tb-list__btn"><i class="fas fa-bars"></i></span>
</div>
<div class="tb-list__header">
<div class="tb-list__links">
<a href="#" class="tb-list__cat_btn is-selected" data-type="all">
<i class="fas fa-images"></i>
<?php echo esc_html__( 'All', 'templateberg' ); ?>
</a>
<?php
$current_tab_data = $data['all'];
if ( isset( $data['normal'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="normal">
<i class="fas fa-images"></i>
<?php echo esc_html__( 'Normal', 'templateberg' ); ?>
</a>
<?php
}
if ( isset( $data['gutenberg'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="gutenberg">
<i class="far fa-file"></i>
<?php echo esc_html__( 'Gutenberg', 'templateberg' ); ?>
</a>
<?php
}
if ( isset( $data['full-site-editing'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="full-site-editing">
<i class="fas fa-th-large"></i>
<?php echo esc_html__( 'Full Site Editing', 'templateberg' ); ?>
</a>
<?php
}
if ( isset( $data['elementor'] ) ) {
?>
<a href="#" class="tb-list__cat_btn" data-type="elementor">
<i class="fas fa-th-large"></i>
<?php echo esc_html__( 'Elementor', 'templateberg' ); ?>
</a>
<?php
}
?>
</div>
<div class="tb-list__actions">
<div class="tb-list__sorting">
<label for="tb-list__sorting_select"><?php echo esc_html__( 'Sort by :', 'templateberg' ); ?></label>
<select name="tb-list__sorting" id="tb-list__sorting_select">
<option value="newest" selected><?php echo esc_html__( 'Newest Items', 'templateberg' ); ?></option>
<option value="popularity"><?php echo esc_html__( 'Popular Items', 'templateberg' ); ?></option>
</select>
</div>
<!--Added-->
<div class="tb-themes-template-kits-refresh">
<span class="dashicon dashicons dashicons-image-rotate"></span>
</div>
</div>
</div>
<div class="tb-list__content">
<?php
if ( ! empty( $current_tab_data ) ) {
foreach ( $current_tab_data as $item ) {
?>
<div aria-label="<?php echo esc_attr( $item['title'] ); ?>"
class="tb-list__item <?php echo isset( $item['theme'] ) && $item['theme']['slug'] === $current_theme ? 'tb-list__active_theme' : ''; ?>"
data-id="<?php echo esc_attr( $item['id'] ); ?>"
data-type="<?php echo isset( $item['type'] ) ? esc_attr( $item['type'] ) : ''; ?>"
>
<div class="tb-list__item_preview">
<img src="<?php echo esc_url( $item['screenshot_url'] ); ?>" loading="lazy" alt="<?php echo esc_attr( $item['title'] ); ?>">
<span class="tb-list__author">
<i class="fas fa-user"></i>
<?php
echo esc_html__( 'By : ', 'templateberg' ) . esc_html( ucwords( $item['author'] ) );
?>
</span>
</div>
<div class="tb-list__item_footer">
<div class="tb-list__item_price">
<?php $tb_download_price = (int) $item['price']; ?>
<span>
<?php
if ( $tb_download_price > 0 ) :
echo wp_kses_post( $item['price_with_symbol'] );
else :
echo esc_html__( 'Free', 'templateberg' );
endif;
?>
</span>
</div>
<div class="tb-list__item_meta">
<h4>
<a class="tb-list__item_title_link" href="<?php echo esc_url( $item['permalink'] ); ?>" target="_blank" rel="noopener">
<?php echo esc_attr( $item['title'] ); ?>
</a>
</h4>
<?php
if ( isset( $item['theme'] ) ) {
?>
<span class="tb-list__item-theme">
<?php
if ( isset( $item['theme'] ) && $item['theme']['slug'] === $current_theme ) {
?>
<span class="tb-list__item-theme--link" data-theme_slug="<?php echo esc_attr( $item['theme']['slug'] ); ?>" ><span class="dashicons dashicons-saved"></span><?php echo esc_attr( $item['theme']['name'] ); ?></span>
<?php
} else {
?>
<a class="tb-list__item-theme--link" href="<?php echo esc_url( $item['theme']['permalink'] ); ?>" data-theme_slug="<?php echo esc_attr( $item['theme']['slug'] ); ?>" target="_blank"><span class="dashicons dashicons-plus-alt2"></span><?php echo esc_attr( $item['theme']['name'] ); ?></a>
<?php
}
?>
</span>
<?php
}
?>
</div>
<div class="tb-list__item_actions">
<a class="tb-item__preview_link" href="<?php echo esc_url( $item['demo_url'] ); ?>" target="_blank"><?php echo esc_html__( 'Preview', 'templateberg' ); ?></a>
<a class="tb-list__item_btn tb-list__item_buy_btn"
data-id="<?php echo esc_attr( $item['id'] ); ?>"
data-is_pro="<?php echo esc_attr( ( $tb_download_price > 0 ) ? 'pro' : 'free' ); ?>"
data-theme_name="<?php echo esc_attr( $item['theme']['name'] ); ?>"
data-theme_slug="<?php echo esc_attr( $item['theme']['slug'] ); ?>"
href="<?php echo esc_url( $item['permalink'] ); ?>"
target="_blank"
rel="noopener"
>
<?php
if ( $tb_download_price > 0 ) :
echo esc_html__( 'Purchase', 'templateberg' );
else :
echo esc_html__( 'Get It Free', 'templateberg' );
endif;
?>
</a>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<?php
echo templateberg_pagination( $paged, $max_pages );
?>
</div>
</div>
<?php
require_once TEMPLATEBERG_PATH . 'includes/lists/templates/theme-buy-preview.php';
// Scripts.
wp_enqueue_script(
'templateberg-all-theme', // Handle.
TEMPLATEBERG_URL . 'dist/theme.min.js', // Block.build.js: We register the block here. Built with Webpack.
array( 'jquery' ), // Dependencies, defined above.
TEMPLATEBERG_VERSION, // Version: File modification time.
true // Enqueue the script in the footer.
);
wp_localize_script(
'templateberg-all-theme',
'templateberg_all_theme',
array(
'restNonce' => wp_create_nonce( 'wp_rest' ),
'restUrl' => esc_url_raw( rest_url() ),
'popularThemes' => $themes_list_popular,
'allThemes' => $themes_list,
'currentTheme' => $current_theme,
'text' => array(
'import' => esc_html__( 'Import', 'templateberg' ),
'purchase' => esc_html__( 'Purchase', 'templateberg' ),
'free' => esc_html__( 'Get It Free', 'templateberg' ),
'allItems' => esc_html__( 'All Items', 'templateberg' ),
'by' => esc_html__( 'By', 'templateberg' ),
'templates' => esc_html__( 'Templates', 'templateberg' ),
),
)
);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,166 @@
=== Templateberg - Gutenberg Templates, WordPress Themes Template Kits & WordPress Templates ===
Contributors: templateberg, gutentor, acmeit, codersantosh
Donate link: https://www.templateberg.com/
Tags: Pre-designed templates, Template Library, Gutenberg Templates, WordPress Templates, WordPress Themes Template Kits
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 5.6.20
Stable tag: 1.2.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Templateberg offers Gutenberg templates & WordPress theme kits. Import pre-designed layouts & build beautiful sites fast.
== Description ==
[Templateberg](https://www.templateberg.com) is the finest collection of [WordPress Gutenberg Templates](https://templateberg.com/gutenberg-templates/) and [WordPress Theme Template Kits](https://templateberg.com/wordpress-themes-template-kits/). Templateberg includes a tremendous listing of templates created in modern and fascinating styles from multipurpose to any niche which will accompany you with more excitement for designing your web pages.
=== Gutenberg Templates Some Terminology ===
- **Template Kits:** Template kits are a collection of different page templates like home, about, contact, team etc to create a complete website.
- **Templates:** Templates are single-page designs. It can be a different landing page design.
- **Blocks:** Blocks are a single section of a template. Probably the most modern way to create a template is by combing the block design the possibility to create a unique template is infinite.
=== WordPress Themes Template Kits ===
[WordPress Theme Template Kits](https://templateberg.com/wordpress-themes-template-kits/) are pre-designed templates, demos or mockups for a specific theme that you can import with a click to have a project quickly and beautiful.
=== Features ==
**Captivating Free Templates:**
The amazing templates designed are just one click away from loading into your website. Sign up now and have great options for the template or block design.
**Preview, Search and Filter Templates:**
Before importing templates you can preview the templates. Search and Filter help to quickly find what you are looking for.
**Harmonious Integration with Gutenberg Block editor:**
Its brilliant integration with Gutenberg Block editor makes it more interesting and users friendly.
**Includes 100+ Gutenberg Free Templates:**
The site consists of 100+ pre-built Gutenberg templates or blocks ready for our cherished clients.
**WooCommerce Templates:**
Templateberg includes stunning templates for WooCommerce design. Creating your online store will be easier now.
**Easy Digital Downloads Templates:**
Templateberg also includes templates for Easy Digital Downloads, perfect to create or redesign your digital store.
**Awesome Support**
Our team highly prioritizes and provides consistent support service to its users.
== Enjoying Templateberg? ==
- Like us on our [Facebook Page](https://www.facebook.com/templateberg).
- Follow us in [Twitter @templateberg](https://twitter.com/templateberg).
- Learn from our tutorials on [YouTube Videos](https://www.youtube.com/watch?v=noppoc1zLIk&list=PLDLpZS3H6SMnpUnrU84LwFs9AAzTYcbmA).
- Or rate us on [WordPress](https://wordpress.org/support/plugin/templateberg/reviews/?filter=5/#new-post) :)
== Frequently Asked Questions ==
= What is Templateberg? =
Templateberg is a collection of Gutenberg Templates, WordPress Themes Template Kits and WordPress Templates. You can choose from thousands of beautiful templates, with just one click to import and customize them for your needs.
= What is a block? =
Block is a section of a website page. It is the most modern way to design a website. The possibility is endless to create any page design by importing and combing the block section.
= What is a template? =
A template is a full design of a single website page. It can be a home page, about, service, contact, pricing or any landing page. Templateberg contains thousands of templates ready to import.
= What is a template kit? =
A template kit is a collection of templates for a website. The template kit contains all page templates for relative websites.
= What is Gutentor? =
[Gutentor](https://wordpress.org/plugins/gutentor/) is a WordPress plugin based on WordPress Block (Gutenberg) Editor, a modern drag & drop WordPress page builder Know more about it on [Gutentor official website](https://www.gutentor.com/). Templateberg contains primarily the Gutentor Templates.
= Does it work with any WordPress theme? =
Yes, it will work with any standard WordPress theme.
= Will Templateberg reduce my site speed? =
Not! Technically Templateberg just adds the functionality of the template library on the Gutenberg Block Editor, it doesn't load anything on the frontend. The Templateberg never slow down your site speed.
= What is a WordPress Theme Template Kit? =
A pre-designed starter content for a specific theme that you can simply import on your site with a click.
In other words, it can be called Demo Content for the theme.
= How Gutenberg Template Kit is different from Theme Template Kit? =
Gutenberg Template Kit is designed on WordPress Gutenberg Block Editor whereas Theme Template Kit is designed for the specific theme. Templates from Gutenberg Template Kits can be imported individually on a single page/post but when you import Theme Template Kit all content and pages are imported at once.
Gutenberg Template Kit will work on any Theme but Theme Template Kit will work on a single theme it is created from.
== Screenshots ==
1. Templateberg: Library Modal Showcase of Templates
2. Templateberg: Imported Template
3. Templateberg: Library Modal Live Preview
5. Templateberg: Edit Screen and Templateberg Button
5. Templateberg: Templateberg.com Gutenberg Templates
6. Templateberg: Get Free License Page
7. Templateberg: Admin Dashboard
== Changelog ==
= 1.2.0 - 2025-04-17 =
* Added: WordPress latest compatibility
* Fixed: Resolved issue with translation function preload
= 1.1.9 - 2024-10-31 =
* Added: WordPress latest compatibility
* Added: Language folder
= 1.1.8 - 2024-08-24 =
* Added: WordPress latest compatibility
* Added: Plugin link to Getting Started.
= 1.1.7 - 2024-07-19 =
* Added: WordPress latest compatibility
* Fixed: Image loading
= 1.1.6 - 2024-04-04 =
* Added: WordPress latest compatibility
* Updated: Few design issue.
= 1.1.5 - 2022-08-03 =
* Added: Favourites Tab - Now Users can have Favourite [Gutenberg Templates](https://templateberg.com/gutenberg-templates/)
* Fixed: Import button on FSE template change
= 1.1.4 - 2022-06-23 =
* Added: Gutentor Pro Compatibility
* Added: WordPress 6.8 Tested up to
* Fixed: FSE import button
* Fixed: Unnecessary console
* Fixed: Advance Import Design
* Updated: Missing Blocks Message
= 1.1.3 - 2022-02-03 =
* Added: Import Button on FSE Editor
* Updated: Missing Import Button on Normal Editor
* Updated: Preview button on Gutenberg Template Page
* Updated: Template Import Design
= 1.1.2 - 2021-07-27 =
* Fixed: WordPress 5.8 Block-based Widgets Editor notification
= 1.1.1 - 2021-07-25 =
* Added: Some Translation
* Added: Alt on some images
* Fixed: [switch_theme](https://wordpress.org/support/topic/urgent-templateberg-causes-theme-options-to-update-on-every-page-load/)
* Fixed: Typo in some pages
= 1.1.0 - 2021-07-23 =
* Added: WordPress 5.8 compatibility
* Added: WordPress Themes Template Kits Support
* Added: Admin Page Gutenberg Template Preview Page
* Updated: My account page
= 1.0.3 - 2021-04-22 =
* Updated: Import modal
* Updated: My account page
= 1.0.2 - 2021-03-26 =
* Added: Account Page
* Updated: Info Message
* Updated: Overall Functionalities and User Experience
= 1.0.1 - 2021-03-18 =
* Added: Contributors
* Fixed : PHP 7.2 compatibility
= 1.0.0 - 2021-03-11 =
* Initial Release

View File

@@ -0,0 +1,75 @@
<?php
/**If this file is called directly, abort.*/
if ( ! defined( 'WPINC' ) ) {
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
exit;
}
/**
*
* @link https://www.templateberg.com/
* @since 1.0.0
* @package Templateberg
*
* @wordpress-plugin
* Plugin Name: Templateberg - Gutenberg Templates, WordPress Themes Template Kits & WordPress Templates
* Description: Easily Import pre-designed templates with starter content on your website and instantly build an elegant website with WordPress. Templateberg content Gutenberg Templates, Patterns and WordPress Theme Template Kits.
* Version: 1.2.0
* Author: templateberg
* Author URI: https://www.templateberg.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: templateberg
*/
/*Define Constants for this plugin*/
const TEMPLATEBERG_VERSION = '1.2.0';
const TEMPLATEBERG_PLUGIN_NAME = 'templateberg';
define( 'TEMPLATEBERG_PATH', plugin_dir_path( __FILE__ ) );
define( 'TEMPLATEBERG_URL', plugin_dir_url( __FILE__ ) );
define( 'TEMPLATEBERG_SCRIPT_PREFIX', ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' );
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-templateberg-activator.php
*/
function activate_templateberg() {
require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-activator.php';
Templateberg_Activator::activate();
}
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require TEMPLATEBERG_PATH . 'includes/class-templateberg.php';
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-templateberg-deactivator.php
*/
function deactivate_templateberg() {
require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-deactivator.php';
Templateberg_Deactivator::deactivate();
}
register_activation_hook( __FILE__, 'activate_templateberg' );
register_deactivation_hook( __FILE__, 'deactivate_templateberg' );
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 1.0.0
*/
if ( ! function_exists( 'run_templateberg' ) ) {
function run_templateberg() {
return Templateberg::instance();
}
run_templateberg()->run();
}