-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmws-easyquote.php
More file actions
158 lines (145 loc) · 5.63 KB
/
mws-easyquote.php
File metadata and controls
158 lines (145 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/*
Plugin Name: Easy Quote
Plugin URI: https://github.com/MakeWebSmart/wp_mws_easyquote
Description: A simple WordPress OnePage Quote plugin by MakeWebSmart(mws)
Version: 0.9
Author: Azraf Anam
Author URI: http://azraf.me
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
add_action('wp_enqueue_scripts', 'mwseq_callback_scripts');
function mwseq_callback_scripts()
{
wp_register_style( 'mwseq_formcss', plugins_url('assets/form.css?t='.time(),__FILE__ ) );
wp_enqueue_style( 'mwseq_formcss' );
wp_enqueue_script( 'mwseq_jqueryeasinhg', plugins_url('assets/jquery.easing.min.js',__FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'mwseq_formjs', plugins_url('assets/form.js',__FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'mwseq_formprocess', plugins_url('assets/form-process-front.js',__FILE__ ), array( 'jquery' ) );
}
function mws_easy_quote_adminscripts()
{
wp_register_style('mwseq_bootstrapiso', plugins_url('assets/bootstrap-iso.css',__FILE__ ));
wp_enqueue_style('mwseq_bootstrapiso');
wp_enqueue_script( 'mwseq_jquerysortable', plugins_url('assets/jquery-sortable-min.js',__FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'mwseq_formprogress', plugins_url('assets/form-process.js',__FILE__ ), array( 'jquery' ) );
}
add_action( 'admin_init','mws_easy_quote_adminscripts');
function mws_easyquote_init()
{
if(is_page('easy-quote')){
mws_easyquote_frontpage();
}
}
function mws_easyquote_frontpage()
{
$dir = plugin_dir_path( __FILE__ );
include($dir."easy.php");
die();
}
add_action( 'wp', 'mws_easyquote_init' );
add_shortcode('MWS_EASYQUOTE', 'mws_easyquote_frontpage');
add_action('admin_menu', 'mws_easy_quote_menu');
function mws_easy_quote_menu()
{
add_menu_page(__('EasyQuote', 'easyquote'), __('EasyQuote', 'easyquote'), 'manage_options', 'mws_easyquote_admin', 'mws_easyquote_admin_page',plugins_url('easyquote.ico',__FILE__ ));
add_submenu_page('mws_easyquote_admin', 'List Models', 'Reorder Model List', 'manage_options', 'mws_easyquote_list', 'mws_easyquote_list_page');
add_submenu_page('mws_easyquote_admin', 'Options', 'EasyQuote Options', 'manage_options', 'mws_easyquote_options', 'mws_easyquote_options_page');
}
function mws_easyquote_admin_page()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
include_once dirname(__FILE__) . '/admin-quote.php';
}
function mws_easyquote_list_page()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
include_once dirname(__FILE__) . '/quote-list.php';
die();
}
function mws_easyquote_options_page()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
include_once dirname(__FILE__) . '/options-page.php';
}
if(!function_exists('mws_helpline')){
function mws_helpline()
{
echo '
<br /><br />
<div class="container">
<h4>Get in touch <span class="glyphicon glyphicon-send"></span> c.azraf@gmail.com</h4>
Send mail using:
<a target="_blank" href="https://mail.google.com/mail/?view=cm&fs=1&to=c.azraf@gmail.com&su=WP EasyQuote plugin help">Gmail</a> /
<a target="_blank" href="http://webmail.aol.com/Mail/ComposeMessage.aspx?to=c.azraf@gmail.com&subject=WP EasyQuote plugin help">AOL</a> /
<a target="_blank" href="http://compose.mail.yahoo.com/?to=c.azraf@gmail.com&subject=WP EasyQuote plugin help">Yahoo</a> /
<a target="_blank" href="http://mail.live.com/mail/EditMessageLight.aspx?n=&to=c.azraf@gmail.com&subject=WP EasyQuote plugin help">Outlook</a>
<br />
<a href="http://azraf.me">Profile</a> | <a href="http://fb.com/webazraf">FaceBook</a>
</div>';
}
}
/**
* Function for dump array or variables
*
* Only for testing purpose
*/
if(!function_exists('mwseq_d')){
function mwseq_d($var, $str = '')
{
if (!empty($str)) {
echo '<br />' . $str . '<br />';
}
echo '<pre>';
print_r($var);
echo '</pre>';
}
}
/**
* Sanitize all array items (e.g. post fields)
*
* $intArr: take array of integers to Integer type casting
* $delItems: omit items from return array
*
*/
if(!function_exists('mws_sanitize_items')){
function mws_sanitize_items($var,$intArr=[],$delItems=[])
{
if(is_array ($var)){
$ret = [];
// if exist _wpnonce, omit from return array
if(isset($var['_wpnonce'])){
unset($var['_wpnonce']);
}
// if exist _wp_http_referer, omit it from return array
if(isset($var['_wp_http_referer'])){
unset($var['_wp_http_referer']);
}
if(!empty($delItems)){
foreach($delItems as $del) {
unset($var[$del]);
}
}
foreach($var as $k=>$v){
if(!empty($intArr) && in_array($k,$intArr)){
if(!empty($v)){
$ret[$k] = intval($v);
} else {
$ret[$k] = '';
}
}else {
$ret[$k] = sanitize_text_field($v);
}
}
return $ret;
} else {
return sanitize_text_field($var);
}
}
}