Plugin Directory

Changeset 2745008


Ignore:
Timestamp:
06/20/2022 06:51:32 AM (4 years ago)
Author:
usetiful
Message:

New version 1.1 with extended settings - changelog described in README

Location:
usetiful-digital-adoption-platform/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • usetiful-digital-adoption-platform/trunk/README.txt

    r2739782 r2745008  
    55Requires at least: 4.9.0
    66Tested up to: 6.0
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555== Changelog ==
    5656
     57= 1.1 =
     58WordPress user variables can be dynamically added as Usetiful tags
     59
    5760= 1.0 =
    5861Ability to install Usetiful to end-user-facing pages and WordPress backend
  • usetiful-digital-adoption-platform/trunk/usetiful.php

    r2739710 r2745008  
    1010 *
    1111 * @link              https://www.usetiful.com/
    12  * @since             1.0
     12 * @since             1.1
    1313 * @package           Usetiful
    1414 *
     
    1717 * Plugin URI:        https://www.usetiful.com/
    1818 * Description:       Usetiful’s digital adoption platform improves user retention with easy-to-use product tours, smart tooltips, and onboarding checklists.
    19  * Version:           1.0
     19 * Version:           1.1
    2020 * Author:            usetiful
    2121 * Author URI:        https://www.dobbytec.com/
     
    4747        add_action( 'wp_footer', array( $this, 'usetiful_footer_script' ), 99 );
    4848        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
    51137
    52138    /**
     
    62148            'edit_theme_options',
    63149            'usetiful-settings',
    64             array( $this, 'usetiful_settings_page' )
     150            array( $this, 'usetiful_settings_page' ) ,
     151            plugins_url( 'usetiful/assets/admin_icon.png' )
    65152        );
    66153        // add this action to save your setting page data
     
    91178    public function usetiful_save_plugin_settings() {
    92179        global $pagenow;
     180
    93181        $settings = get_option( 'usetiful_plugin_settings' );
    94182        if ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] == 'usetiful-settings' ) {
     
    97185                $settings['usetiful_key'] = isset( $_POST['usetiful_key'] ) ? sanitize_key( $_POST['usetiful_key'] ) : '';
    98186                $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               
    99190                update_option( 'usetiful_plugin_settings', $settings );
    100191            }
     
    131222                            include 'admin/setting.php';
    132223                        echo '</table>';
     224                        include 'admin/tag-setting.php';
    133225                    }
    134226                    ?>
    135227                    <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" />
    137229                        <input type="hidden" name="usetiful-settings-submit" value="Y" />
    138230                    </p>
     
    233325
    234326        if ( is_user_logged_in() ) {
     327
    235328            $usetiful_user_id = get_current_user_id();
    236329            $user_data        = get_userdata( $usetiful_user_id );
     
    238331            $usetiful_fname   = $user_data->user_firstname;
    239332            $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            }
    255403
    256404            // $encodeUserTag = json_encode( $userTag );
Note: See TracChangeset for help on using the changeset viewer.