| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/templates-directory.tar |
views/template-directory-render-template-tpl.php 0000666 00000000374 15113763611 0016126 0 ustar 00 <?php
/**
* The View for Rendering the Template Directory Main Dashboard Page.
*
* @link https://themeisle.com
* @since 2.0.0
*
* @package ThemeIsle
* @subpackage ThemeIsle/PageTemplatesDirectory
* @codeCoverageIgnore
*/
die();
views/template-directory-page-tpl.php 0000666 00000016055 15113763611 0013755 0 ustar 00 <?php
/**
* The View for Rendering the Template Directory Main Dashboard Page.
*
* @link https://themeisle.com
* @since 2.0.0
*
* @package ThemeIsle
* @subpackage ThemeIsle/PageTemplatesDirectory
* @codeCoverageIgnore
*/
$preview_url = add_query_arg( 'obfx_templates', '', home_url() ); // Define query arg for custom endpoint.
$html = '';
if ( is_array( $templates_array ) ) { ?>
<div class="obfx-template-dir wrap">
<h2 class="wp-heading-inline"> <?php echo apply_filters( 'obfx_template_dir_page_title', __( 'Orbit Fox Template Directory', 'themeisle-companion' ) ); ?></h2>
<button id="obfx-template-dir-fetch-templates" class="button-primary button"><i class="dashicons dashicons-update"></i><?php echo __( 'Sync Templates', 'themeisle-companion' ); ?></button>
<div class="obfx-template-browser">
<?php
foreach ( $templates_array as $template => $properties ) {
?>
<div class="obfx-template">
<?php if ( isset( $properties['has_badge'] ) ) { ?>
<span class="badge"><?php echo esc_html( $properties['has_badge'] ); ?></span>
<?php } ?>
<div class="more-details obfx-preview-template"
data-demo-url="<?php echo esc_url( $properties['demo_url'] ); ?>"
data-template-slug="<?php echo esc_attr( $template ); ?>">
<span><?php echo __( 'More Details', 'themeisle-companion' ); ?></span></div>
<div class="obfx-template-screenshot">
<img src="<?php echo esc_url( $properties['screenshot'] ); ?>"
alt="<?php echo esc_html( $properties['title'] ); ?>">
</div>
<h2 class="template-name template-header"><?php echo esc_html( $properties['title'] ); ?></h2>
<div class="obfx-template-actions">
<?php if ( ! empty( $properties['demo_url'] ) ) { ?>
<a class="button obfx-preview-template"
data-demo-url="<?php echo esc_url( $properties['demo_url'] ); ?>"
data-template-slug="<?php echo esc_attr( $template ); ?>"><?php echo __( 'Preview', 'themeisle-companion' ); ?></a>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>
<div class="wp-clearfix clearfix"></div>
<?php } // End if().
?>
<div class="obfx-template-preview theme-install-overlay wp-full-overlay expanded" style="display: none;">
<div class="wp-full-overlay-sidebar">
<div class="wp-full-overlay-header">
<button class="close-full-overlay"><span
class="screen-reader-text"><?php esc_html_e( 'Close', 'themeisle-companion' ); ?></span></button>
<div class="obfx-next-prev">
<button class="previous-theme"><span
class="screen-reader-text"><?php esc_html_e( 'Previous', 'themeisle-companion' ); ?></span></button>
<button class="next-theme"><span
class="screen-reader-text"><?php esc_html_e( 'Next', 'themeisle-companion' ); ?></span></button>
</div>
<span class="obfx-import-template button button-primary"><?php esc_html_e( 'Import', 'themeisle-companion' ); ?></span>
<a href="https://themeisle.com/plugins/sizzify-elementor-addons-templates" target="_blank"
class="obfx-upsell-button button button-primary"><?php esc_html_e( 'See Pro Version', 'themeisle-companion' ); ?></a>
</div>
<div class="wp-full-overlay-sidebar-content">
<?php
foreach ( $templates_array as $template => $properties ) {
$upsell = 'no';
if ( isset( $properties['has_badge'] ) && ! isset( $properties['import_file'] ) ) {
$upsell = 'yes';
$properties['import_file'] = '';
}
?>
<div class="install-theme-info obfx-theme-info <?php echo esc_attr( $template ); ?>"
data-demo-url="<?php echo esc_url( $properties['demo_url'] ); ?>"
<?php if( isset( $properties['import_file'] ) ) { ?>
data-template-file="<?php echo esc_url( $properties['import_file'] ); ?>"
<?php } ?>
data-template-title="<?php echo esc_html( $properties['title'] ); ?>"
data-upsell="<?php echo esc_attr( $upsell ) ?>">
<h3 class="theme-name"><?php echo esc_html( $properties['title'] ); ?></h3>
<div class="obfx-preview-wrap">
<img class="theme-screenshot" src="<?php echo esc_url( $properties['screenshot'] ); ?>"
alt="<?php echo esc_html( $properties['title'] ); ?>">
<?php if ( isset( $properties['has_badge'] ) ) { ?>
<span class="badge"> <?php echo esc_html( $properties['has_badge'] ); ?></span>
<?php } ?>
</div>
<div class="theme-details">
<?php echo esc_html( $properties['description'] ); ?>
</div>
<?php
if ( ! empty( $properties['required_plugins'] ) && is_array( $properties['required_plugins'] ) ) { ?>
<div class="obfx-required-plugins">
<p><?php esc_html_e( 'Required Plugins', 'themeisle-companion' ); ?></p>
<?php
foreach ( $properties['required_plugins'] as $plugin_slug => $details ) {
if ( $this->check_plugin_state( $plugin_slug ) === 'install' ) {
echo '<div class="obfx-installable plugin-card-' . esc_attr( $plugin_slug ) . '">';
echo '<span class="dashicons dashicons-no-alt"></span>';
echo $details['title'];
echo $this->get_button_html( $plugin_slug );
echo '</div>';
} elseif ( $this->check_plugin_state( $plugin_slug ) === 'activate' ) {
echo '<div class="obfx-activate plugin-card-' . esc_attr( $plugin_slug ) . '">';
echo '<span class="dashicons dashicons-admin-plugins" style="color: #ffb227;"></span>';
echo $details['title'];
echo $this->get_button_html( $plugin_slug );
echo '</div>';
} else {
echo '<div class="obfx-installed plugin-card-' . esc_attr( $plugin_slug ) . '">';
echo '<span class="dashicons dashicons-yes" style="color: #34a85e"></span>';
echo $details['title'];
echo '</div>';
}
} ?>
</div>
<?php } ?>
</div><!-- /.install-theme-info -->
<?php } ?>
</div>
<div class="wp-full-overlay-footer">
<button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="Collapse Sidebar">
<span class="collapse-sidebar-arrow"></span>
<span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'themeisle-companion' ); ?></span>
</button>
<div class="devices-wrapper">
<div class="devices obfx-responsive-preview">
<button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
<span class="screen-reader-text"><?php esc_html_e( 'Enter desktop preview mode', 'themeisle-companion' ); ?></span>
</button>
<button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
<span class="screen-reader-text"><?php esc_html_e( 'Enter tablet preview mode', 'themeisle-companion' ); ?></span>
</button>
<button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
<span class="screen-reader-text"><?php esc_html_e( 'Enter mobile preview mode', 'themeisle-companion' ); ?></span>
</button>
</div>
</div>
</div>
</div>
<div class="wp-full-overlay-main obfx-main-preview">
<iframe src="" title="Preview" class="obfx-template-frame"></iframe>
</div>
</div>
class-page-templates-directory.php 0000666 00000061317 15113763611 0013312 0 ustar 00 <?php
namespace ThemeIsle;
if ( ! class_exists( '\ThemeIsle\PageTemplatesDirectory' ) ) {
class PageTemplatesDirectory {
/**
* @var PageTemplatesDirectory
*/
protected static $instance = null;
/**
* The version of this library
* @var string
*/
public static $version = '1.0.9';
/**
* Holds the module slug.
*
* @since 1.0.0
* @access protected
* @var string $slug The module slug.
*/
protected $slug = 'templates-directory';
protected $source_url;
/**
* Defines the library behaviour
*/
protected function init() {
add_action( 'rest_api_init', array( $this, 'register_endpoints' ) );
//Add dashboard menu page.
add_action( 'admin_menu', array( $this, 'add_menu_page' ), 100 );
//Add rewrite endpoint.
add_action( 'init', array( $this, 'demo_listing_register' ) );
//Add template redirect.
add_action( 'template_redirect', array( $this, 'demo_listing' ) );
//Enqueue admin scripts.
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_template_dir_scripts' ) );
// Get the full-width pages feature
add_action( 'init', array( $this, 'load_full_width_page_templates' ), 11 );
// Remove the blank template from the page template selector
add_filter( 'fwpt_templates_list', array( $this, 'filter_fwpt_templates_list' ) );
// Filter to add fetched.
add_filter( 'template_directory_templates_list', array( $this, 'filter_templates' ), 99 );
$default_source_url = apply_filters( 'templates_directory_source_url', 'https://raw.githubusercontent.com/Codeinwp/obfx-templates/master/' );
$this->set_source_url( $default_source_url );
}
/**
* Enqueue the scripts for the dashboard page of the
*/
public function enqueue_template_dir_scripts() {
$current_screen = get_current_screen();
if ( $current_screen->id === 'orbit-fox_page_obfx_template_dir' || $current_screen->id === 'sizzify_page_sizzify_template_dir' ) {
if ( $current_screen->id === 'orbit-fox_page_obfx_template_dir' ) {
$plugin_slug = 'obfx';
} else {
$plugin_slug = 'sizzify';
}
$script_handle = $this->slug . '-script';
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'updates' );
wp_register_script( $script_handle, plugin_dir_url( $this->get_dir() ) . $this->slug . '/js/script.js', array( 'jquery' ), $this::$version );
wp_localize_script( $script_handle, 'importer_endpoint',
array(
'url' => $this->get_endpoint_url( '/import_elementor' ),
'plugin_slug' => $plugin_slug,
'fetch_templates_url' => $this->get_endpoint_url( '/fetch_templates' ),
'nonce' => wp_create_nonce( 'wp_rest' ),
) );
wp_enqueue_script( $script_handle );
wp_enqueue_style( $this->slug . '-style', plugin_dir_url( $this->get_dir() ) . $this->slug . '/css/admin.css', array(), $this::$version );
}
}
/**
*
*
* @param string $path
*
* @return string
*/
public function get_endpoint_url( $path = '' ) {
return rest_url( $this->slug . $path );
}
/**
* Register Rest endpoint for requests.
*/
public function register_endpoints() {
register_rest_route( $this->slug, '/import_elementor', array(
'methods' => 'POST',
'callback' => array( $this, 'import_elementor' ),
'permission_callback' => function () {
return current_user_can( 'manage_options' );
},
) );
register_rest_route( $this->slug, '/fetch_templates', array(
'methods' => 'POST',
'callback' => array( $this, 'fetch_templates' ),
'permission_callback' => function () {
return current_user_can( 'manage_options' );
},
) );
}
/**
* Function to fetch templates.
*
* @return array|bool|\WP_Error
*/
public function fetch_templates( \WP_REST_Request $request ) {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
$params = $request->get_params();
if ( empty ( $params['plugin_slug'] ) ) {
return false;
}
$plugin_slug = $params['plugin_slug'];
$query_args = array( 'license' => '', 'url' => get_home_url(), 'name' => $plugin_slug );
$license = get_option( 'eaw_premium_license_data', '' );
if ( ! empty ( $license ) ) {
$license = isset( $license->key ) ? $license->key : '';
$query_args['license'] = $license;
$query_args['_'] = time();
}
$url = add_query_arg( $query_args, 'https://themeisle.com/?edd_action=get_templates' );
$request = wp_remote_retrieve_body( wp_remote_post( esc_url_raw( $url ) ) );
$response = json_decode( $request, true );
if ( ! empty( $response ) ) {
update_option( $plugin_slug . '_synced_templates', $response );
}
die();
}
public function filter_templates( $templates ) {
$current_screen = get_current_screen();
if ( $current_screen->id === 'orbit-fox_page_obfx_template_dir' ) {
$fetched = get_option( 'obfx_synced_templates' );
} else {
$fetched = get_option( 'sizzify_synced_templates' );
}
if ( empty( $fetched ) ) {
return $templates;
}
if ( ! is_array( $fetched ) ) {
return $templates;
}
$new_templates = array_merge( $templates, $fetched['templates'] );
return $new_templates;
}
/**
* The templates list.
*
* @return array
*/
public function templates_list() {
$defaults_if_empty = array(
'title' => __( 'A new Orbit Fox Template', 'themeisle-companion' ),
'screenshot' => esc_url( 'https://raw.githubusercontent.com/Codeinwp/obfx-templates/master/placeholder.png' ),
'description' => __( 'This is an awesome Orbit Fox Template.', 'themeisle-companion' ),
'demo_url' => esc_url( 'https://demo.themeisle.com/hestia-pro-demo-content/demo-placeholder/' ),
'import_file' => '',
'required_plugins' => array( 'elementor' => array( 'title' => __( 'Elementor Page Builder', 'themeisle-companion' ) ) ),
);
$templates_list = array(
'about-our-business-elementor' => array(
'title' => __( 'About Our Business', 'themeisle-companion' ),
'description' => __( 'Use this layout to present your business in a fancy way. Add an interactive header, shwocase your services via progress bars, introduce your team members, and locate your headquarters on Google Maps. Last but not least, beautify the design by adding catchy images.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/about-our-business-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'about-our-business-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'about-our-business-elementor/template.json' ),
),
'contact-us-elementor' => array(
'title' => __( 'Contact Us', 'themeisle-companion' ),
'description' => __( 'A clean and simple template for your Contact page, where we integrated our Pirate Forms plugin. It will let your customers send you a message using an intuitive form. A Google map, together with a few other details about your business, completes the section.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/contact-us-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'contact-us-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'contact-us-elementor/template.json' ),
),
'pricing-elementor' => array(
'title' => __( 'Pricing', 'themeisle-companion' ),
'description' => __( 'If you plan to sell your products online, this layout offers you elegant pricing tables so you can differentiate the features and services for your clients. Also, for a better clarification, the template provides a FAQ area where you can answer people\'s questions.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/pricing-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'pricing-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'pricing-elementor/template.json' ),
),
'material-homepage-elementor' => array(
'title' => __( 'Material Homepage', 'themeisle-companion' ),
'description' => __( 'This layout could be your main website homepage (or you can use it as an alternative homepage, if you wish). It was built on material design and comes with call to action, catchy icons, testimonials, blog posts, pricing plans, and other sections that you can add yourself by customizing it.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/material-homepage-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'material-homepage-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'material-homepage-elementor/template.json' ),
),
'ether-elementor' => array(
'title' => __( 'Ether - Landing Page', 'themeisle-companion' ),
'description' => __( 'An elegant and modern landing page for e-commerce, coming with a clean interface, beautiful typography, photo galleries, and call to action. If you have an online shop and want to promote a certain product, use this layout to tell people why they should buy it.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/ether-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'ether-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'ether-elementor/template.json' ),
),
'jason-elementor' => array(
'title' => __( 'Jason - Landing Page', 'themeisle-companion' ),
'description' => __( 'A classy template for freelancers, where you can put your skills and knowldge in the spotlight for potential clients. Talk about yourself, your projects, awards, and let people contact you easily. The template is designed to feature one-page scrolling.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/jason-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'jason-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'jason-elementor/template.json' ),
),
'pulse-elementor' => array(
'title' => __( 'Pulse - Landing Page', 'themeisle-companion' ),
'description' => __( 'A good-looking landing page for products and apps, built to mark the features and services that they offer. The layout provides customer reviews, call to action, beautiful pricing tables, an About section, and a creative design. If you want to promote and sell your brand product, this template might help.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/pulse-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'pulse-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'pulse-elementor/template.json' ),
),
'ascend-elementor' => array(
'title' => __( 'Ascend - Landing Page', 'themeisle-companion' ),
'description' => __( 'A resume-like template, built for outdoor enthusiasts and nature lovers. Its design and layout make it flexible for any other purpose too, so do not hesitate to showcase any kind of skills and activities, even business-oriented.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/ascend-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'ascend-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'ascend-elementor/template.json' ),
),
'path-elementor' => array(
'title' => __( 'Path - Landing Page', 'themeisle-companion' ),
'description' => __( 'If you are a business consultant - agency or working on your own - have a look at this template! It comes with a clean design, call to action, statistics, and sections that put your services first.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/path-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'path-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'path-elementor/template.json' ),
),
'mocha-elementor' => array(
'title' => __( 'Mocha - Landing Page', 'themeisle-companion' ),
'description' => __( 'An elegant and modern template for cafes and pubs, where you can display your menu in a mouth-watering way. Call to action, blog posts, attractive images, tabbed menus, and a catchy design will help you convince more people to stop by.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/mocha-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'mocha-elementor/screenshot.png' ),
'import_file' => esc_url( $this->get_source_url() . 'mocha-elementor/template.json' ),
),
'rik-landing' => array(
'title' => __( 'Rik - Landing Page', 'themeisle-companion' ),
'description' => __( 'This is a clean Landing page, ready to be used for an app presentation. It features beautiful gradients and great layouts for showcasing your product.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/rik-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'rik-elementor/screenshot.jpg' ),
'import_file' => esc_url( $this->get_source_url() . 'rik-elementor/template.json' ),
),
'zelle-lite' => array(
'title' => __( 'Zelle Lite - One Page Template', 'themeisle-companion' ),
'description' => __( 'A friendly one-page multipurpose page, with a full-width image in the background. It comes with an elegant and modern design, which could fit very well any kind of business. Zelle Lite has an interactive and colorful interface, with classy parallax effect and lively animations. You can use it for your online shop as well.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/zelle-lite/',
'screenshot' => esc_url( $this->get_source_url() . 'zelle-lite/screenshot.jpg' ),
'import_file' => esc_url( $this->get_source_url() . 'zelle-lite/template.json' ),
),
'notify' => array(
'title' => __( 'Notify - Landing Page', 'themeisle-companion' ),
'description' => __( 'A beautiful landing page to showcase your new application. It has a features section to present your app, a subscribe section where you can also add a video showcasing your new app and a testimonials section so you can present the feedback from your beta testers.', 'themeisle-companion' ),
'demo_url' => 'https://demo.themeisle.com/hestia-pro-demo-content/notify-elementor/',
'screenshot' => esc_url( $this->get_source_url() . 'notify-elementor/screenshot.jpg' ),
'import_file' => esc_url( $this->get_source_url() . 'notify-elementor/template.json' ),
)
);
foreach ( $templates_list as $template => $properties ) {
$templates_list[ $template ] = wp_parse_args( $properties, $defaults_if_empty );
}
return apply_filters( 'template_directory_templates_list', $templates_list );
}
/**
* Register endpoint for themes page.
*/
public function demo_listing_register() {
add_rewrite_endpoint( 'obfx_templates', EP_ROOT );
}
/**
* Return template preview in customizer.
*
* @return bool|string
*/
public function demo_listing() {
$flag = get_query_var( 'obfx_templates', false );
if ( $flag !== '' ) {
return false;
}
if ( ! current_user_can( 'customize' ) ) {
return false;
}
if ( ! is_customize_preview() ) {
return false;
}
return $this->render_view( 'template-directory-render-template' );
}
/**
* Add the 'Template Directory' page to the dashboard menu.
*/
public function add_menu_page() {
$products = apply_filters( 'obfx_template_dir_products', array() );
foreach ( $products as $product ) {
add_submenu_page(
$product['parent_page_slug'], $product['directory_page_title'], __( 'Template Directory', 'themeisle-companion' ), 'manage_options', $product['page_slug'],
array( $this, 'render_admin_page' )
);
}
}
/**
* Render the template directory admin page.
*/
public function render_admin_page() {
$data = array(
'templates_array' => $this->templates_list(),
);
echo $this->render_view( 'template-directory-page', $data );
}
/**
* Utility method to call Elementor import routine.
*
* @param \WP_REST_Request $request the async request.
*
* @return string
*/
public function import_elementor( \WP_REST_Request $request ) {
if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
return 'no-elementor';
}
$params = $request->get_params();
$template_name = $params['template_name'];
$template_url = $params['template_url'];
require_once( ABSPATH . 'wp-admin' . '/includes/file.php' );
require_once( ABSPATH . 'wp-admin' . '/includes/image.php' );
// Mime a supported document type.
$elementor_plugin = \Elementor\Plugin::$instance;
$elementor_plugin->documents->register_document_type( 'not-supported', \Elementor\Modules\Library\Documents\Page::get_class_full_name() );
$template = download_url( esc_url( $template_url ) );
$name = $template_name;
$_FILES['file']['tmp_name'] = $template;
$elementor = new \Elementor\TemplateLibrary\Source_Local;
$elementor->import_template( $name, $template );
unlink( $template );
$args = array(
'post_type' => 'elementor_library',
'nopaging' => true,
'posts_per_page' => '1',
'orderby' => 'date',
'order' => 'DESC',
'suppress_filters' => true,
);
$query = new \WP_Query( $args );
$last_template_added = $query->posts[0];
//get template id
$template_id = $last_template_added->ID;
wp_reset_query();
wp_reset_postdata();
//page content
$page_content = $last_template_added->post_content;
//meta fields
$elementor_data_meta = get_post_meta( $template_id, '_elementor_data' );
$elementor_ver_meta = get_post_meta( $template_id, '_elementor_version' );
$elementor_edit_mode_meta = get_post_meta( $template_id, '_elementor_edit_mode' );
$elementor_css_meta = get_post_meta( $template_id, '_elementor_css' );
$elementor_metas = array(
'_elementor_data' => ! empty( $elementor_data_meta[0] ) ? wp_slash( $elementor_data_meta[0] ) : '',
'_elementor_version' => ! empty( $elementor_ver_meta[0] ) ? $elementor_ver_meta[0] : '',
'_elementor_edit_mode' => ! empty( $elementor_edit_mode_meta[0] ) ? $elementor_edit_mode_meta[0] : '',
'_elementor_css' => $elementor_css_meta,
);
// Create post object
$new_template_page = array(
'post_type' => 'page',
'post_title' => $template_name,
'post_status' => 'publish',
'post_content' => $page_content,
'meta_input' => $elementor_metas,
'page_template' => apply_filters( 'template_directory_default_template', 'templates/builder-fullwidth-std.php' )
);
$current_theme = wp_get_theme();
switch ( $current_theme->get_template() ) {
case 'hestia-pro':
case 'hestia':
$new_template_page['page_template'] = 'page-templates/template-pagebuilder-full-width.php';
break;
case 'zerif-lite':
case 'zerif-pro':
$new_template_page['page_template'] = 'template-fullwidth-no-title.php';
break;
}
$post_id = wp_insert_post( $new_template_page );
$redirect_url = add_query_arg( array(
'post' => $post_id,
'action' => 'elementor',
), admin_url( 'post.php' ) );
return ( $redirect_url );
}
/**
* Generate action button html.
*
* @param string $slug plugin slug.
*
* @return string
*/
public function get_button_html( $slug ) {
$button = '';
$state = $this->check_plugin_state( $slug );
if ( ! empty( $slug ) ) {
switch ( $state ) {
case 'install':
$nonce = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'from' => 'import',
'plugin' => $slug,
),
network_admin_url( 'update.php' )
),
'install-plugin_' . $slug
);
$button .= '<a data-slug="' . $slug . '" class="install-now obfx-install-plugin button button-primary" href="' . esc_url( $nonce ) . '" data-name="' . $slug . '" aria-label="Install ' . $slug . '">' . __( 'Install and activate', 'themeisle-companion' ) . '</a>';
break;
case 'activate':
$plugin_link_suffix = $slug . '/' . $slug . '.php';
$nonce = add_query_arg(
array(
'action' => 'activate',
'plugin' => rawurlencode( $plugin_link_suffix ),
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin_link_suffix ),
), network_admin_url( 'plugins.php' )
);
$button .= '<a data-slug="' . $slug . '" class="activate-now button button-primary" href="' . esc_url( $nonce ) . '" aria-label="Activate ' . $slug . '">' . __( 'Activate', 'themeisle-companion' ) . '</a>';
break;
}// End switch().
}// End if().
return $button;
}
/**
* Getter method for the source url
* @return mixed
*/
public function get_source_url() {
return $this->source_url;
}
/**
* Setting method for source url
*
* @param $url
*/
protected function set_source_url( $url ) {
$this->source_url = $url;
}
/**
* Check plugin state.
*
* @param string $slug plugin slug.
*
* @return bool
*/
public function check_plugin_state( $slug ) {
if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $slug . '/' . $slug . '.php' ) || file_exists( WP_CONTENT_DIR . '/plugins/' . $slug . '/index.php' ) ) {
require_once( ABSPATH . 'wp-admin' . '/includes/plugin.php' );
$needs = ( is_plugin_active( $slug . '/' . $slug . '.php' ) ||
is_plugin_active( $slug . '/index.php' ) ) ?
'deactivate' : 'activate';
return $needs;
} else {
return 'install';
}
}
/**
* If the composer library is present let's try to init.
*/
public function load_full_width_page_templates() {
if ( class_exists( '\ThemeIsle\FullWidthTemplates' ) ) {
\ThemeIsle\FullWidthTemplates::instance();
}
}
/**
* By default the composer library "Full Width Page Templates" comes with two page templates: a blank one and a full
* width one with the header and footer inherited from the active theme.
* OBFX Template directory doesn't need the blonk one, so we are going to ditch it.
*
* @param array $list
*
* @return array
*/
public function filter_fwpt_templates_list( $list ) {
unset( $list['templates/builder-fullwidth.php'] );
return $list;
}
/**
* Utility method to render a view from module.
*
* @codeCoverageIgnore
*
* @since 1.0.0
* @access protected
*
* @param string $view_name The view name w/o the `-tpl.php` part.
* @param array $args An array of arguments to be passed to the view.
*
* @return string
*/
protected function render_view( $view_name, $args = array() ) {
ob_start();
$file = $this->get_dir() . '/views/' . $view_name . '-tpl.php';
if ( ! empty( $args ) ) {
foreach ( $args as $obfx_rh_name => $obfx_rh_value ) {
$$obfx_rh_name = $obfx_rh_value;
}
}
if ( file_exists( $file ) ) {
include $file;
}
return ob_get_clean();
}
/**
* Method to return path to child class in a Reflective Way.
*
* @since 1.0.0
* @access protected
* @return string
*/
protected function get_dir() {
return dirname( __FILE__ );
}
/**
* @static
* @since 1.0.0
* @access public
* @return PageTemplatesDirectory
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
self::$instance->init();
}
return self::$instance;
}
/**
* Throw error on object clone
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @access public
* @since 1.0.0
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'themeisle-companion' ), '1.0.0' );
}
/**
* Disable unserializing of the class
*
* @access public
* @since 1.0.0
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'themeisle-companion' ), '1.0.0' );
}
}
}
css/admin.css 0000666 00000014177 15113763611 0007160 0 ustar 00 .obfx-template-browser {
display: grid;
padding: 35px 0 0;
grid-gap: 2em;
}
.obfx-template-browser .template-name {
float: left;
margin: 0;
padding: 15px;
font-size: 16px;
font-weight: 600;
}
.obfx-template {
position: relative;
box-sizing: border-box;
border: 1px solid #ddd;
background: #fff;
box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
cursor: pointer;
}
.obfx-preview-wrap {
margin: 15px 0;
position: relative;
}
.obfx-preview-wrap .badge,
.obfx-template .badge {
position: absolute;
color: #fff;
z-index: 10;
background-color: #00a6e3;
padding: 7px 12px;
text-transform: uppercase;
border-radius: 0 0 3px 0;
top: 1px;
left: 0;
box-shadow: 2px 2px 2px 0 rgba(0,0,0,0.25);
font-weight: 500;
font-size: 20px;
}
.obfx-template:nth-child(3n) {
margin-right: 0;
}
.obfx-template:hover .obfx-template-actions,
.obfx-template:hover .obfx-preview-template {
opacity: 1;
}
.obfx-template:hover .obfx-template-screenshot {
opacity: 0.4;
}
.obfx-template-actions {
float: right;
position: absolute;
right: 0;
bottom: 0;
padding: 10px 15px;
border-left: 1px solid rgba(0,0,0,0.05);
opacity: 0;
background: rgba(244,244,244,0.7);
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
}
.obfx-template-actions .button .dashicons {
line-height: 27px;
}
.obfx-template-actions .button {
margin-left: 5px;
}
.obfx-template-screenshot {
display: inline-block;
float: left;
overflow: hidden;
position: relative;
width: 100%;
border: 1px solid #ddd;
border-right: none;
border-left: none;
background: #fff;
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
}
.obfx-template img {
float: left;
width: 100%;
}
.obfx-template-browser.customizer {
display: block !important;
padding: 10px 20px 60px;
}
.obfx-next-prev {
position: absolute;
left: 45px;
}
.obfx-next-prev span:hover {
border-color: #ccc;
outline: 0;
color: #000;
background: #ddd;
box-shadow: none;
}
.obfx-next-prev .previous-template,
.obfx-next-prev .next-template {
display: block;
float: left;
position: relative;
width: 45px;
height: 45px;
padding-right: 2px;
border: none;
border-right: 1px solid #ddd;
color: #444;
background: #eee;
text-decoration: none;
cursor: pointer;
-webkit-transition: color 0.1s ease-in-out,background 0.1s ease-in-out;
transition: color 0.1s ease-in-out,background 0.1s ease-in-out;
}
.obfx-next-prev .previous-template {
border-left: 1px solid #ddd;
}
.obfx-next-prev .next-template:before {
position: relative;
top: 6px;
left: 14px;
font: 400 20px/1 dashicons;
content: "\f345";
}
.obfx-next-prev .previous-template:before {
position: relative;
top: 6px;
left: 14px;
font: 400 20px/1 dashicons;
content: "\f341";
}
.obfx-custom-customizer {
background: #fff;
}
.obfx-template-browser.customizer .obfx-template.active {
display: inline-block;
}
.customize-controls-preview-toggle {
float: left;
position: relative;
left: 120px;
}
.obfx-template-browser.customizer .template-name {
padding-left: 0;
}
.obfx-template-browser.customizer .obfx-template-screenshot {
border: 1px solid #ddd;
}
.obfx-hide {
display: none !important;
}
.obfx-import-elementor-hidden-form {
display: inline-block;
}
.obfx-done-import {
display: block;
margin: 0;
padding-top: 10px;
color: green;
text-align: center;
}
.obfx-done-import .dashicons {
font-size: 30px;
}
.obfx-updating.updating-message.button.button-primary {
padding: 0 4px 0 10px;
}
.obfx-no-elementor-modal-wrapper {
display: none;
position: fixed;
z-index: 900000;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: 0 auto;
background: rgba(0, 0, 0, 0.8);
}
.obfx-no-elementor-modal {
position: relative;
top: 50%;
width: auto;
max-width: 550px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
text-align: right;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.obfx-no-elementor-modal p {
margin: 30px 0 20px;
text-align: left;
}
.obfx-no-elementor-modal .modal-header {
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 30px;
border-bottom: 1px solid #d4d4d4;
background: #e6e6e6;
}
.obfx-close-modal {
float: right;
position: absolute;
top: 5px;
right: 5px;
color: #7b7b7b;
cursor: pointer;
}
.obfx-template-preview.theme-install-overlay .install-theme-info.obfx-theme-info .theme-screenshot {
width: 100%;
margin: 0;
}
.obfx-template-preview.theme-install-overlay .install-theme-info.obfx-theme-info {
display: none;
}
.obfx-template-preview.theme-install-overlay .install-theme-info.obfx-theme-info.active {
display: block;
}
.more-details.obfx-preview-template {
position: absolute;
z-index: 100;
top: 0;
right: 0;
bottom: 51px;
left: 0;
opacity: 0;
text-align: center;
cursor: pointer;
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
}
.more-details.obfx-preview-template span {
display: block;
position: relative;
top: 50%;
left: 50%;
width: 45%;
padding: 15px 12px;
border-radius: 3px;
color: #fff;
background: #23282d;
background: rgba(0,0,0,0.7);
text-shadow: 0 1px 0 rgba(0,0,0,0.6);
font-size: 15px;
font-weight: 600;
-webkit-font-smoothing: antialiased;
text-align: center;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.obfx-required-plugins > p {
margin-top: 20px;
color: #333;
font-weight: 800;
}
.obfx-required-plugins .button {
display: none;
}
#obfx-template-dir-fetch-templates {
display: block;
margin: 0 auto;
}
#obfx-template-dir-fetch-templates .dashicons {
margin: 3px 5px 0 -2px;
}
@media only screen and (max-width: 2000px) {
.obfx-template-browser {
grid-template-columns: 1fr 1fr 1fr 1fr;
}
}
@media only screen and (max-width: 1450px) {
.obfx-template-browser {
grid-template-columns: 1fr 1fr 1fr;
}
}
@media only screen and (max-width: 1000px) {
.obfx-template-browser {
grid-template-columns: 1fr 1fr;
}
}
@media only screen and (max-width: 600px) {
.obfx-template-preview .wp-full-overlay-sidebar {
width: 100%;
}
.obfx-template-browser {
grid-template-columns: 1fr;
}
}
@media only screen and (min-width: 2000px) {
.obfx-template-browser {
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
}
} LICENSE 0000666 00000026135 15113763611 0005570 0 ustar 00 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
load.php 0000666 00000000526 15113763611 0006207 0 ustar 00 <?php
/**
* Loader for the ThemeIsle\PageTemplatesDirectory
*
* @package ThemeIsle\PageTemplatesDirectory
* @copyright Copyright (c) 2017, Andrei Lupu
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0.0
*/
require_once( dirname( __FILE__ ) . '/class-page-templates-directory.php' ); composer.json 0000666 00000001242 15113763611 0007275 0 ustar 00 {
"name": "codeinwp/templates-directory",
"description": "A WordPress library to manage page templates.",
"type": "library",
"version": "1.0.9",
"license": "GPL-2.0-or-later",
"homepage": "https://github.com/Codeinwp/templates-directory",
"authors": [
{
"name": "ThemeIsle team",
"email": "friends@themeisle.com",
"homepage": "https://themeisle.com"
}
],
"autoload": {
"files": [
"load.php"
]
},
"require": {
"codeinwp/full-width-page-templates": "master"
},
"support": {
"issues": "https://github.com/Codeinwp/templates-directory/issues"
},
"minimum-stability": "dev",
"prefer-stable": true
}
js/script.js 0000666 00000021154 15113763611 0007035 0 ustar 00 /* global importer_endpoint, console */
/**
* Template Directory Customizer Admin Dashboard Script
*
* This handles the template directory.
*
* @since 1.0.0
* @package obfx_modules/template-directory/js
*
* @author ThemeIsle
*/
var obfx_template_directory = function ( $ ) {
'use strict';
$(
function () {
// Handle import click.
$( '.wp-full-overlay-header' ).on(
'click', '.obfx-import-template', function () {
$( this ).addClass( 'obfx-import-queue updating-message obfx-updating' ).html( '' );
$( '.obfx-template-preview .close-full-overlay, .obfx-next-prev' ).remove();
var template_url = $( this ).data( 'template-file' );
var template_name = $( this ).data( 'template-title' );
if ( $( '.active .obfx-installable' ).length || $( '.active .obfx-activate' ).length ) {
checkAndInstallPlugins();
} else {
$.ajax(
{
url: importer_endpoint.url,
beforeSend: function ( xhr ) {
$( '.obfx-import-queue' ).addClass( 'obfx-updating' ).html( '' );
xhr.setRequestHeader( 'X-WP-Nonce', importer_endpoint.nonce );
},
data: {
template_url: template_url,
template_name: template_name
},
type: 'POST',
success: function ( data ) {
$( '.obfx-updating' ).replaceWith( '<span class="obfx-done-import"><i class="dashicons-yes dashicons"></i></span>' );
location.href = data;
},
error: function ( error ) {
console.error( error );
},
complete: function () {
$( '.obfx-updating' ).replaceWith( '<span class="obfx-done-import"><i class="dashicons-yes dashicons"></i></span>' );
}
}, 'json'
);
}
}
);
$( '#obfx-template-dir-fetch-templates' ).on( 'click', function ( e ) {
e.preventDefault();
$.ajax(
{
url: importer_endpoint.fetch_templates_url,
beforeSend: function ( xhr ) {
$( '#obfx-template-dir-fetch-templates .dashicons' ).hide();
$( '#obfx-template-dir-fetch-templates' ).addClass( 'updating-message' );
xhr.setRequestHeader( 'X-WP-Nonce', importer_endpoint.nonce );
},
data: {
plugin_slug: importer_endpoint.plugin_slug,
},
type: 'POST',
success: function () {
$( '#obfx-template-dir-fetch-templates' ).removeClass( 'updating-message' ).attr('disabled', 'true').empty().html('<i class="dashicons-yes dashicons" style="margin-right:0"></i>');
location.reload();
},
error: function( error ) {
console.log(error);
}
}, 'json'
);
} );
function checkAndInstallPlugins() {
var installable = $( '.active .obfx-installable' );
var toActivate = $( '.active .obfx-activate' );
if ( installable.length || toActivate.length ) {
$( installable ).each(
function () {
var plugin = $( this );
$( plugin ).removeClass( 'obfx-installable' ).addClass( 'obfx-installing' );
$( plugin ).find( 'span.dashicons' ).replaceWith( '<span class="dashicons dashicons-update" style="-webkit-animation: rotation 2s infinite linear; animation: rotation 2s infinite linear; color: #ffb227 "></span>' );
var slug = $( this ).find( '.obfx-install-plugin' ).attr( 'data-slug' );
wp.updates.installPlugin(
{
slug: slug,
success: function ( response ) {
activatePlugin( response.activateUrl, plugin );
}
}
);
}
);
$( toActivate ).each(
function () {
var plugin = $( this );
var activateUrl = $( plugin ).find( '.activate-now' ).attr( 'href' );
if ( typeof activateUrl !== 'undefined' ) {
activatePlugin( activateUrl, plugin );
}
}
);
}
}
function activatePlugin( activationUrl, plugin ) {
$.ajax(
{
type: 'GET',
url: activationUrl,
beforeSend: function () {
$( plugin ).removeClass( 'obfx-activate' ).addClass( 'obfx-installing' );
$( plugin ).find( 'span.dashicons' ).replaceWith( '<span class="dashicons dashicons-update" style="-webkit-animation: rotation 2s infinite linear; animation: rotation 2s infinite linear; color: #ffb227 "></span>' );
},
success: function () {
$( plugin ).find( '.dashicons' ).replaceWith( '<span class="dashicons dashicons-yes" style="color: #34a85e"></span>' );
$( plugin ).removeClass( 'obfx-installing' );
},
complete: function () {
if ( $( '.active .obfx-installing' ).length === 0 ) {
$( '.obfx-import-queue' ).trigger( 'click' );
}
}
}
);
}
// Handle sidebar collapse in preview.
$( '.obfx-template-preview' ).on(
'click', '.collapse-sidebar', function (event) {
event.preventDefault();
var overlay = $( '.obfx-template-preview' );
if ( overlay.hasClass( 'expanded' ) ) {
overlay.removeClass( 'expanded' );
overlay.addClass( 'collapsed' );
return false;
}
if ( overlay.hasClass( 'collapsed' ) ) {
overlay.removeClass( 'collapsed' );
overlay.addClass( 'expanded' );
return false;
}
}
);
// Handle responsive buttons.
$( '.obfx-responsive-preview' ).on(
'click', 'button', function () {
$( '.obfx-template-preview' ).removeClass( 'preview-mobile preview-tablet preview-desktop' );
var deviceClass = 'preview-' + $( this ).data( 'device' );
$( '.obfx-responsive-preview button' ).each(
function () {
$( this ).attr( 'aria-pressed', 'false' );
$( this ).removeClass( 'active' );
}
);
$( '.obfx-responsive-preview' ).removeClass( $( this ).attr( 'class' ).split( ' ' ).pop() );
$( '.obfx-template-preview' ).addClass( deviceClass );
$( this ).addClass( 'active' );
}
);
// Hide preview.
$( '.close-full-overlay' ).on(
'click', function () {
$( '.obfx-template-preview .obfx-theme-info.active' ).removeClass( 'active' );
$( '.obfx-template-preview' ).hide();
$( '.obfx-template-frame' ).attr( 'src', '' );
}
);
// Open preview routine.
$( '.obfx-preview-template' ).on(
'click', function () {
var templateSlug = $( this ).data( 'template-slug' );
var previewUrl = $( this ).data( 'demo-url' );
$( '.obfx-template-frame' ).attr( 'src', previewUrl );
$( '.obfx-theme-info.' + templateSlug ).addClass( 'active' );
setupImportButton();
$( '.obfx-template-preview' ).fadeIn();
}
);
// Handle left-right navigation between templates.
$( '.obfx-next-prev .next-theme' ).on(
'click', function () {
var active = $( '.obfx-theme-info.active' ).removeClass( 'active' );
if ( active.next() && active.next().length ) {
active.next().addClass( 'active' );
} else {
active.siblings( ':first' ).addClass( 'active' );
}
changePreviewSource();
setupImportButton();
}
);
$( '.obfx-next-prev .previous-theme' ).on(
'click', function () {
var active = $( '.obfx-theme-info.active' ).removeClass( 'active' );
if ( active.prev() && active.prev().length ) {
active.prev().addClass( 'active' );
} else {
active.siblings( ':last' ).addClass( 'active' );
}
changePreviewSource();
setupImportButton();
}
);
// Change preview source.
function changePreviewSource() {
var previewUrl = $( '.obfx-theme-info.active' ).data( 'demo-url' );
$( '.obfx-template-frame' ).attr( 'src', previewUrl );
}
function setupImportButton() {
var button = $( '.wp-full-overlay-header .obfx-import-template' );
var dataUpsell = $( '.active' ).data( 'upsell' );
var upsellButton = $( '.obfx-upsell-button' );
if ( dataUpsell === 'yes' ) {
$( button ).hide();
$( upsellButton ).show();
return false;
}
$( button ).show();
$( upsellButton ).hide();
var installable = $( '.active .obfx-installable' );
if ( installable.length > 0 ) {
$( '.wp-full-overlay-header .obfx-import-template' ).text( 'Install and Import' );
} else {
$( '.wp-full-overlay-header .obfx-import-template' ).text( 'Import' );
}
var activeTheme = $( '.obfx-theme-info.active' );
$( button ).attr( 'data-template-file', $( activeTheme ).data( 'template-file' ) );
$( button ).attr( 'data-template-title', $( activeTheme ).data( 'template-title' ) );
}
}
);
};
obfx_template_directory( jQuery );
README.md 0000666 00000000025 15114322722 0006023 0 ustar 00 # templates-directory js/.htaccess 0000666 00000000424 15114671314 0006765 0 ustar 00 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>