' . esc_html__( 'Get started with Zakra', 'zakra' ) . '';
return $html;
}
/**
* Show welcome notice.
*/
public function welcome_notice_markup() {
$dismiss_url = wp_nonce_url(
remove_query_arg( array( 'activated' ), add_query_arg( 'zakra-hide-notice', 'welcome' ) ),
'zakra_hide_notices_nonce',
'_zakra_notice_nonce'
);
?>
',
''
);
?>
import_button_html(); ?>
get_error_code();
$response['errorMessage'] = $result->get_error_message();
}
}
} else {
wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
$response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&zakra-hide-notice=welcome' );
/**
* Install Plugin.
*/
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
$api = plugins_api(
'plugin_information',
array(
'slug' => sanitize_key( wp_unslash( 'themegrill-demo-importer' ) ),
'fields' => array(
'sections' => false,
),
)
);
$skin = new WP_Ajax_Upgrader_Skin();
$upgrader = new Plugin_Upgrader( $skin );
$result = $upgrader->install( $api->download_link );
if ( $result ) {
$response['installed'] = 'succeed';
} else {
$response['installed'] = 'failed';
}
// Activate plugin.
if ( current_user_can( 'activate_plugin' ) ) {
$result = activate_plugin( 'themegrill-demo-importer/themegrill-demo-importer.php' );
if ( is_wp_error( $result ) ) {
$response['errorCode'] = $result->get_error_code();
$response['errorMessage'] = $result->get_error_message();
}
}
}
wp_send_json( $response );
exit();
}
}
new Zakra_Welcome_Notice();