Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #144 from Codeinwp/development
Browse files Browse the repository at this point in the history
Update Customize upsells layout
  • Loading branch information
rodica-andronache authored Feb 14, 2017
2 parents 05b7b28 + 5aa39f6 commit 85e74ae
Show file tree
Hide file tree
Showing 11 changed files with 647 additions and 164 deletions.
5 changes: 3 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ function llorix_one_lite_setup() {
*/
add_theme_support( 'eventbrite' );

if ( ! class_exists( 'Llorix_One_Plus' ) ) {
require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-llorix-one-lite-customize-upsell.php' );
if ( is_customize_preview() && ! class_exists( 'Llorix_One_Plus' ) ) {
require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-customizer-theme-info-root.php' );
require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-customizer-theme-info-control.php' );
}
}
endif; // llorix_one_lite_setup
Expand Down
113 changes: 113 additions & 0 deletions inc/customize-pro/class-customizer-theme-info-control.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
/**
* Llorix One Lite Upsell Theme Info Class
*
* @package Llorix One Lite
*/

if ( ! class_exists( 'Llorix_One_Lite_Control_Upsell_Theme_Info' ) ) :

/**
* Llorix_One_Lite_Control_Upsell_Theme_Info class.
*/
class Llorix_One_Lite_Control_Upsell_Theme_Info extends WP_Customize_Control {

/**
* Control type
*
* @var string control type
*/
public $type = 'themeisle-control-upsell';

/**
* Button text
*
* @var string button text
*/
public $button_text = '';

/**
* Button link
*
* @var string button url
*/
public $button_url = '#';

/**
* List of features
*
* @var array theme features / options
*/
public $options = array();

/**
* List of explanations
*
* @var array additional info
*/
public $explained_features = array();

/**
* Llorix_One_Lite_Control_Upsell_Theme_Info constructor.
*
* @param WP_Customize_Manager $manager the customize manager class.
* @param string $id id.
* @param array $args customizer manager parameters.
*/
public function __construct( WP_Customize_Manager $manager, $id, array $args ) {
$this->button_text;
$manager->register_control_type( 'Llorix_One_Lite_Control_Upsell_Theme_Info' );
parent::__construct( $manager, $id, $args );

}
/**
* Enqueue resources for the control
*/
public function enqueue() {
wp_enqueue_style( 'themeisle-upsell-style', get_template_directory_uri() . '/inc/customize-pro/css/style.css', '1.0.0' );
}

/**
* Json conversion
*/
public function to_json() {
parent::to_json();
$this->json['button_text'] = $this->button_text;
$this->json['button_url'] = $this->button_url;
$this->json['options'] = $this->options;
$this->json['explained_features'] = $this->explained_features;
}

/**
* Control content
*/
public function content_template() {
?>
<div class="themeisle-upsell">
<# if ( data.options ) { #>
<ul class="themeisle-upsell-features">
<# for (option in data.options) { #>
<li><span class="upsell-pro-label"></span>{{ data.options[option] }}
</li>
<# } #>
</ul>
<# } #>

<# if ( data.button_text && data.button_url ) { #>
<a target="_blank" href="{{ data.button_url }}" class="button button-primary" target="_blank">{{
data.button_text }}</a>
<# } #>

<# if ( data.explained_features.length > 0 ) { #>
<hr />

<ul class="themeisle-upsell-feature-list">
<# for (requirement in data.explained_features) { #>
<li>* {{{ data.explained_features[requirement] }}}</li>
<# } #>
</ul>
<# } #>
</div>
<?php }
}
endif;
130 changes: 130 additions & 0 deletions inc/customize-pro/class-customizer-theme-info-root.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
/**
* Singleton class file.
*
* @package llorix-one-lite
*/

/**
* Singleton class for handling the theme's customizer integration.
*
* @since 1.0.0
* @access public
*/
final class Llorix_One_Lite_Customizer_Upsell {

/**
* Returns the instance.
*
* @since 1.0.0
* @access public
* @return object
*/
public static function get_instance() {

static $instance = null;

if ( is_null( $instance ) ) {
$instance = new self;
$instance->setup_actions();
}

return $instance;
}

/**
* Constructor method.
*
* @since 1.0.0
* @access private
* @return void
*/
private function __construct() {}

/**
* Sets up initial actions.
*
* @since 1.0.0
* @access private
* @return void
*/
private function setup_actions() {

// Register panels, sections, settings, controls, and partials.
add_action( 'customize_register', array( $this, 'sections' ) );

// Register scripts and styles for the controls.
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
}

/**
* Sets up the customizer sections.
*
* @since 1.0.0
* @access public
* @param object $manager Customizer manager.
* @return void
*/
public function sections( $manager ) {

// Load custom sections.
require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-llorix-one-lite-customize-upsell-frontpage-sections.php' );
require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-llorix-one-lite-customize-theme-info-main.php' );
require_once( trailingslashit( get_template_directory() ) . 'inc/customize-pro/class-llorix-one-lite-customize-theme-info-section.php' );

// Register custom section types.
$manager->register_section_type( 'Llorix_One_Lite_Customizer_Upsell_Frontpage_Sections' );
$manager->register_section_type( 'Llorix_One_Lite_Customizer_Theme_Info_Main' );
$manager->register_section_type( 'Llorix_One_Lite_Customizer_Theme_Info_Section' );

if ( 'posts' === get_option( 'show_on_front' ) ) {
$manager->add_section( new Llorix_One_Lite_Customizer_Upsell_Frontpage_Sections( $manager, 'llorix-one-lite-frontpage-instructions',
array(
'upsell_text' => __( 'To customize the Frontpage sections please create a page and select the template "Frontpage" for that page. After that, go to Appearance -> Customize -> Static Front Page and under "Static Front Page" select "A static page". Finally, for "Front page" choose the page you previously created.','llorix-one-lite' ) . '<br><br>' . __( 'Need further informations? Check this','llorix-one-lite' ) . ' <a href="http://docs.themeisle.com/article/236-how-to-set-up-the-home-page-for-llorix-one">' . __( 'doc','llorix-one-lite' ) . '</a>',
'panel' => 'llorix_one_lite_front_page_sections',
'priority' => 1,
'active_callback' => 'llorix_one_lite_show_on_front',
) ) );
}

// Main Documentation Link In Customizer Root.
$manager->add_section( new Llorix_One_Lite_Customizer_Theme_Info_Main( $manager, 'llorix-one-lite-theme-info', array(
'theme_info_title' => __( 'Llorix One Lite', 'llorix-one-lite' ),
'label_url' => esc_url( 'http://docs.themeisle.com/article/186-llorix-one-documentation' ),
'label_text' => __( 'Documentation', 'llorix-one-lite' ),
) ) );

// Frontpage Sections Upsell.
$manager->add_section( new Llorix_One_Lite_Customizer_Theme_Info_Section( $manager, 'llorix-one-lite-theme-info-section', array(
'active_callback' => 'llorix_one_lite_show_on_front',
'panel' => 'llorix_one_lite_front_page_sections',
'priority' => 500,
'options' => array(
esc_html__( 'Shop Section', 'llorix-one-lite' ),
esc_html__( 'Portfolio Section', 'llorix-one-lite' ),
esc_html__( 'Shortcodes Section', 'llorix-one-lite' ),
esc_html__( 'Section Reordering', 'llorix-one-lite' ),
),

'button_url' => esc_url( 'https://themeisle.com/plugins/llorix-one-plus/' ),
'button_text' => esc_html__( 'View PRO version', 'llorix-one-lite' ),
) ) );
}

/**
* Loads theme customizer CSS.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue_control_scripts() {

wp_enqueue_script( 'llorix-one-lite-upsell-js', trailingslashit( get_template_directory_uri() ) . 'inc/customize-pro/js/llorix-one-lite-upsell-customize-controls.js', array( 'customize-controls' ) );

wp_enqueue_style( 'llorix-one-lite-theme-info-style', trailingslashit( get_template_directory_uri() ) . 'inc/customize-pro/css/style.css' );

}
}

Llorix_One_Lite_Customizer_Upsell::get_instance();
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* The customizer upsell.
*
* Pro customizer section.
*
* @package WordPress
* @subpackage Llorix One Lite
*/

/**
* Class Llorix_One_Lite_Customizer_Theme_Info_Main
*
* @since 1.0.0
* @access public
*/
class Llorix_One_Lite_Customizer_Theme_Info_Main extends WP_Customize_Section {

/**
* The type of customize section being rendered.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'llorix-one-lite-theme-info';

/**
* Upsell title to output.
*
* @since 1.0.0
* @access public
* @var string
*/
public $theme_info_title = '';

/**
* Label text to output.
*
* @since 1.0.0
* @access public
* @var string
*/
public $label_text = '';

/**
* Label URL.
*
* @since 1.0.0
* @access public
* @var string
*/
public $label_url = '';

/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
* @access public
*/
public function json() {
$json = parent::json();

$json['theme_info_title'] = $this->theme_info_title;
$json['label_text'] = $this->label_text;
$json['label_url'] = esc_url( $this->label_url );

return $json;
}

/**
* Outputs the Underscore.js template.
*
* @since 1.0.0
* @access public
* @return void
*/
protected function render_template() {
?>

<li id="accordion-section-{{ data.id }}"
class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
<h3 class="accordion-section-title">
{{data.theme_info_title}}
<# if ( data.label_text && data.label_url ) { #>
<a class="button button-secondary alignright" href="{{data.label_url}}" target="_blank">
{{data.label_text}}
</a>
<# } #>
</h3>
</li>
<?php
}
}
Loading

0 comments on commit 85e74ae

Please sign in to comment.