Changeset 2745008
- Timestamp:
- 06/20/2022 06:51:32 AM (4 years ago)
- Location:
- usetiful-digital-adoption-platform/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (2 diffs)
-
usetiful.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
usetiful-digital-adoption-platform/trunk/README.txt
r2739782 r2745008 5 5 Requires at least: 4.9.0 6 6 Tested up to: 6.0 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 55 55 == Changelog == 56 56 57 = 1.1 = 58 WordPress user variables can be dynamically added as Usetiful tags 59 57 60 = 1.0 = 58 61 Ability to install Usetiful to end-user-facing pages and WordPress backend -
usetiful-digital-adoption-platform/trunk/usetiful.php
r2739710 r2745008 10 10 * 11 11 * @link https://www.usetiful.com/ 12 * @since 1. 012 * @since 1.1 13 13 * @package Usetiful 14 14 * … … 17 17 * Plugin URI: https://www.usetiful.com/ 18 18 * Description: Usetiful’s digital adoption platform improves user retention with easy-to-use product tours, smart tooltips, and onboarding checklists. 19 * Version: 1. 019 * Version: 1.1 20 20 * Author: usetiful 21 21 * Author URI: https://www.dobbytec.com/ … … 47 47 add_action( 'wp_footer', array( $this, 'usetiful_footer_script' ), 99 ); 48 48 add_action( 'admin_footer', array( $this, 'usetiful_admin_footer_script' ), 99 ); 49 50 } 49 add_action('admin_enqueue_scripts', array( $this, 'usetiful_add_scripts' ) ); 50 add_action('admin_enqueue_scripts', array( $this, 'usetiful_add_style' ) ); 51 52 add_filter( 'usetiful_get_tags_name_filter', array( $this, 'usetiful_get_tags_name_callback', 10, 3 ) ); 53 add_filter( 'usetiful_get_wp_tags_filter', array( $this, 'usetiful_get_wp_tags_callback', 10, 3 ) ); 54 55 } 56 57 /** 58 * Usetiful_add_style. 59 * Admin menu hooks for adding the style in backend side. 60 * 61 * @return void 62 */ 63 public function usetiful_add_style(){ 64 wp_enqueue_script( 'jquery-ui-core'); 65 wp_enqueue_style( 'usetiful_style', plugin_dir_url( __FILE__ ) . 'assets/css/usetiful_style.css', array(), '1.0' ); 66 } 67 68 /** 69 * Usetiful_add_scripts. 70 * Admin menu hooks for adding the script in backend side. 71 * 72 * @return void 73 */ 74 public function usetiful_add_scripts(){ 75 76 wp_enqueue_script( 'jquery-ui-autocomplete' ); 77 wp_enqueue_script( 'usetiful_script', plugin_dir_url( __FILE__ ) . 'assets/js/usetiful_script.js', array(), '1.0' , true ); 78 wp_localize_script( 'usetiful_script' , 'usetiful_args', 79 array( 80 'availabletagsName' => $this->usetiful_get_tags_name_callback(), 81 'availableWptags' => $this->usetiful_get_wp_tags_callback(), 82 ) 83 ); 84 } 85 86 87 /** 88 * Usetiful_get_wp_tags_callback. 89 * Admin menu hooks for get tags as wp variable. 90 * 91 * @return void 92 */ 93 public function usetiful_get_wp_tags_callback() { 94 95 $wptagArray = array( 96 "wp_userId", 97 "wp_email", 98 "wp_nice_name", 99 "wp_display_name", 100 "wp_role", 101 "wp_firstName", 102 "wp_lastName", 103 "wp_language", 104 "wp_status", 105 ); 106 107 $value = apply_filters( 'usetiful_add_wp_tags_filter', $wptagArray ); 108 109 return $value; 110 } 111 112 /** 113 * Usetiful_get_tags_name_callback. 114 * Admin menu hooks for adding tags name. 115 * 116 * @return void 117 */ 118 public function usetiful_get_tags_name_callback() { 119 120 $tagnameArray = array( 121 "userId", 122 "email", 123 "nice_name", 124 "display_name", 125 "role", 126 "firstName", 127 "lastName", 128 "language", 129 "status", 130 ); 131 132 $value = apply_filters( 'usetiful_add_tags_name_filter', $tagnameArray ); 133 134 return $value; 135 } 136 51 137 52 138 /** … … 62 148 'edit_theme_options', 63 149 'usetiful-settings', 64 array( $this, 'usetiful_settings_page' ) 150 array( $this, 'usetiful_settings_page' ) , 151 plugins_url( 'usetiful/assets/admin_icon.png' ) 65 152 ); 66 153 // add this action to save your setting page data … … 91 178 public function usetiful_save_plugin_settings() { 92 179 global $pagenow; 180 93 181 $settings = get_option( 'usetiful_plugin_settings' ); 94 182 if ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] == 'usetiful-settings' ) { … … 97 185 $settings['usetiful_key'] = isset( $_POST['usetiful_key'] ) ? sanitize_key( $_POST['usetiful_key'] ) : ''; 98 186 $settings['admin_usetiful_key'] = isset( $_POST['admin_usetiful_key'] ) ? sanitize_key( $_POST['admin_usetiful_key'] ) : ''; 187 $settings['usetiful_tags_option'] = isset( $_POST['usetiful_option'] ) ? array_values(array_filter($_POST['usetiful_option'])) : ''; 188 189 99 190 update_option( 'usetiful_plugin_settings', $settings ); 100 191 } … … 131 222 include 'admin/setting.php'; 132 223 echo '</table>'; 224 include 'admin/tag-setting.php'; 133 225 } 134 226 ?> 135 227 <p class="submit" style="clear: both;"> 136 <input type="submit" name="Submit" class="button-primary " value="Update Settings" />228 <input type="submit" name="Submit" class="button-primary usetiful-submit" value="Update Settings" /> 137 229 <input type="hidden" name="usetiful-settings-submit" value="Y" /> 138 230 </p> … … 233 325 234 326 if ( is_user_logged_in() ) { 327 235 328 $usetiful_user_id = get_current_user_id(); 236 329 $user_data = get_userdata( $usetiful_user_id ); … … 238 331 $usetiful_fname = $user_data->user_firstname; 239 332 $usetiful_lname = $user_data->user_lastname; 240 241 $userTag = array( 242 'userId' => (string)$usetiful_user_id, 243 'role' => esc_html( $usetiful_role ), 244 ); 245 246 // Checking First Name tag. 247 if(!empty( $usetiful_fname )){ 248 $userTag['firstName'] = esc_html( $usetiful_fname ); 249 } 250 251 // Checking Last Name. tag 252 if(!empty( $usetiful_lname )){ 253 $userTag['lastName'] = esc_html( $usetiful_lname ); 254 } 333 $usetiful_email = $user_data->user_email; 334 $usetiful_nicename = $user_data->user_nicename; 335 $usetiful_display_name = $user_data->user_display_name; 336 337 $settings = get_option( 'usetiful_plugin_settings' ); 338 339 if(!empty($settings['usetiful_tags_option'])) 340 { 341 $userTag = array(); 342 foreach ($settings['usetiful_tags_option'] as $_key => $value) { 343 $tag_key = esc_html($value['tag']); 344 345 /* Replace tag_value to actual value */ 346 if( $value['tag_value'] == 'wp_userId'){ 347 $value['tag_value'] = str_replace('wp_userId', (string)$usetiful_user_id, $value['tag_value']); 348 } 349 350 if( $value['tag_value'] == 'wp_firstName'){ 351 $value['tag_value'] = str_replace('wp_firstName',esc_html($usetiful_fname), $value['tag_value']); 352 } 353 354 if( $value['tag_value'] == 'wp_lastName'){ 355 $value['tag_value'] = str_replace('wp_lastName',esc_html($usetiful_lname), $value['tag_value']); 356 } 357 358 if( $value['tag_value'] == 'wp_role'){ 359 $value['tag_value'] = str_replace('wp_role',esc_html($usetiful_role), $value['tag_value']); 360 } 361 362 if( $value['tag_value'] == 'wp_language'){ 363 $value['tag_value'] = str_replace('wp_language',get_bloginfo("language"), $value['tag_value']); 364 } 365 366 if( $value['tag_value'] == 'wp_status'){ 367 $value['tag_value'] = str_replace('wp_status',esc_html('loggedin'), $value['tag_value']); 368 } 369 370 if( $value['tag_value'] == 'wp_email'){ 371 $value['tag_value'] = str_replace('wp_email',esc_html($usetiful_email), $value['tag_value']); 372 } 373 374 if( $value['tag_value'] == 'wp_nicename'){ 375 $value['tag_value'] = str_replace('wp_nicename',esc_html($usetiful_nicename), $value['tag_value']); 376 } 377 378 if( $value['tag_value'] == 'wp_display_name'){ 379 $value['tag_value'] = str_replace('wp_display_name',esc_html($usetiful_display_name), $value['tag_value']); 380 } 381 382 $userTag[$tag_key] = esc_html($value['tag_value']); 383 384 } 385 386 }else{ 387 388 $userTag = array( 389 'userId' => (string)$usetiful_user_id, 390 'role' => esc_html( $usetiful_role ), 391 ); 392 393 // Checking First Name tag. 394 if(!empty( $usetiful_fname )){ 395 $userTag['firstName'] = esc_html( $usetiful_fname ); 396 } 397 398 // Checking Last Name. tag 399 if(!empty( $usetiful_lname )){ 400 $userTag['lastName'] = esc_html( $usetiful_lname ); 401 } 402 } 255 403 256 404 // $encodeUserTag = json_encode( $userTag );
Note: See TracChangeset
for help on using the changeset viewer.