Skip to content

Commit c0b0ed4

Browse files
author
Cosmin
committed
#95 import demo content is now part of the req actions
1 parent 05f7ba1 commit c0b0ed4

File tree

5 files changed

+47
-28
lines changed

5 files changed

+47
-28
lines changed

functions.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ function shapely_setup() {
136136
array(
137137
"id" => 'shapely-req-import-content',
138138
"title" => esc_html__( 'Import content', 'shapely' ),
139-
"description" => esc_html__( 'Head over to the Demo Content tab (available only if you installed Shapely Companion plugin) and import sample content data.', 'shapely' ),
140-
"help" => '<a href="' . self_admin_url( 'themes.php?page=shapely-welcome&tab=demo_content' ) . '">' . __( 'Demo Content', 'shapely' ) . '</a>',
141-
"check" => Shapely_Notify_System::shapely_has_content(),
139+
"external" => ABSPATH . 'wp-content/plugins/shapely-companion/inc/views/shapely-demo-content.php',
140+
"check" => Shapely_Notify_System::shapely_check_import_req(),
142141
),
143142

144143
);

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,21 @@
181181

182182
.about-wrap .three-col .plugin_box.col {
183183
width: 29.81%;
184-
}
184+
}
185+
186+
.shapely-media-control img {
187+
width: 100%;
188+
}
189+
190+
#demo_content .spinner {
191+
float: none;
192+
}
193+
194+
#demo_content .updated-message,
195+
#demo_content .spinner {
196+
display: none;
197+
}
198+
199+
#demo_content .spinner.is-active {
200+
display: inline-block;
201+
}

inc/admin/welcome-screen/notify-system-checks.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,32 @@ public static function shapely_is_not_static_page() {
2828
* @return bool
2929
*/
3030
public static function shapely_has_content() {
31-
$option = get_option( "shapely_show_required_actions" );
32-
if ( $option['shapely-req-import-content'] ) {
31+
$option = get_option( "shapely_imported_demo", false );
32+
if ( $option ) {
3333
return true;
3434
};
3535

3636
return false;
3737
}
3838

3939
/**
40-
* @return bool
40+
* @return bool|mixed
4141
*/
42-
public static function shapely_check_wordpress_importer() {
43-
if ( file_exists( ABSPATH . 'wp-content/plugins/wordpress-importer/wordpress-importer.php' ) ) {
44-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
42+
public static function shapely_check_import_req() {
43+
$needs = array(
44+
'has_content' => self::shapely_has_content(),
45+
'has_plugin' => self::shapely_has_plugin( 'shapely-companion' )
46+
);
4547

46-
return is_plugin_active( 'wordpress-importer/wordpress-importer.php' );
48+
if ( $needs['has_content'] ) {
49+
return true;
4750
}
4851

49-
return false;
52+
if ( $needs['has_plugin'] ) {
53+
return false;
54+
}
55+
56+
return true;
5057
}
5158

5259
/**

inc/admin/welcome-screen/sections/actions-required.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,22 @@
2828
<div class="shapely-action-required-box">
2929
<?php if ( ! $hidden ): ?>
3030
<span data-action="dismiss" class="dashicons dashicons-visibility shapely-required-action-button"
31-
id="<?php echo $shapely_required_action_value['id']; ?>"></span>
31+
id="<?php echo esc_attr( $shapely_required_action_value['id'] ); ?>"></span>
3232
<?php else: ?>
33-
<span data-action="add" class="dashicons dashicons-hidden shapely-required-action-button" id="<?php echo $shapely_required_action_value['id']; ?>"></span>
33+
<span data-action="add" class="dashicons dashicons-hidden shapely-required-action-button"
34+
id="<?php echo esc_attr( $shapely_required_action_value['id'] ); ?>"></span>
3435
<?php endif; ?>
35-
<h3><?php if ( ! empty( $shapely_required_action_value['title'] ) ): echo $shapely_required_action_value['title']; endif; ?></h3>
36+
<h3><?php if ( ! empty( $shapely_required_action_value['title'] ) ): echo esc_html( $shapely_required_action_value['title'] ); endif; ?></h3>
3637
<p>
37-
<?php if ( ! empty( $shapely_required_action_value['description'] ) ): echo $shapely_required_action_value['description']; endif; ?>
38-
<?php if ( ! empty( $shapely_required_action_value['help'] ) ): echo '<br/>' . $shapely_required_action_value['help']; endif; ?>
38+
<?php if ( ! empty( $shapely_required_action_value['description'] ) ): echo esc_html( $shapely_required_action_value['description'] ); endif; ?>
39+
<?php if ( ! empty( $shapely_required_action_value['help'] ) ): echo '<br/>' . wp_kses_post( $shapely_required_action_value['help'] ); endif; ?>
3940
</p>
4041
<?php
42+
if ( ! empty( $shapely_required_action_value['external'] ) && file_exists( $shapely_required_action_value['external'] ) ) {
43+
require_once $shapely_required_action_value['external'];
44+
}
45+
?>
46+
<?php
4147
if ( ! empty( $shapely_required_action_value['plugin_slug'] ) ) {
4248
$active = $this->check_active( $shapely_required_action_value['plugin_slug'] );
4349
$url = $this->create_action_link( $active['needs'], $shapely_required_action_value['plugin_slug'] );
@@ -73,6 +79,7 @@ class="<?php echo $class; ?>"
7379
endforeach;
7480
endif;
7581

82+
7683
if ( $hooray ):
7784
echo '<span class="hooray">' . __( 'Hooray! There are no required actions for you right now.', 'shapely' ) . '</span>';
7885
endif;

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,6 @@ class="nav-tab <?php echo $active_tab == 'recommended_actions' ? 'nav-tab-active
334334
<?php echo $action_count > 0 ? '<span class="badge-action-count">' . esc_html( $action_count ) . '</span>' : '' ?></a>
335335
<a href="<?php echo admin_url( 'themes.php?page=shapely-welcome&tab=recommended_plugins' ); ?>"
336336
class="nav-tab <?php echo $active_tab == 'recommended_plugins' ? 'nav-tab-active' : ''; ?> "><?php echo esc_html__( 'Recommended Plugins', 'shapely' ); ?></a>
337-
<?php $shapely_companion = $this->check_active( 'shapely-companion' ); ?>
338-
<?php if ( $shapely_companion['needs'] === 'deactivate' ): ?>
339-
<a href="<?php echo admin_url( 'themes.php?page=shapely-welcome&tab=demo_content' ); ?>"
340-
class="nav-tab <?php echo $active_tab == 'demo_content' ? 'nav-tab-active' : ''; ?> "><?php echo esc_html__( 'Demo Content', 'shapely' ); ?></a>
341-
<?php endif; ?>
342337
<a href="<?php echo admin_url( 'themes.php?page=shapely-welcome&tab=support' ); ?>"
343338
class="nav-tab <?php echo $active_tab == 'support' ? 'nav-tab-active' : ''; ?> "><?php echo esc_html__( 'Support', 'shapely' ); ?></a>
344339
<a href="<?php echo admin_url( 'themes.php?page=shapely-welcome&tab=changelog' ); ?>"
@@ -362,12 +357,6 @@ class="nav-tab <?php echo $active_tab == 'changelog' ? 'nav-tab-active' : ''; ?>
362357
case 'changelog':
363358
require_once get_template_directory() . '/inc/admin/welcome-screen/sections/changelog.php';
364359
break;
365-
case 'demo_content':
366-
$shapely_companion = $this->check_active( 'shapely-companion' );
367-
if ( $shapely_companion['needs'] === 'deactivate' && file_exists( ABSPATH . 'wp-content/plugins/shapely-companion/inc/views/shapely-demo-content.php' ) ) {
368-
require_once ABSPATH . 'wp-content/plugins/shapely-companion/inc/views/shapely-demo-content.php';
369-
}
370-
break;
371360
default:
372361
require_once get_template_directory() . '/inc/admin/welcome-screen/sections/getting-started.php';
373362
break;

0 commit comments

Comments
 (0)