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

Commit e9c1fc9

Browse files
Added notification in dashboard and customizer about Zerif Lite and Hestia
1 parent dc3dc7a commit e9c1fc9

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

class-ti-notify.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Class Ti_Notify
4+
*/
5+
class Ti_Notify extends WP_Customize_Section {
6+
7+
/**
8+
* The type of customize section being rendered.
9+
*
10+
* @since 1.0.4
11+
* @access public
12+
* @var string
13+
*/
14+
public $type = 'ti-notify';
15+
16+
public $text = '';
17+
18+
/**
19+
* Add custom parameters to pass to the JS via JSON.
20+
*
21+
* @since 1.0.4
22+
* @access public
23+
* @return void
24+
*/
25+
public function json() {
26+
$json = parent::json();
27+
$json['text'] = $this->text;
28+
return $json;
29+
}
30+
/**
31+
* Outputs the structure for the customizer control
32+
*
33+
* @since 1.0.4
34+
* @access public
35+
* @return void
36+
*/
37+
protected function render_template() { ?>
38+
<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
39+
<h3 class="accordion-section-title">
40+
<span class="section-title">
41+
<# if( data.text.length > 0 ){ #>
42+
{{{ data.text }}}
43+
<# } #>
44+
</span>
45+
</h3>
46+
</li>
47+
<?php
48+
}
49+
}
50+
?>

functions.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,50 @@ function responsiveboat_get_first_image_from_post() {
159159
return $zerif_first_img;
160160

161161
}
162+
163+
/**
164+
* Notice in Customize to announce the theme is not maintained anymore
165+
*/
166+
function zerius_customize_register( $wp_customize ) {
167+
168+
require_once get_stylesheet_directory() . '/class-ti-notify.php';
169+
170+
$wp_customize->register_section_type( 'Ti_Notify' );
171+
172+
$wp_customize->add_section(
173+
new Ti_Notify(
174+
$wp_customize,
175+
'ti-notify',
176+
array(
177+
'text' => sprintf( __( 'This child theme is not maintained anymore, consider using the parent theme %1$s or check-out our latest free one-page theme: %2$s.','zerius' ), sprintf( '<a href="https://wp-themes.com/zerif-lite/" target="_blank">%s</a>', 'Zerif Lite' ), sprintf( '<a href="https://wp-themes.com/hestia/" target="_blank">%s</a>', 'Hestia' ) ),
178+
'priority' => 0,
179+
)
180+
)
181+
);
182+
183+
$wp_customize->add_setting( 'zerius-notify') ;
184+
185+
$wp_customize->add_control( 'zerius-notify', array(
186+
'label' => __( 'Notification', 'zerius' ),
187+
'section' => 'ti-notify',
188+
'priority' => 1,
189+
) );
190+
}
191+
192+
add_action( 'customize_register', 'zerius_customize_register' );
193+
194+
/**
195+
* Notice in admin dashboard to announce the theme is not maintained anymore
196+
*/
197+
function zerius_admin_notice() {
198+
199+
global $pagenow;
200+
201+
if ( is_admin() && ( 'themes.php' == $pagenow ) && isset( $_GET['activated'] ) ) {
202+
echo '<div class="updated notice is-dismissible"><p>';
203+
printf( __( 'This child theme is not maintained anymore, consider using the parent theme %1$s or check-out our latest free one-page theme: %2$s.','zerius' ), sprintf( '<a href="https://wp-themes.com/zerif-lite/" target="_blank">%s</a>', 'Zerif Lite' ), sprintf( '<a href="https://wp-themes.com/hestia/" target="_blank">%s</a>', 'Hestia' ) );
204+
echo '</p></div>';
205+
}
206+
}
207+
208+
add_action( 'admin_notices', 'zerius_admin_notice', 99 );

0 commit comments

Comments
 (0)