-
${plugin_description}
+
${shorten_description(plugin['description'])}
${plugin_by_text.replace(
'%s',
@@ -151,8 +151,8 @@ jQuery(function ($) {
}
function shorten_description(description = '') {
- if (description.length > 75) {
- description = description.slice(0, 175) + '...';
+ if (description.length > 88) {
+ description = description.slice(0, 88) + '...';
}
return description;
}
@@ -185,70 +185,6 @@ jQuery(function ($) {
card_back.append('
');
});
- function makeRequest(type, url, data, base = 'dt/v1/') {
- // Add trailing slash if missing
- if (!base.endsWith('/') && !url.startsWith('/')) {
- base += '/';
- }
- const options = {
- type: type,
- contentType: 'application/json; charset=utf-8',
- dataType: 'json',
- url: url.startsWith('http')
- ? url
- : `${window.wpApiSettings.root}${base}${url}`,
- beforeSend: (xhr) => {
- xhr.setRequestHeader('X-WP-Nonce', window.wpApiSettings.nonce);
- },
- };
- if (data) {
- options.data = type === 'GET' ? data : JSON.stringify(data);
- }
- return jQuery.ajax(options);
- }
-
- window.API = {
- plugin_install: (download_url) =>
- makeRequest(
- 'POST',
- `plugin-install`,
- {
- download_url: download_url,
- },
- `dt-admin-settings/`,
- ),
-
- plugin_delete: (plugin_slug) =>
- makeRequest(
- 'POST',
- `plugin-delete`,
- {
- plugin_slug: plugin_slug,
- },
- `dt-admin-settings/`,
- ),
-
- plugin_activate: (plugin_slug) =>
- makeRequest(
- 'POST',
- `plugin-activate`,
- {
- plugin_slug: plugin_slug,
- },
- `dt-admin-settings/`,
- ),
-
- plugin_deactivate: (plugin_slug) =>
- makeRequest(
- 'POST',
- `plugin-deactivate`,
- {
- plugin_slug: plugin_slug,
- },
- `dt-admin-settings/`,
- ),
- };
-
function get_plugin_download_url(plugin_slug) {
const all_plugins = window.plugins.all_plugins;
var download_url = false;
@@ -262,7 +198,8 @@ jQuery(function ($) {
function plugin_install(plugin_slug) {
var download_url = get_plugin_download_url(plugin_slug);
- window.API.plugin_install(download_url)
+ window.dt_admin_shared
+ .plugin_install(download_url)
.promise()
.then(function (response) {
if (!response) {
@@ -284,7 +221,8 @@ jQuery(function ($) {
}
function plugin_delete(plugin_slug) {
- window.API.plugin_delete(plugin_slug)
+ window.dt_admin_shared
+ .plugin_delete(plugin_slug)
.promise()
.then(function (response) {
if (!response) {
@@ -303,7 +241,8 @@ jQuery(function ($) {
}
function plugin_activate(plugin_slug) {
- window.API.plugin_activate(plugin_slug)
+ window.dt_admin_shared
+ .plugin_activate(plugin_slug)
.promise()
.then(function (response) {
if (!response) {
@@ -322,7 +261,8 @@ jQuery(function ($) {
}
function plugin_deactivate(plugin_slug) {
let can_install_plugins = window.plugins.can_install_plugins;
- window.API.plugin_deactivate(plugin_slug)
+ window.dt_admin_shared
+ .plugin_deactivate(plugin_slug)
.promise()
.then(function (response) {
if (!response) {
diff --git a/dt-core/admin/js/dt-shared.js b/dt-core/admin/js/dt-shared.js
index bc4cd1219..84055fc24 100644
--- a/dt-core/admin/js/dt-shared.js
+++ b/dt-core/admin/js/dt-shared.js
@@ -4,6 +4,28 @@ shared scripts applicable to all sections.
*/
'use strict';
+function makeRequest(type, url, data, base = 'dt/v1/') {
+ // Add trailing slash if missing
+ if (!base.endsWith('/') && !url.startsWith('/')) {
+ base += '/';
+ }
+ const options = {
+ type: type,
+ contentType: 'application/json; charset=utf-8',
+ dataType: 'json',
+ url: url.startsWith('http')
+ ? url
+ : `${window.wpApiSettings.root}${base}${url}`,
+ beforeSend: (xhr) => {
+ xhr.setRequestHeader('X-WP-Nonce', window.wpApiSettings.nonce);
+ },
+ };
+ if (data) {
+ options.data = type === 'GET' ? data : JSON.stringify(data);
+ }
+ return jQuery.ajax(options);
+}
+
window.dt_admin_shared = {
escape(str) {
if (typeof str !== 'string') return str;
@@ -14,6 +36,85 @@ window.dt_admin_shared = {
.replace(/"/g, '"')
.replace(/'/g, ''');
},
+
+ /**
+ * Update options. Provide an object with the options to update.
+ * @param options
+ */
+ update_dt_options: (options) =>
+ makeRequest('POST', 'update-dt-options', options, 'dt-admin-settings/'),
+
+ plugin_install: (download_url) =>
+ makeRequest(
+ 'POST',
+ `plugin-install`,
+ {
+ download_url: download_url,
+ },
+ `dt-admin-settings/`,
+ ),
+
+ plugin_delete: (plugin_slug) =>
+ makeRequest(
+ 'POST',
+ `plugin-delete`,
+ {
+ plugin_slug: plugin_slug,
+ },
+ `dt-admin-settings/`,
+ ),
+
+ plugin_activate: (plugin_slug) =>
+ makeRequest(
+ 'POST',
+ `plugin-activate`,
+ {
+ plugin_slug: plugin_slug,
+ },
+ `dt-admin-settings/`,
+ ),
+
+ plugin_deactivate: (plugin_slug) =>
+ makeRequest(
+ 'POST',
+ `plugin-deactivate`,
+ {
+ plugin_slug: plugin_slug,
+ },
+ `dt-admin-settings/`,
+ ),
+ modules_update: (modules) =>
+ makeRequest(
+ 'POST',
+ 'modules-update',
+ {
+ modules,
+ },
+ `dt-admin-settings/`,
+ ),
+ people_groups_get: (country) =>
+ makeRequest(
+ 'POST',
+ 'search_csv',
+ { s: country, as_object: true },
+ 'dt/v1/people-groups',
+ ),
+ people_groups_install: (data) =>
+ makeRequest('POST', 'add_single_people_group', data, 'dt/v1/people-groups'),
+ people_groups_get_batches: () =>
+ makeRequest(
+ 'GET',
+ 'get_bulk_people_groups_import_batches',
+ {},
+ 'dt/v1/people-groups',
+ ),
+ people_groups_install_batch: (groups) =>
+ makeRequest(
+ 'POST',
+ 'add_bulk_people_groups',
+ { groups },
+ 'dt/v1/people-groups',
+ ),
};
jQuery(function ($) {
diff --git a/dt-core/admin/menu/menu-setup-wizard.php b/dt-core/admin/menu/menu-setup-wizard.php
new file mode 100644
index 000000000..46c995877
--- /dev/null
+++ b/dt-core/admin/menu/menu-setup-wizard.php
@@ -0,0 +1,317 @@
+ [
+ 'title' => esc_html__( 'Disciple.Tools Setup Wizard', 'disciple_tools' ),
+ 'next' => esc_html__( 'Next', 'disciple_tools' ),
+ 'submit' => esc_html__( 'Submit', 'disciple_tools' ),
+ 'confirm' => esc_html__( 'Confirm', 'disciple_tools' ),
+ 'back' => esc_html__( 'Back', 'disciple_tools' ),
+ 'skip' => esc_html__( 'Skip', 'disciple_tools' ),
+ 'finish' => esc_html__( 'Finish', 'disciple_tools' ),
+ 'exit' => esc_html__( 'Exit', 'disciple_tools' ),
+ ],
+ 'steps' => $this->setup_wizard_steps(),
+ 'data' => $this->setup_wizard_data(),
+ 'admin_url' => admin_url(),
+ 'image_url' => trailingslashit( get_template_directory_uri() ) . 'dt-assets/images/',
+ 'can_install_plugins' => current_user_can( 'install_plugins' ),
+ ] );
+ }
+
+ public function dt_setup_wizard_items( $items ){
+
+ $is_completed = !empty( get_option( 'dt_setup_wizard_completed' ) );
+ $is_administrator = current_user_can( 'manage_options' );
+
+ $setup_wizard_step = [
+ 'label' => 'Setup Wizard',
+ 'description' => 'D.T. can be used in many ways from managing connections and relationships, all the way through to tracking and managing a movement of Disciple Making. In order to help you, we want to take you through a series of choices to give you the best start at getting Disciple.Tools setup ready to suit your needs.',
+ 'link' => esc_url( admin_url( 'admin.php?page=dt_setup_wizard' ) ),
+ 'complete' => $is_completed || !$is_administrator,
+ 'hide_mark_done' => true
+ ];
+
+ return [
+ 'getting_started' => $setup_wizard_step,
+ ...$items,
+ ];
+ }
+
+ public function has_access_permission() {
+ return !current_user_can( 'manage_dt' );
+ }
+
+ public function filter_script_loader_tag( $tag, $handle ) {
+ if ( str_starts_with( $handle, 'setup-wizard' ) ) {
+ $tag = preg_replace( '/(.*)(><\/script>)/', '$1 type="module"$2', $tag );
+ }
+ return $tag;
+ }
+
+ public function add_dt_options_menu() {
+ if ( $this->has_access_permission() ) {
+ return;
+ }
+
+ $image_url = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNDUwLjY0IDQzMS41NCI+CiAgPGRlZnM+CiAgICA8c3R5bGU+CiAgICAgIC5jbHMtMSB7CiAgICAgICAgZmlsbDogIzhiYzM0YTsKICAgICAgfQoKICAgICAgLmNscy0yIHsKICAgICAgICBmaWxsOiB1cmwoI2xpbmVhci1ncmFkaWVudCk7CiAgICAgIH0KICAgIDwvc3R5bGU+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImxpbmVhci1ncmFkaWVudCIgeDE9IjIyNS4zMyIgeTE9IjI0My44IiB4Mj0iNDUwLjY0IiB5Mj0iMjQzLjgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KICAgICAgPHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjMWQxZDFiIi8+CiAgICAgIDxzdG9wIG9mZnNldD0iLjQ3IiBzdG9wLWNvbG9yPSIjOGJjMzRhIi8+CiAgICAgIDxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzhiYzM0YSIvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICA8L2RlZnM+CiAgPGcgaWQ9IkxheWVyXzEtMiIgZGF0YS1uYW1lPSJMYXllciAxIj4KICAgIDxnPgogICAgICA8cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNDUwLjY0IDQzMS41NCAzNzUuNTQgNDMxLjU0IDIyNS4zMyAxMTcuMjcgMjU0LjU5IDU2LjA1IDQ1MC42NCA0MzEuNTQiLz4KICAgICAgPHBvbHlnb24gY2xhc3M9ImNscy0xIiBwb2ludHM9IjI1NC41OSA1Ni4wNSAyMjUuMzMgMTE3LjI3IDIyNS4zMiAxMTcuMjcgNzUuMTEgNDMxLjU0IDAgNDMxLjU0IDI5LjM1IDM3NS4zMyAyMDUuMyAzOC4zNSAyMjUuMzIgMCAyNDQuMzQgMzYuNDMgMjU0LjU5IDU2LjA1Ii8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4=';
+ add_menu_page(
+ __( 'Setup Wizard (D.T)', 'disciple_tools' ),
+ __( 'Setup Wizard (D.T)', 'disciple_tools' ),
+ 'manage_dt',
+ 'dt_setup_wizard',
+ [ $this, 'content' ],
+ $image_url,
+ 52,
+ );
+ /* Hide the setup wizard in the menu */
+ remove_menu_page( 'dt_setup_wizard' );
+ }
+
+ public function content() {
+ if ( $this->has_access_permission() ) {
+ wp_die( 'You do not have sufficient permissions to access this page.' );
+ }
+
+ ?>
+
+
+
+
+
+ 'intro',
+ 'name' => 'Intro',
+ 'component' => 'setup-wizard-intro',
+ ],
+ [
+ 'key' => 'choose_your_use_cases',
+ 'name' => 'Use cases',
+ 'component' => 'setup-wizard-use-cases',
+ 'description' => 'How are you planning to use DT?',
+ 'config' => [
+ 'crm',
+ 'media',
+ 'dmm',
+ ]
+ ],
+ [
+ 'key' => 'choose_your_modules',
+ 'name' => 'Modules',
+ 'component' => 'setup-wizard-modules',
+ 'description' => 'What modules do you want to use?',
+ ],
+ [
+ 'key' => 'plugins',
+ 'name' => 'Plugins',
+ 'description' => 'Choose which plugins to install.',
+ 'component' => 'setup-wizard-plugins',
+ ],
+ [
+ 'key' => 'site_keys',
+ 'name' => 'Site keys',
+ 'description' => 'Fill in some site details',
+ 'component' => 'setup-wizard-keys',
+ 'config' => [
+ 'dt_google_map_key' => Disciple_Tools_Google_Geocode_API::get_key(),
+ 'dt_mapbox_api_key' => DT_Mapbox_API::get_key(),
+ ],
+ ],
+ [
+ 'key' => 'people_groups',
+ 'name' => 'People Groups',
+ 'description' => 'Install desired people groups data',
+ 'component' => 'setup-wizard-people-groups',
+ 'disabled' => true,
+ 'config' => [
+ 'countries' => Disciple_Tools_People_Groups::get_country_dropdown(),
+ ],
+ ],
+ [
+ 'key' => 'celebration',
+ 'name' => 'Finished',
+ 'component' => 'setup-wizard-celebration',
+ ]
+ ];
+
+ $steps = apply_filters( 'dt_setup_wizard_steps', $steps );
+
+ return $steps;
+ }
+
+ public static function get_plugins_list(){
+ $dt_plugins = Disciple_Tools_Tab_Featured_Extensions::get_dt_plugins();
+ $enabled_plugins = [
+ 'disciple-tools-dashboard',
+ 'disciple-tools-webform',
+ 'disciple-tools-facebook',
+ 'disciple-tools-import',
+ 'disciple-tools-bulk-magic-link-sender',
+ 'disciple-tools-team-module',
+ 'disciple-tools-storage',
+ 'disciple-tools-prayer-campaigns',
+ ];
+ if ( is_multisite() ){
+ $enabled_plugins[] = 'disciple-tools-multisite';
+ }
+ //dt-home
+ //auto assignment
+ //share app
+
+
+ $plugin_data = [];
+ foreach ( $dt_plugins as $plugin ) {
+ if ( in_array( $plugin->slug, $enabled_plugins, true ) ) {
+ $plugin_data[] = $plugin;
+ }
+ }
+ return $plugin_data;
+ }
+
+
+ public function setup_wizard_data() : array {
+ $modules = dt_get_option( 'dt_post_type_modules' );
+ $plugin_data = self::get_plugins_list();
+ $data = [
+ 'use_cases' => [
+ 'crm' => [
+ 'key' => 'crm',
+ 'name' => 'Simple Setup - Relationship Manager',
+ 'description' => 'Launch people ( seekers or believers ) on a journey that leads
+ them closer to Christ. Set up your own fields, integrations and workflows to
+ track them as them go.',
+ 'recommended_modules' => [],
+ 'recommended_plugins' => [
+ 'disciple-tools-webform',
+ 'disciple-tools-import',
+ 'disciple-tools-bulk-magic-link-sender',
+ ],
+ ],
+ 'media' => [
+ 'key' => 'media',
+ 'name' => 'Media or Follow-up Ministry',
+ 'description' => 'Do you find seekers through media or through events
+ or trainings? Let your team(s) steward these leads, letting none fall
+ through the cracks and inviting them into deeper relationships
+ with God and others.',
+ 'recommended_modules' => [
+ 'access_module',
+ 'contacts_faith_module',
+ 'contacts_baptisms_module',
+ ],
+ 'recommended_plugins' => [
+ 'disciple-tools-webform',
+ 'disciple-tools-facebook',
+ 'disciple-tools-dashboard',
+ 'disciple-tools-import',
+ 'disciple-tools-bulk-magic-link-sender',
+ ],
+ ],
+ 'dmm' => [
+ 'key' => 'dmm',
+ 'name' => 'Church Growth and Disciple Making',
+ 'description' => 'Invest in the growth of individuals and churches as they multiply.
+ Monitor church health and track individuals through coaching and faith milestones.',
+ 'recommended_modules' => [
+ 'contacts_baptisms_module',
+ 'contacts_faith_module',
+ 'groups_base',
+ 'people_groups_module'
+ ],
+ 'recommended_plugins' => [
+ 'disciple-tools-webform',
+ 'disciple-tools-bulk-magic-link-sender',
+ 'disciple-tools-training',
+ 'disciple-tools-import',
+ ],
+ ],
+ ],
+ 'modules' => $modules,
+ 'plugins' => $plugin_data,
+ ];
+
+ $data = apply_filters( 'dt_setup_wizard_data', $data );
+
+ return $data;
+ }
+}
+DT_Setup_Wizard::instance();
diff --git a/dt-core/admin/menu/tabs/tab-featured-extensions.php b/dt-core/admin/menu/tabs/tab-featured-extensions.php
index f9261d3f6..3b5e7c5f3 100644
--- a/dt-core/admin/menu/tabs/tab-featured-extensions.php
+++ b/dt-core/admin/menu/tabs/tab-featured-extensions.php
@@ -232,7 +232,7 @@ public function box_message( $tab ) {
blog_url = 'https://disciple.tools/plugins/' . $plugin->slug;
$plugin->folder_name = get_home_path() . 'wp-content/plugins/' . $plugin->slug;
$plugin->author_github_username = explode( '/', $plugin->homepage )[3];
- $plugin->description = count_chars( $plugin->description ) > 128 ? trim( substr( $plugin->description, 0, 128 ) ) . '...' : $plugin->description; // Shorten descriptions to 88 chars
$plugin->icon = ! isset( $plugin->icon ) ? 'https://s.w.org/plugins/geopattern-icon/' . $plugin->slug . '.svg' : $plugin->icon;
$plugin->name = str_replace( 'Disciple Tools - ', '', $plugin->name );
$plugin->name = str_replace( 'Disciple.Tools - ', '', $plugin->name );
@@ -320,13 +319,13 @@ public function get_dt_plugins() {
$plugin->active = false;
$plugin->activation_path = '';
- if ( $this->partial_array_search( $all_plugins, $plugin->slug ) !== -1 ) {
+ if ( self::partial_array_search( $all_plugins, $plugin->slug ) !== -1 ) {
$plugin->installed = true;
}
- if ( $this->partial_array_search( $active_plugins, $plugin->slug ) !== -1 ) {
+ if ( self::partial_array_search( $active_plugins, $plugin->slug ) !== -1 ) {
$plugin->active = true;
- $plugin->activation_path = $this->partial_array_search( $active_plugins, $plugin->slug );
+ $plugin->activation_path = self::partial_array_search( $active_plugins, $plugin->slug );
}
}
return $plugins;
diff --git a/dt-core/configuration/class-migration-engine.php b/dt-core/configuration/class-migration-engine.php
index 4d903e2c9..01797ba31 100644
--- a/dt-core/configuration/class-migration-engine.php
+++ b/dt-core/configuration/class-migration-engine.php
@@ -12,7 +12,7 @@
class Disciple_Tools_Migration_Engine
{
- public static $migration_number = 59;
+ public static $migration_number = 60;
protected static $migrations = null;
diff --git a/dt-core/configuration/config-site-defaults.php b/dt-core/configuration/config-site-defaults.php
index feec9d936..8b8a9e656 100644
--- a/dt-core/configuration/config-site-defaults.php
+++ b/dt-core/configuration/config-site-defaults.php
@@ -135,8 +135,6 @@ function dt_get_option( string $name ) {
}
return get_option( 'dt_site_options' );
- break;
-
case 'dt_site_custom_lists':
$default_custom_lists = dt_get_site_custom_lists();
@@ -154,7 +152,6 @@ function dt_get_option( string $name ) {
}
//return apply_filters( "dt_site_custom_lists", get_option( 'dt_site_custom_lists' ) );
return get_option( 'dt_site_custom_lists' );
- break;
case 'dt_field_customizations':
return get_option( 'dt_field_customizations', [
@@ -192,8 +189,6 @@ function dt_get_option( string $name ) {
else {
return get_option( 'dt_base_user' );
}
- break;
-
case 'location_levels':
$default_levels = dt_get_location_levels();
@@ -216,7 +211,6 @@ function dt_get_option( string $name ) {
$levels = get_option( 'dt_location_levels' );
}
return $levels['location_levels'];
- break;
case 'auto_location':
$setting = get_option( 'dt_auto_location' );
if ( false === $setting ) {
@@ -224,8 +218,6 @@ function dt_get_option( string $name ) {
$setting = get_option( 'dt_auto_location' );
}
return $setting;
- break;
-
case 'dt_storage_connection_id':
return get_option( 'dt_storage_connection_id', '' );
@@ -235,8 +227,6 @@ function dt_get_option( string $name ) {
update_option( 'dt_email_base_subject', 'Disciple.Tools' );
}
return $subject_base;
- break;
-
case 'dt_email_base_address_reply_to':
return get_option( 'dt_email_base_address_reply_to', '' );
case 'dt_email_base_address':
@@ -282,7 +272,6 @@ function dt_get_option( string $name ) {
default:
return false;
- break;
}
}
@@ -313,15 +302,11 @@ function dt_update_option( $name, $value, $autoload = false ) {
$levels = wp_parse_args( $levels, $default_levels );
return update_option( 'dt_location_levels', $levels, $autoload );
-
- break;
case 'auto_location':
return update_option( 'dt_auto_location', $value, $autoload );
- break;
default:
return false;
- break;
}
}
diff --git a/dt-core/migrations/0060-setup-wizard-only-new.php b/dt-core/migrations/0060-setup-wizard-only-new.php
new file mode 100644
index 000000000..ef3b7a721
--- /dev/null
+++ b/dt-core/migrations/0060-setup-wizard-only-new.php
@@ -0,0 +1,28 @@
+= 60 ){
+ return;
+ }
+
+ update_option( 'dt_setup_wizard_completed', true );
+ }
+
+ public function down() {
+ }
+
+ public function test() {
+ }
+
+ public function get_expected_tables(): array {
+ return [];
+ }
+}
diff --git a/dt-groups/groups.php b/dt-groups/groups.php
index 9ba708d5d..ee202502b 100644
--- a/dt-groups/groups.php
+++ b/dt-groups/groups.php
@@ -7,7 +7,7 @@
'locked' => false,
'prerequisites' => [ 'contacts_base' ],
'post_type' => 'groups',
- 'description' => 'Default group functionality'
+ 'description' => 'Track church health and generational growth'
];
return $modules;
}, 20, 1 );
diff --git a/dt-people-groups/people-groups-base.php b/dt-people-groups/people-groups-base.php
index 91a955652..0edb2660a 100644
--- a/dt-people-groups/people-groups-base.php
+++ b/dt-people-groups/people-groups-base.php
@@ -5,11 +5,11 @@
add_filter( 'dt_post_type_modules', function( $modules ){
$modules['people_groups_module'] = [
- 'name' => 'People Groups Module',
+ 'name' => 'People Groups',
'enabled' => true,
'prerequisites' => [],
'post_type' => 'peoplegroups',
- 'description' => 'Enables people groups'
+ 'description' => 'Create your own people groups or use Joshua Project data. Link your contacts and groups to their people group.',
];
return $modules;
}, 20, 1 );
diff --git a/dt-people-groups/people-groups-endpoints.php b/dt-people-groups/people-groups-endpoints.php
index 799060894..aae6bd59b 100644
--- a/dt-people-groups/people-groups-endpoints.php
+++ b/dt-people-groups/people-groups-endpoints.php
@@ -134,8 +134,12 @@ public function get_people_groups_compact( WP_REST_Request $request ) {
public function search_csv( WP_REST_Request $request ) {
$params = $request->get_params();
+ $as_object = false;
+ if ( isset( $params['as_object'] ) ) {
+ $as_object = true;
+ }
if ( isset( $params['s'] ) ) {
- $people_groups = Disciple_Tools_People_Groups::search_csv( $params['s'] );
+ $people_groups = Disciple_Tools_People_Groups::search_csv( $params['s'], $as_object );
return $people_groups;
} else {
return new WP_Error( __METHOD__, 'Missing required parameter `s`' );
diff --git a/dt-people-groups/people-groups.php b/dt-people-groups/people-groups.php
index 0a116b200..9ba45fe42 100644
--- a/dt-people-groups/people-groups.php
+++ b/dt-people-groups/people-groups.php
@@ -49,16 +49,21 @@ public static function get_imb_source() {
return $imb_csv;
}
- public static function search_csv( $search ) { // gets a list by country
+ public static function search_csv( $search, $as_object = false ) { // gets a list by country
if ( ! current_user_can( 'manage_dt' ) ) {
return new WP_Error( __METHOD__, 'Insufficient permissions', [] );
}
$data = self::get_jp_source();
+ $columns = [ ...$data[0], 'duplicate' ];
$result = [];
foreach ( $data as $row ) {
if ( $row[1] === $search ) {
$row[] = ( self::duplicate_db_checker_by_rop3( $row[1], $row[3] ) > 0 );
- $result[] = $row;
+ if ( $as_object === true ) {
+ $result[] = array_combine( $columns, $row );
+ } else {
+ $result[] = $row;
+ }
}
}
return $result;
diff --git a/functions.php b/functions.php
index c6c3a2de3..5ce06506e 100755
--- a/functions.php
+++ b/functions.php
@@ -87,6 +87,19 @@ function dt_theme_load() {
} catch ( Throwable $e ) {
new WP_Error( 'migration_error', 'Migration engine failed to migrate.', [ 'message' => $e->getMessage() ] );
}
+
+ $is_rest = dt_is_rest();
+
+ /**
+ * Redirect to setup wizard if not seen
+ */
+ $setup_wizard_completed = get_option( 'dt_setup_wizard_completed' );
+ $setup_wizard_completed = apply_filters( 'dt_setup_wizard_completed', $setup_wizard_completed );
+ $current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
+ $is_administrator = current_user_can( 'manage_options' );
+ if ( !$is_rest && !is_network_admin() && !wp_doing_cron() && !$setup_wizard_completed && $is_administrator && $current_page !== 'dt_setup_wizard' ) {
+ wp_redirect( admin_url( 'admin.php?page=dt_setup_wizard' ) );
+ }
} );
/**
@@ -229,8 +242,10 @@ public function __construct() {
require_once( 'dt-core/multisite.php' );
require_once( 'dt-core/global-functions.php' );
require_once( 'dt-core/utilities/loader.php' );
+
$is_rest = dt_is_rest();
$url_path = dt_get_url_path();
+
require_once( 'dt-core/libraries/posts-to-posts/posts-to-posts.php' ); // P2P library/plugin. Required before DT instance
require_once( 'dt-core/libraries/wp-queue/wp-queue.php' ); //w
if ( !class_exists( 'Jwt_Auth' ) ) {
@@ -496,6 +511,7 @@ public function __construct() {
/* Note: The load order matters for the menus and submenus. Submenu must load after menu. */
require_once( 'dt-core/admin/menu/tabs/abstract-tabs-base.php' ); // registers all the menu pages and tabs
require_once( 'dt-core/admin/menu/menu-settings.php' );
+ require_once( 'dt-core/admin/menu/menu-setup-wizard.php' );
require_once( 'dt-core/admin/menu/menu-extensions.php' );
require_once( 'dt-core/admin/menu/tabs/tab-featured-extensions.php' );