Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D.T theme and plugins loading order #2478

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dt-core/configuration/dt-configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Hooks and configurations that customize wordpress for D.T
*/
nocache_headers();

add_action( 'init', 'dt_set_permalink_structure' );
add_action( 'update_option_permalink_structure', 'dt_permalink_structure_changed_callback' );
add_filter( 'comment_notification_recipients', 'dt_override_comment_notice_recipients', 10, 2 );
Expand Down
14 changes: 14 additions & 0 deletions dt-core/global-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,20 @@ function dt_label_from_slug( $slug ) {
}
}

/**
* AJAX handler to store the state of dismissible notices.
*/
if ( !function_exists( 'dt_hook_ajax_notice_handler' ) ){
function dt_hook_ajax_notice_handler(){
check_ajax_referer( 'wp_rest_dismiss', 'security' );
if ( isset( $_POST['type'] ) ){
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
update_option( 'dismissed-' . $type, true );
}
}
}
add_action( 'wp_ajax_dismissed_notice_handler', 'dt_hook_ajax_notice_handler' );

if ( !function_exists( 'dt_get_global_languages_list' ) ){
function dt_get_global_languages_list(){
/* You can find flags with country codes here https://unpkg.com/[email protected]/dist/country-flag-emoji.umd.js */
Expand Down
46 changes: 46 additions & 0 deletions dt-core/setup-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,50 @@ function dt_setup_roles_and_permissions(){
}
}
}
}

add_action( 'switch_blog', 'dt_set_up_wpdb_tables', 99, 2 );
function dt_set_up_wpdb_tables(){
global $wpdb;
$wpdb->dt_activity_log = $wpdb->prefix . 'dt_activity_log'; // Prepare database table names
$wpdb->dt_reports = $wpdb->prefix . 'dt_reports';
$wpdb->dt_reportmeta = $wpdb->prefix . 'dt_reportmeta';
$wpdb->dt_share = $wpdb->prefix . 'dt_share';
$wpdb->dt_notifications = $wpdb->prefix . 'dt_notifications';
$wpdb->dt_notifications_queue = $wpdb->prefix . 'dt_notifications_queue';
$wpdb->dt_post_user_meta = $wpdb->prefix . 'dt_post_user_meta';
$wpdb->dt_location_grid = $wpdb->prefix . 'dt_location_grid';
$wpdb->dt_location_grid_meta = $wpdb->prefix . 'dt_location_grid_meta';

$more_tables = apply_filters( 'dt_custom_tables', [] );
foreach ( $more_tables as $table ){
$wpdb->$table = $wpdb->prefix . $table;
}
}

/**
* Route Front Page depending on login role
*/
function dt_route_front_page() {
if ( current_user_can( 'access_disciple_tools' ) || current_user_can( 'access_contacts' ) ) {
/**
* Use this filter to add a new landing page for logged in users with 'access_contacts' capabilities
*/
if ( current_user_can( 'access_contacts' ) ){
wp_safe_redirect( apply_filters( 'dt_front_page', home_url( '/contacts' ) ) );
} else {
wp_safe_redirect( apply_filters( 'dt_front_page', home_url( '/settings' ) ) );
}
}
else if ( ! is_user_logged_in() ) {
dt_please_log_in();
}
else {
/**
* Use this filter to give a front page for logged in users who do not have basic 'access_contacts' capabilities
* This is used for specific custom roles that are not intended to see the basic framework of DT.
* Use this to create a dedicated landing page for partners, donors, or subscribers.
*/
wp_safe_redirect( apply_filters( 'dt_non_standard_front_page', home_url( '/registered' ) ) );
}
}
2 changes: 1 addition & 1 deletion dt-metrics/metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(){
$url_path = dt_get_url_path();
if ( strpos( $url_path, 'metrics' ) !== false ){
// wait for D.T post type classes to be set up before building metrics for them
add_action( 'after_setup_theme', function (){
add_action( 'disciple_tools_loaded', function (){
$modules = dt_get_option( 'dt_post_type_modules' );
// Personal
require_once( get_template_directory() . '/dt-metrics/personal/coaching-tree.php' );
Expand Down
Loading
Loading