Repository navigation
Expand file tree
/
Copy pathplugin-onboarding.php
More file actions
260 lines (215 loc) · 9.03 KB
/
Copy pathplugin-onboarding.php
File metadata and controls
260 lines (215 loc) · 9.03 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
/**
* Plugin Name: Onboarding ISCEB
*/
include 'ajaxHandler.php';
function afunction(){
add_menu_page(
__( 'Custom Menu Title', 'textdomain' ),
"Onboarding",
"manage_options",
"plugin-onboarding/dashboard.php",
);
}
add_action( 'admin_menu', 'afunction' );
// add_action('admin_init', 'myplugin_admin_init');
function add_my_plugin_stylesheet() {
// wp_register_style('mypluginstylesheet', '/wp-content/plugins/plugin-onboarding/onboarding.css');
// wp_enqueue_style('mypluginstylesheet');
// wp_register_style( 'namespace1', '/wp-content/plugins/plugin-onboarding/onboarding.css' );
// wp_enqueue_style( 'namespace1' );
wp_register_style( 'namespace2', '/wp-content/plugins/plugin-onboarding/interactive_timeline.css' );
wp_enqueue_style( 'namespace2' );
wp_register_style( 'namespace', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css' );
wp_enqueue_style( 'namespace' );
wp_register_script( 'my_script', '/wp-content/plugins/plugin-onboarding/interactive_timeline.js',array ('jquery'), time());
wp_enqueue_script(
'my_script',
plugins_url( 'interactive_timeline.js', __FILE__ ),
array( 'jquery' ),
time()
);
wp_localize_script( 'my_script', 'my_ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' ) )) ;
}
add_action('wp_enqueue_scripts', 'add_my_plugin_stylesheet');
add_action( 'wp_ajax_stagetest', 'my_ajax_handler' );
// MBA_STAGE1_METADTA = true
// MBA_STAGE2_METADTA = false
// ....
// MBA_STAGES = [stage1:true,...]
function wporg_custom_post_type() {
register_post_type('wp_stages',
array(
'labels' => array(
'name' => __('Stages', 'textdomain'),
'singular_name' => __('Stage', 'textdomain'),
),
'public' => true,
'has_archive' => true,
'show_ui' => true
)
);
}
add_action('init', 'wporg_custom_post_type');
function wpdocs_create_new_taxonomy() {
$labels = array(
'name' => _x('Onboarding flows','taxonomy general name' ,'textdomain'),
'singular_name' => _x('Onboarding flow','taxonomy singular name', 'textdomain'),
'add_new_item' => __( 'Add New Flow', 'textdomain' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
);
register_taxonomy('flow_taxonomy', array('wp_stages'), $args);
}
add_action('init','wpdocs_create_new_taxonomy', 0);
add_shortcode('flow', 'flow_function');
function flow_function($atts) {
if (is_user_logged_in ()) {
$stageStatus = get_user_meta(get_current_user_id(), 'stage 1', true);
if ($stageStatus == "true"){
echo '<input type="checkbox" id="chkbx" checked/> <textarea id="textbox1"></textarea>';
}
else{
echo '<input type="checkbox" id="chkbx"/> <textarea id="textbox1"></textarea>';
}
echo '<p>'. get_user_meta(get_current_user_id(), 'stage 1', true). '</p>';
add_user_meta (get_current_user_id(), 'stage 1', true, true);
// update_user_meta(get_current_user_id(), 'stage 1', 'stage 1');
$args = array(
'post_type' => 'wp_stages',
'tax_query' => array(
array(
'taxonomy' => 'flow_taxonomy',
'field' => 'name',
'terms' => $atts['name'],
),
),
'orderby' => 'CAST(title as CHAR)',
'order' => 'ASC',
// array('title' => 'DSC'),
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
switch ($atts['name']) {
/* BBA!!!!!*/
case 'BBA':
echo "<div class='onboarding_list' id='onboarding_list_{$atts['name']}'>";
echo'<div class="row">
<div class="col_md_12">
<div class="main_timeline">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '
<div class="timeline" id="stage1">
<div class="timeline_content">
<span class="timeline_stage">'. get_post_meta( get_the_ID() , 'subtitle', true ) .' </span>
<div class="timeline_icon">
<i class="fa fa-rocket"></i>
</div>
<div class="content">
<a href=" "> <h3 class="title">' . get_the_title() . '</h3> </a>
<p class="description">
in this website design tutorial i will guide you that how to create the amazing timeline design using the modern technologies cush as html 5 css 3 and no JavaScript. After
Completing this website design tutorial you will be having all the great skills for website design in no time. Hope this website design and web development tutorial will
</p>
</div>
</div>
</div>
';
}
echo ' </div>
</div>
</div> ';
echo '</div>';
break;
case 'MBA':
default:
add_user_meta (get_current_user_id(), 'stages_MBA', true, true);
echo
'<section class="timeline">
<div class="container">' ;
while ($the_query->have_posts() ) {
$the_query->the_post();
echo '<div class="timeline-item">
<div class="timeline-img"></div>
<div class="timeline-content js--fadeInLeft">
<h2>'. get_the_title() .'</h2>
<div class="date">'. get_the_date() .
'<input type="checkbox" id="chkbx_'.get_the_ID().'" '
.($stageStatus == "true" ? 'checked': '').
'/></div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maxime ipsa ratione omnis alias cupiditate saepe atque totam aperiam sed nulla voluptatem recusandae dolor, nostrum excepturi amet in dolores. Alias, ullam.</p>
<a class="bnt-more" href="javascript:void(0)">More</a>
</div>
</div>
';
}
echo ' </div>
</section>';
break;
}
} else {
// no posts found
echo "<h1>No Flows</h1>";
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
echo '<a href="/wp-login.php"> Login </a>';
}
}
function wporg_usermeta_form_field_birthday( $user )
{
?>
<h3>It's Your Birthday</h3>
<table class="form-table">
<tr>
<th>
<label for="birthday">Birthday</label>
</th>
<td>
<input type="text"
class="regular-text ltr"
id="birthday"
name="birthday"
value="<?= esc_attr( get_user_meta( $user->ID, 'stage 1', true ) ) ?>"
title="Some data"
required>
<p class="description">
Please enter your birthday date.
</p>
</td>
</tr>
</table>
<?php
}
// /**
// * The save action.
// *
// * @param $user_id int the ID of the current user.
// *
// * @return bool Meta ID if the key didn't exist, true on successful update, false on failure.
// */
// function wporg_usermeta_form_field_birthday_update( $user_id )
// {
// // check that the current user have the capability to edit the $user_id
// if ( ! current_user_can( 'edit_user', $user_id ) ) {
// return false;
// }
// // create/update user meta for the $user_id
// return update_user_meta(
// $user_id,
// 'status',
// $_POST['status']
// );
// }
// // Add the field to user's own profile editing screen.
// add_action(
// 'show_user_profile',
// 'wporg_usermeta_form_field_birthday'
// );
// /* Leave open*/