File: /home/undanet/www/wp-content/themes/panoramic-child/functions.php
<?php
/** Load Lang
*/
function panoramic_child_theme_textdomain()
{
load_child_theme_textdomain(
'panoramic_child', get_stylesheet_directory() . '/languages'
);
}
add_action('after_setup_theme', 'panoramic_child_theme_textdomain');
/** Load Styles
*/
function panoramic_child_styles()
{
if (is_page_template('template-report.php')) {
wp_enqueue_style('panoramic_child_bootstrap_css', 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css');
wp_enqueue_style('panoramic_child_daterangepicker_css', 'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css');
wp_enqueue_style('panoramic_child_bootstrap_select_css', 'https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css');
wp_enqueue_style('panoramic_child_datatable_css', 'https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap4.min.css');
wp_enqueue_style('panoramic_child_datatable_css', 'https://cdn.datatables.net/buttons/2.3.2/css/buttons.dataTables.min.css');
}
wp_enqueue_style('child-theme-css', get_template_directory_uri() . '/style.css');
wp_enqueue_script('html2pdf', get_stylesheet_directory_uri() . '/js/html2pdf.bundle.min.js');
if (is_page_template('template-report.php')) {
//wp_enqueue_script( 'panoramic_child_bootstrap_slim_js', 'https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js', array('jquery') );
wp_enqueue_script('panoramic_child_bootstrap_js', 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js', ['jquery']);
wp_enqueue_script('panoramic_child_moments_js', 'https://cdn.jsdelivr.net/momentjs/latest/moment.min.js');
wp_enqueue_script('panoramic_child_daterangepicker_js', 'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js', [
'jquery', 'panoramic_child_moments_js',
'panoramic_child_bootstrap_js',
]);
wp_enqueue_script('panoramic_child_bootstrap_select_js', 'https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js', []);
wp_enqueue_script('panoramic_child_datatable_js', 'https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_js', 'https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap4.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_buttons_js', 'https://cdn.datatables.net/buttons/2.3.2/js/dataTables.buttons.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_jszip_js', 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_pdfmake_js', 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_fonts_js', 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_buttons_html5_js', 'https://cdn.datatables.net/buttons/2.3.2/js/buttons.html5.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_buttons_vis_js', 'https://cdn.datatables.net/buttons/1.5.1/js/buttons.colVis.min.js', []);
wp_enqueue_script('panoramic_child_bootstrap_datatable_print_js', 'https://cdn.datatables.net/buttons/2.3.2/js/buttons.print.min.js', []);
}
wp_enqueue_script(
'panoramic_child_scripts',
get_stylesheet_directory_uri() . '/js/panoramic_child_scripts.js',
['jquery', 'html2pdf',]
);
if (isset($_GET['id'])) {
$getid = (isset($_GET['id']))
? '?id=' . $_GET['id']
: '';
wp_localize_script('panoramic_child_scripts', 'panoramic_child_scripts_object', [
'getid' => $getid,
]);
}
wp_localize_script('panoramic_child_scripts', 'panoramic_child_scripts_params', [
'login_popup_title' => __('Login', 'panoramic_child'),
]);
}
add_action('wp_enqueue_scripts', 'panoramic_child_styles');
/** Custom Widgets
*/
function panoramic_child_widgets_init()
{
register_sidebar([
'name' => __('Rigth Top Bar', 'panoramic_child'),
'id' => 'sidebar-rtb',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s social-links">',
'after_widget' => '</aside>',
]);
register_sidebar([
'name' => __('Footer Left', 'panoramic_child'),
'id' => 'footer-lt',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
]);
register_sidebar([
'name' => __('Footer Center', 'panoramic_child'),
'id' => 'sidebar-cr',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
]);
register_sidebar([
'name' => __('Footer Rigth', 'panoramic_child'),
'id' => 'sidebar-rt',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
]);
}
add_action('widgets_init', 'panoramic_child_widgets_init');
/** change profile name
*/
function panoramic_child_cambiar_nombre_perfil()
{
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
$wp_roles->roles['editor']['name'] = 'RRHH';
$wp_roles->role_names['editor'] = 'RRHH';
}
add_action('init', 'panoramic_child_cambiar_nombre_perfil');
/** Shortcodes
*/
include_once get_theme_file_path() . '/inc/shortcodes.php';
/** Ajax functions
*/
include_once get_theme_file_path() . '/inc/ajax-functions.php';
/** other functions
*/
include_once get_theme_file_path() . '/inc/functions.php';
/*
* Change text Login Ultimat Member plugins
* */
remove_action('um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10);
function custom_um_submit_form_errors_hook_login($args)
{
$is_email = false;
$form_id = $args['form_id'];
$mode = $args['mode'];
$user_password = $args['user_password'];
if (isset($args['username']) && $args['username'] == '') {
UM()->form()->add_error(
'username', __('Please enter your username or email', 'ultimate-member')
);
}
if (isset($args['user_login']) && $args['user_login'] == '') {
UM()->form()->add_error(
'user_login', __('Please enter your username', 'ultimate-member')
);
}
if (isset($args['user_email']) && $args['user_email'] == '') {
UM()->form()->add_error(
'user_email', __('Please enter your email', 'ultimate-member')
);
}
if (isset($args['username'])) {
$authenticate = $args['username'];
$field = 'username';
if (is_email($args['username'])) {
$is_email = true;
$data = get_user_by('email', $args['username']);
$user_name = isset($data->user_login)
? $data->user_login
: null;
} else {
$user_name = $args['username'];
}
} elseif (isset($args['user_email'])) {
$authenticate = $args['user_email'];
$field = 'user_email';
$is_email = true;
$data = get_user_by('email', $args['user_email']);
$user_name = isset($data->user_login)
? $data->user_login
: null;
} else {
$field = 'user_login';
$user_name = $args['user_login'];
$authenticate = $args['user_login'];
}
if ($args['user_password'] == '') {
UM()->form()->add_error(
'user_password', __('Please enter your password', 'ultimate-member')
);
}
$user = get_user_by('login', $user_name);
if (
$user
&& wp_check_password($args['user_password'], $user->data->user_pass, $user->ID)
) {
UM()->login()->auth_id = username_exists($user_name);
} else {
UM()->form()->add_error(
'user_password', __('The username or password is incorrect. please try again.', 'ultimate-member')
);
}
// @since 4.18 replacement for 'wp_login_failed' action hook
// see WP function wp_authenticate()
$ignore_codes = ['empty_username', 'empty_password'];
$user =
apply_filters('authenticate', null, $authenticate, $args['user_password']);
if (
is_wp_error($user)
&& !in_array($user->get_error_code(), $ignore_codes)
) {
UM()->form()->add_error($user->get_error_code(),
__('The username or password is incorrect. please try again.', 'ultimate-member')
);
}
$user =
apply_filters('wp_authenticate_user', $user, $args['user_password']);
if (
is_wp_error($user)
&& !in_array($user->get_error_code(), $ignore_codes)
) {
UM()->form()->add_error($user->get_error_code(),
__('The username or password is incorrect. please try again.', 'ultimate-member'));
}
// if there is an error notify wp
if (
UM()->form()->has_error($field)
|| UM()->form()->has_error($user_password)
|| UM()->form()->count_errors() > 0
) {
do_action('wp_login_failed', $user_name, UM()->form()->get_wp_error());
}
}
add_action('um_submit_form_errors_hook_login', 'custom_um_submit_form_errors_hook_login', 10);
/** mail functions
*/
include_once get_theme_file_path() . '/inc/mail-functions.php';
/** mpdf functions
*/
include_once get_theme_file_path() . '/mpdf/mpdf.php';