| 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_ajax_nopriv_wppm_sign_in',array($this,'wppm_sign_in')); |
| 17 |
add_action('wp_ajax_nopriv_wppm_set_user_login',array($this,'wppm_set_user_login')); |
| 18 |
} |
| 19 |
|
| 20 |
// Load scripts |
| 21 |
public function loadScripts(){ |
| 22 |
//bootstrap |
| 23 |
wp_register_style('wppm-bootstrap-css', WPPM_PLUGIN_URL.'asset/css/wppm_bootstrap.css?version='.WPPM_VERSION ); |
| 24 |
//admin scripts |
| 25 |
wp_register_script('wppm-admin', WPPM_PLUGIN_URL.'asset/js/admin.js?version='.WPPM_VERSION, array('jquery')); |
| 26 |
wp_register_script('wppm-public', WPPM_PLUGIN_URL.'asset/js/public.js?version='.WPPM_VERSION, array('jquery')); |
| 27 |
wp_register_script('wppm-modal', WPPM_PLUGIN_URL.'asset/js/modal.js?version='.WPPM_VERSION, array('jquery')); |
| 28 |
wp_register_script('wppm-flatpickr-js', WPPM_PLUGIN_URL.'asset/lib/flatpickr/flatpickr.js?version='.WPPM_VERSION, array('jquery')); |
| 29 |
wp_register_script('wppm-select2-js', WPPM_PLUGIN_URL.'asset/lib/select2/select2.min.js?version='.WPPM_VERSION, array('jquery')); |
| 30 |
wp_register_script('wppm-gpopover-js', WPPM_PLUGIN_URL.'asset/lib/gpopover/jquery.gpopover.js?version='.WPPM_VERSION, array('jquery')); |
| 31 |
wp_register_script('wppm-dragula-js', WPPM_PLUGIN_URL.'asset/lib/dragula/dragula.min.js?version='.WPPM_VERSION, array('jquery')); |
| 32 |
wp_register_script('wppm-datatable-js', WPPM_PLUGIN_URL.'asset/lib/DataTables/datatables.min.js?version='.WPPM_VERSION, array('jquery')); |
| 33 |
wp_register_style('wppm-public-css', WPPM_PLUGIN_URL . 'asset/css/public.css?version='.WPPM_VERSION ); |
| 34 |
wp_register_style('wppm-admin-css', WPPM_PLUGIN_URL . 'asset/css/admin.css?version='.WPPM_VERSION ); |
| 35 |
wp_register_style('wppm-modal-css', WPPM_PLUGIN_URL . 'asset/css/modal.css?version='.WPPM_VERSION ); |
| 36 |
wp_register_style('wppm-flatpickr-css', WPPM_PLUGIN_URL . 'asset/lib/flatpickr/flatpickr.min.css?version='.WPPM_VERSION ); |
| 37 |
wp_register_style('wppm-select2-css', WPPM_PLUGIN_URL . 'asset/lib/select2/select2.min.css?version='.WPPM_VERSION ); |
| 38 |
wp_register_style('wppm-gpopover-css', WPPM_PLUGIN_URL . 'asset/lib/gpopover/jquery.gpopover.css?version='.WPPM_VERSION ); |
| 39 |
wp_register_style('wppm-dragula-css', WPPM_PLUGIN_URL . 'asset/lib/dragula/dragula.min.css?version='.WPPM_VERSION ); |
| 40 |
wp_register_script('wppm-datatable-js',WPPM_PLUGIN_URL.'asset/lib/DataTables/datatables.min.js?version='.WPPM_VERSION, array('jquery')); |
| 41 |
wp_register_style('wppm-datatable-css',WPPM_PLUGIN_URL.'asset/lib/DataTables/datatables.min.css?version='.WPPM_VERSION ); |
| 42 |
//localize script |
| 43 |
$loading_html = '<div class="wppm_loading_icon"><img src="'.WPPM_PLUGIN_URL.'asset/images/ajax-loading.gif"></div>'; |
| 44 |
$wppm_rich_text_editor = get_option('wppm_rich_text_editor'); |
| 45 |
$localize_script_data = apply_filters( 'wppm_public_localize_script', array( |
| 46 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 47 |
'loading_html' => $loading_html, |
| 48 |
'please_wait' =>esc_html__('Please wait ...','taskbuilder'), |
| 49 |
'confirm' =>esc_html__('Are you sure?','taskbuilder'), |
| 50 |
'auth_code' => isset($_REQUEST['auth-code'])? sanitize_text_field(wp_unslash($_REQUEST['auth-code'])) :"", |
| 51 |
'rich_text_editor' => !empty($wppm_rich_text_editor) ? (int) $wppm_rich_text_editor : 0 |
| 52 |
|
| 53 |
)); |
| 54 |
wp_localize_script( 'wppm-public', 'wppm_admin', $localize_script_data ); |
| 55 |
do_action('wppm_after_enqueue_script',$localize_script_data); |
| 56 |
} |
| 57 |
/** |
| 58 |
* Main shortcode |
| 59 |
*/ |
| 60 |
|
| 61 |
function wppm_projects(){ |
| 62 |
ob_start(); |
| 63 |
include WPPM_ABSPATH.'includes/frontend/shortcode.php'; |
| 64 |
return ob_get_clean(); |
| 65 |
} |
| 66 |
|
| 67 |
function wppm_tasks($attr){ |
| 68 |
ob_start(); |
| 69 |
include WPPM_ABSPATH.'includes/frontend/wppm_tasks_shortcode.php'; |
| 70 |
return ob_get_clean(); |
| 71 |
} |
| 72 |
|
| 73 |
function wppm_sign_in(){ |
| 74 |
include WPPM_ABSPATH.'includes/frontend/wppm_sign_in.php'; |
| 75 |
die(); |
| 76 |
} |
| 77 |
|
| 78 |
function wppm_set_user_login(){ |
| 79 |
include WPPM_ABSPATH.'includes/frontend/wppm_set_user_login.php'; |
| 80 |
} |
| 81 |
|
| 82 |
function wppm_public_projects_tasks(){ |
| 83 |
ob_start(); |
| 84 |
include WPPM_ABSPATH.'includes/frontend/wppm_public_projects_tasks.php'; |
| 85 |
return ob_get_clean(); |
| 86 |
} |
| 87 |
|
| 88 |
} |
| 89 |
endif; |
| 90 |
|
| 91 |
new WPPM_Frontend(); |