Skip to content
This repository was archived by the owner on Jan 28, 2019. It is now read-only.

Commit ba95132

Browse files
Merge pull request #442 from cristian-ungureanu/development
#439 - reorganize upsells
2 parents eae9665 + 2fd2a15 commit ba95132

14 files changed

+542
-296
lines changed

css/admin-style.css

+8
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,11 @@ button.parallax_one_general_control_remove_field:hover {
221221
.parallax_one_add_social_item {
222222
margin-top: 10px;
223223
}
224+
225+
.parallax-one-theme-info {
226+
text-align: center;
227+
}
228+
229+
.parallax-one-theme-info hr {
230+
margin: 10px auto;
231+
}

functions.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,6 @@ function parallax_one_customizer_scripts() {
202202

203203
wp_enqueue_script( 'parallax_one_customizer_script', parallax_get_file( '/js/parallax_one_customizer.js' ), array( 'jquery', 'jquery-ui-draggable' ),'1.0.2', true );
204204

205-
wp_localize_script( 'parallax_one_customizer_script', 'parallaxOneCustomizerObject', array(
206-
207-
'documentation' => esc_html__( 'Documentation', 'parallax-one' ),
208-
'support' => esc_html__( 'Support','parallax-one' ),
209-
'pro' => __( 'Upgrade to PRO','parallax-one' ),
210-
211-
) );
212205
}
213206
add_action( 'customize_controls_enqueue_scripts', 'parallax_one_customizer_scripts' );
214207

@@ -341,6 +334,11 @@ function parallax_one_scripts() {
341334
*/
342335
require get_template_directory() . '/inc/hooks.php';
343336

337+
/**
338+
* Customizer info
339+
*/
340+
require_once get_template_directory() . '/inc/customizer-info/class/class-singleton-customizer-info-section.php';
341+
344342
/**
345343
* TAV_Remote_Notification_Client.
346344
*/

inc/admin/welcome-screen/css/welcome_customizer.css

-23
This file was deleted.

inc/admin/welcome-screen/js/welcome_customizer.js

-16
This file was deleted.

inc/admin/welcome-screen/sections/getting-started.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@
4949
</div>
5050

5151
<div class="prallax-one-tab-pane-half prallax-one-tab-pane-first-half">
52-
52+
<?php
53+
$link = 'http://docs.themeisle.com/article/14-how-to-create-a-child-theme/';
54+
if( class_exists('Parallax_One_Plus') ){
55+
$link = 'http://docs.themeisle.com/article/264-how-to-create-a-child-theme-if-you-use-parallax-one-plus';
56+
} ?>
5357
<h4><?php esc_html_e( 'Create a child theme', 'parallax-one' ); ?></h4>
5458
<p><?php esc_html_e( 'If you want to make changes to the theme\'s files, those changes are likely to be overwritten when you next update the theme. In order to prevent that from happening, you need to create a child theme. For this, please follow the documentation below.', 'parallax-one' ); ?></p>
55-
<p><a href="http://docs.themeisle.com/article/14-how-to-create-a-child-theme/" class="button"><?php esc_html_e( 'View how to do this', 'parallax-one' ); ?></a></p>
59+
<p><a href="<?php echo esc_url($link); ?>" class="button"><?php esc_html_e( 'View how to do this', 'parallax-one' ); ?></a></p>
5660

5761
<hr />
5862

inc/admin/welcome-screen/welcome-screen.php

-17
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public function __construct() {
1717

1818
/* enqueue script and style for welcome screen */
1919
add_action( 'admin_enqueue_scripts', array( $this, 'parallax_one_welcome_style_and_scripts' ) );
20-
21-
/* enqueue script for customizer */
22-
add_action( 'customize_controls_enqueue_scripts', array( $this, 'parallax_one_welcome_scripts_for_customizer' ) );
2320

2421
/* load welcome screen */
2522
add_action( 'parallax_one_welcome', array( $this, 'parallax_one_welcome_getting_started' ), 10 );
@@ -69,20 +66,6 @@ public function parallax_one_welcome_style_and_scripts( $hook_suffix ) {
6966
wp_enqueue_script( 'parallax-one-welcome-screen-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome.js', array('jquery') );
7067
}
7168
}
72-
73-
/**
74-
* Load scripts for customizer page
75-
*/
76-
public function parallax_one_welcome_scripts_for_customizer() {
77-
78-
wp_enqueue_style( 'parallax-one-welcome-screen-customizer-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome_customizer.css' );
79-
wp_enqueue_script( 'parallax-one-welcome-screen-customizer-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome_customizer.js', array('jquery'), '20120206', true );
80-
wp_localize_script( 'parallax-one-welcome-screen-customizer-js', 'parallaxOneWelcomeScreenCustomizerObject', array(
81-
'aboutpage' => esc_url( admin_url( 'themes.php?page=parallax-one-welcome#getting_started' ) ),
82-
'themeinfo' => __('View Theme Info','parallax-one'),
83-
) );
84-
85-
}
8669

8770
/**
8871
* Welcome screen content

inc/class/parallax-one-info.php

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Class to display upsells.
4+
*
5+
* @package WordPress
6+
* @subpackage parallax-one
7+
*/
8+
if ( ! class_exists( 'WP_Customize_Control' ) ) {
9+
return;
10+
}
11+
12+
/**
13+
* Class Parallax_One_Info
14+
*/
15+
class Parallax_One_Info extends WP_Customize_Control {
16+
17+
/**
18+
* The type of customize section being rendered.
19+
*
20+
* @since 1.0.0
21+
* @access public
22+
* @var string
23+
*/
24+
public $type = 'info';
25+
26+
/**
27+
* Control label
28+
*
29+
* @since 1.0.0
30+
* @access public
31+
* @var string
32+
*/
33+
public $label = '';
34+
35+
/**
36+
* The render function for the controler
37+
*/
38+
public function render_content() {
39+
$links = array(
40+
array(
41+
'name' => __( 'Documentation','parallax-one' ),
42+
'link' => esc_url( 'http://themeisle.com/documentation-parallax-one/' ),
43+
),
44+
array(
45+
'name' => __( 'Support','parallax-one' ),
46+
'link' => esc_url( 'http://themeisle.com/contact/' ),
47+
),
48+
array(
49+
'name' => __( 'View Theme Info','parallax-one' ),
50+
'link' => admin_url( 'themes.php?page=parallax-one-welcome#getting_started' ),
51+
),
52+
); ?>
53+
54+
55+
<div class="parallax-one-theme-info">
56+
<?php
57+
foreach ( $links as $item ) { ?>
58+
<a href="<?php echo esc_url( $item['link'] ); ?>" target="_blank"><?php echo esc_html( $item['name'] ); ?></a>
59+
<hr/>
60+
<?php
61+
} ?>
62+
</div>
63+
<?php
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Customizer info main class.
4+
*
5+
* @package WordPress
6+
* @subpackage Hestia
7+
* @since Hestia 1.0
8+
*/
9+
10+
/**
11+
* Pro customizer section.
12+
*
13+
* @since 1.0.0
14+
* @access public
15+
*/
16+
class Customizer_Info extends WP_Customize_Section {
17+
18+
/**
19+
* The type of customize section being rendered.
20+
*
21+
* @since 1.0.0
22+
* @access public
23+
* @var string
24+
*/
25+
public $type = 'customizer-info';
26+
27+
28+
/**
29+
* Label title to output.
30+
*
31+
* @since 1.0.0
32+
* @access public
33+
* @var string
34+
*/
35+
public $section_title = '';
36+
37+
38+
/**
39+
* Label text to output.
40+
*
41+
* @since 1.0.0
42+
* @access public
43+
* @var string
44+
*/
45+
public $section_text = '';
46+
47+
/**
48+
* Button url.
49+
*
50+
* @since 1.0.0
51+
* @access public
52+
* @var string
53+
*/
54+
public $section_url = '';
55+
56+
/**
57+
* Add custom parameters to pass to the JS via JSON.
58+
*
59+
* @since 1.0.0
60+
* @access public
61+
* @return array
62+
*/
63+
public function json() {
64+
$json = parent::json();
65+
$json['section_text'] = $this->section_text;
66+
$json['section_title'] = $this->section_title;
67+
$json['section_url'] = $this->section_url;
68+
return $json;
69+
}
70+
71+
/**
72+
* Outputs the Underscore.js template.
73+
*
74+
* @since 1.0.0
75+
* @access public
76+
* @return void
77+
*/
78+
protected function render_template() {
79+
?>
80+
81+
<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
82+
<h3 class="accordion-section-title">
83+
<# if ( data.section_url){ #>
84+
<# if ( data.section_title ) { #>
85+
{{{data.section_title}}}
86+
<# } #>
87+
<# if ( data.section_text && data.section_url ) { #>
88+
<a class="button button-secondary alignright" href="{{data.section_url}}" target="_blank">
89+
{{data.section_text}}
90+
</a>
91+
<# } #>
92+
<# } #>
93+
</h3>
94+
</li>
95+
<?php
96+
}
97+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Customizer info singleton class file.
4+
*
5+
* @package WordPress
6+
* @subpackage Hestia
7+
* @since Hestia 1.0
8+
*/
9+
10+
/**
11+
* Singleton class for handling the theme's customizer integration.
12+
*
13+
* @since 1.0.0
14+
* @access public
15+
*/
16+
final class Customizer_Info_Singleton {
17+
18+
/**
19+
* Returns the instance.
20+
*
21+
* @since 1.0.0
22+
* @access public
23+
* @return object
24+
*/
25+
public static function get_instance() {
26+
27+
static $instance = null;
28+
29+
if ( is_null( $instance ) ) {
30+
$instance = new self;
31+
$instance->setup_actions();
32+
}
33+
34+
return $instance;
35+
}
36+
37+
/**
38+
* Constructor method.
39+
*
40+
* @since 1.0.0
41+
* @access private
42+
* @return void
43+
*/
44+
private function __construct() {}
45+
46+
/**
47+
* Sets up initial actions.
48+
*
49+
* @since 1.0.0
50+
* @access private
51+
* @return void
52+
*/
53+
private function setup_actions() {
54+
55+
// Register panels, sections, settings, controls, and partials.
56+
add_action( 'customize_register', array( $this, 'sections' ), 1 );
57+
58+
// Register scripts and styles for the controls.
59+
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
60+
}
61+
62+
/**
63+
* Sets up the customizer sections.
64+
*
65+
* @since 1.0.0
66+
* @access public
67+
* @param object $manager WordPress customizer object.
68+
* @return void
69+
*/
70+
public function sections( $manager ) {
71+
72+
// Load custom sections.
73+
require_once( trailingslashit( get_template_directory() ) . 'inc/customizer-info/class/class-customizer-info-section.php' );
74+
75+
// Register custom section types.
76+
$manager->register_section_type( 'Customizer_Info' );
77+
78+
if ( ! class_exists( 'Parallax_One_Plus' ) ) {
79+
$manager->add_section( new Customizer_Info( $manager, 'parallax_one_view_pro', array(
80+
'section_title' => __( 'View PRO version', 'parallax-one' ),
81+
'section_url' => 'https://themeisle.com/plugins/parallax-one-plus/',
82+
'section_text' => __( 'Get it', 'parallax-one' ),
83+
) ) );
84+
}
85+
86+
}
87+
88+
/**
89+
* Loads theme customizer CSS.
90+
*
91+
* @since 1.0.0
92+
* @access public
93+
* @return void
94+
*/
95+
public function enqueue_control_scripts() {
96+
wp_enqueue_script( 'customizer-info-js', trailingslashit( get_template_directory_uri() ) . 'inc/customizer-info/js/customizer-info-controls.js', array( 'customize-controls' ) );
97+
}
98+
}
99+
100+
Customizer_Info_Singleton::get_instance();

0 commit comments

Comments
 (0)