| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
if ( ! class_exists( 'WPPM_Frontend' ) ) : |
| 7 |
|
| 8 |
final class WPPM_Frontend { |
| 9 |
|
| 10 |
// constructor |
| 11 |
public function __construct() { |
| 12 |
add_action( 'wp_enqueue_scripts', array( $this, 'loadScripts') ); |
| 13 |
add_shortcode( 'wppm_projects', array( $this, 'wppm_projects' ) ); |
| 14 |
add_shortcode( 'wppm_tasks', array( $this, 'wppm_tasks' ) ); |
| 15 |
add_shortcode( 'wppm_public_projects_tasks', array( $this, 'wppm_public_projects_tasks' ) ); |
| 16 |
add_action('wp_footer', array($this,'wppm_add_notification_container')); |
| 17 |
add_action('wp_ajax_nopriv_wppm_sign_in',array($this,'wppm_sign_in')); |
| 18 |
add_action('wp_ajax_nopriv_wppm_set_user_login',array($this,'wppm_set_user_login')); |
| 19 |
add_action('wp_ajax_wppm_get_notifications',array($this,'wppm_get_notifications_callback')); |
| 20 |
} |
| 21 |
|
| 22 |
// Load scripts |
| 23 |
public function loadScripts(){ |
| 24 |
$loading_html = '<div class="wppm_loading_icon"><img src="'.WPPM_PLUGIN_URL.'asset/images/ajax-loading.gif"></div>'; |
| 25 |
wp_register_script( |
| 26 |
'wppm-notification', |
| 27 |
WPPM_PLUGIN_URL . 'asset/js/notification.js', |
| 28 |
array( 'jquery' ), |
| 29 |
WPPM_VERSION, |
| 30 |
true |
| 31 |
); |
| 32 |
|
| 33 |
wp_localize_script( |
| 34 |
'wppm-notification', |
| 35 |
'wppm_notification', |
| 36 |
array( |
| 37 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 38 |
'nonce' => wp_create_nonce( 'wppm_notification_nonce' ), |
| 39 |
'loading_html' => $loading_html, |
| 40 |
) |
| 41 |
); |
| 42 |
wp_enqueue_script( 'wppm-notification' ); |
| 43 |
wp_enqueue_style( 'dashicons' ); |
| 44 |
//bootstrap |
| 45 |
wp_register_style('wppm-bootstrap-css', WPPM_PLUGIN_URL.'asset/css/wppm_bootstrap.css?version='.WPPM_VERSION ); |
| 46 |
//admin scripts |
| 47 |
wp_register_script('wppm-admin', WPPM_PLUGIN_URL.'asset/js/admin.js?version='.WPPM_VERSION, array('jquery')); |
| 48 |
wp_register_script('wppm-public', WPPM_PLUGIN_URL.'asset/js/public.js?version='.WPPM_VERSION, array('jquery')); |
| 49 |
wp_register_script('wppm-modal', WPPM_PLUGIN_URL.'asset/js/modal.js?version='.WPPM_VERSION, array('jquery')); |
| 50 |
wp_register_script('wppm-flatpickr-js', WPPM_PLUGIN_URL.'asset/lib/flatpickr/flatpickr.js?version='.WPPM_VERSION, array('jquery')); |
| 51 |
wp_register_script('wppm-select2-js', WPPM_PLUGIN_URL.'asset/lib/select2/select2.min.js?version='.WPPM_VERSION, array('jquery')); |
| 52 |
wp_register_script('wppm-gpopover-js', WPPM_PLUGIN_URL.'asset/lib/gpopover/jquery.gpopover.js?version='.WPPM_VERSION, array('jquery')); |
| 53 |
wp_register_script('wppm-dragula-js', WPPM_PLUGIN_URL.'asset/lib/dragula/dragula.min.js?version='.WPPM_VERSION, array('jquery')); |
| 54 |
wp_register_script('wppm-datatable-js', WPPM_PLUGIN_URL.'asset/lib/DataTables/datatables.min.js?version='.WPPM_VERSION, array('jquery')); |
| 55 |
wp_register_style('wppm-public-css', WPPM_PLUGIN_URL . 'asset/css/public.css?version='.WPPM_VERSION ); |
| 56 |
wp_register_style('wppm-admin-css', WPPM_PLUGIN_URL . 'asset/css/admin.css?version='.WPPM_VERSION ); |
| 57 |
wp_enqueue_style( 'wppm-admin-css' ); |
| 58 |
wp_register_style('wppm-modal-css', WPPM_PLUGIN_URL . 'asset/css/modal.css?version='.WPPM_VERSION ); |
| 59 |
wp_register_style('wppm-flatpickr-css', WPPM_PLUGIN_URL . 'asset/lib/flatpickr/flatpickr.min.css?version='.WPPM_VERSION ); |
| 60 |
wp_register_style('wppm-select2-css', WPPM_PLUGIN_URL . 'asset/lib/select2/select2.min.css?version='.WPPM_VERSION ); |
| 61 |
wp_register_style('wppm-gpopover-css', WPPM_PLUGIN_URL . 'asset/lib/gpopover/jquery.gpopover.css?version='.WPPM_VERSION ); |
| 62 |
wp_register_style('wppm-dragula-css', WPPM_PLUGIN_URL . 'asset/lib/dragula/dragula.min.css?version='.WPPM_VERSION ); |
| 63 |
wp_register_script('wppm-datatable-js',WPPM_PLUGIN_URL.'asset/lib/DataTables/datatables.min.js?version='.WPPM_VERSION, array('jquery')); |
| 64 |
wp_register_style('wppm-datatable-css',WPPM_PLUGIN_URL.'asset/lib/DataTables/datatables.min.css?version='.WPPM_VERSION ); |
| 65 |
//localize script |
| 66 |
$loading_html = '<div class="wppm_loading_icon"><img src="'.WPPM_PLUGIN_URL.'asset/images/ajax-loading.gif"></div>'; |
| 67 |
$wppm_rich_text_editor = get_option('wppm_rich_text_editor'); |
| 68 |
$localize_script_data = apply_filters( 'wppm_public_localize_script', array( |
| 69 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 70 |
'loading_html' => $loading_html, |
| 71 |
'please_wait' =>esc_html__('Please wait ...','taskbuilder'), |
| 72 |
'confirm' =>esc_html__('Are you sure?','taskbuilder'), |
| 73 |
'auth_code' => isset($_REQUEST['auth-code'])? sanitize_text_field(wp_unslash($_REQUEST['auth-code'])) :"", |
| 74 |
'rich_text_editor' => !empty($wppm_rich_text_editor) ? (int) $wppm_rich_text_editor : 0 |
| 75 |
|
| 76 |
)); |
| 77 |
wp_localize_script( 'wppm-public', 'wppm_admin', $localize_script_data ); |
| 78 |
do_action('wppm_after_enqueue_script',$localize_script_data); |
| 79 |
} |
| 80 |
/** |
| 81 |
* Main shortcode |
| 82 |
*/ |
| 83 |
|
| 84 |
function wppm_projects(){ |
| 85 |
ob_start(); |
| 86 |
include WPPM_ABSPATH.'includes/frontend/shortcode.php'; |
| 87 |
return ob_get_clean(); |
| 88 |
} |
| 89 |
|
| 90 |
function wppm_tasks($attr){ |
| 91 |
ob_start(); |
| 92 |
include WPPM_ABSPATH.'includes/frontend/wppm_tasks_shortcode.php'; |
| 93 |
return ob_get_clean(); |
| 94 |
} |
| 95 |
|
| 96 |
function wppm_sign_in(){ |
| 97 |
include WPPM_ABSPATH.'includes/frontend/wppm_sign_in.php'; |
| 98 |
die(); |
| 99 |
} |
| 100 |
|
| 101 |
function wppm_set_user_login(){ |
| 102 |
include WPPM_ABSPATH.'includes/frontend/wppm_set_user_login.php'; |
| 103 |
} |
| 104 |
|
| 105 |
function wppm_public_projects_tasks(){ |
| 106 |
ob_start(); |
| 107 |
include WPPM_ABSPATH.'includes/frontend/wppm_public_projects_tasks.php'; |
| 108 |
return ob_get_clean(); |
| 109 |
} |
| 110 |
|
| 111 |
public function wppm_get_notifications_callback(){ |
| 112 |
include WPPM_ABSPATH.'includes/admin/email_notifications/wppm_get_notifications.php'; |
| 113 |
die(); |
| 114 |
} |
| 115 |
|
| 116 |
public function wppm_add_notification_container(){ |
| 117 |
echo ' <div id="wppm_notification_bell"> |
| 118 |
<span class="dashicons dashicons-bell"></span> |
| 119 |
<span class="wppm-badge">0</span> |
| 120 |
</div> |
| 121 |
<div id="wppm-notification-container"></div>'; |
| 122 |
} |
| 123 |
|
| 124 |
} |
| 125 |
endif; |
| 126 |
|
| 127 |
new WPPM_Frontend(); |