Plugin Directory

Changeset 3123813


Ignore:
Timestamp:
07/23/2024 11:06:18 AM (19 months ago)
Author:
wpeventmanager
Message:

Released version 1.0.4

Location:
wp-user-profile-avatar/trunk
Files:
6 added
9 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • wp-user-profile-avatar/trunk/admin/templates/comments-settings-page.php

    r3106296 r3123813  
    88}
    99
    10 function wpupa_update_options( $options ) {
    11     update_option( 'disable_comments_options', $options );
    12 }
    13 
    14 $typeargs            = array( 'public' => true );
    15 $options             = get_option( 'disable_comments_options', array() );
    16 $modified_types      = array();
    17 $disabled_post_types = wpupa_get_disabled_post_types();
    18 
    19 if ( ! empty( $disabled_post_types ) ) {
    20     foreach ( $disabled_post_types as $type ) {
    21         // we need to know what native support was for later.
    22         if ( post_type_supports( $type, 'comments' ) ) {
    23             $modified_types[] = $type;
    24             remove_post_type_support( $type, 'comments' );
    25             remove_post_type_support( $type, 'trackbacks' );
    26         }
    27     }
    28 }
    29 $types = get_post_types( $typeargs, 'objects' );
    30 // foreach ( array_keys( $types ) as $type ) {
    31 // if ( ! in_array( $type, $modified_types ) && ! post_type_supports( $type, 'comments' ) ) {   // the type doesn't support comments anyway.
    32 // //       unset( $types[ $type ] );
    33 // }
    34 // }
    35 
    36 if ( isset( $_POST['submit'] ) ) {
    37     check_admin_referer( 'disable-comments-admin' );
    38     $options['remove_everywhere'] = ( isset( $_POST['mode'] ) == 'remove_everywhere' );
    39 
    40     if ( $options['remove_everywhere'] ) {
    41         $disabled_post_types = array_keys( $types );
    42     } else {
    43         $disabled_post_types = empty( $_POST['disabled_types'] ) ? array() : (array) wp_unslash( sanitize_text_field( $_POST['disabled_types'] ) );
    44     }
    45 
    46     $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) );
    47 
    48     $options['disabled_post_types'] = $disabled_post_types;
    49 
    50     // Extra custom post types.
    51     if ( ! empty( $_POST['extra_post_types'] ) ) {
    52         $extra_post_types            = array_filter( array_map( 'sanitize_key', explode( ',', sanitize_text_field( $_POST['extra_post_types'] ) ) ) );
    53         $options['extra_post_types'] = array_diff( $extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins.
    54     }
    55 
    56     wpupa_update_options( $options );
    57     echo '<div id="message" class="updated"><p>' . esc_html__( 'Options updated. Changes to the Admin Menu and Admin Bar will not appear until you leave or reload this page.', 'wp-user-profile-avatar' ) . '</p></div>';
    58 }
    59 ?>
     10?> 
    6011<div class="wrap">
    6112    <h1><?php echo esc_html_x( 'Disable Comments', 'settings page title', 'wp-user-profile-avatar' ); ?></h1>
    62 
     13    <?php
     14        if ( isset( $_POST['submit'] ) && isset( $_POST['disable_comments_nonce_field'] ) && wp_verify_nonce( $_POST['disable_comments_nonce_field'], 'disable_comments_nonce' ) ) {
     15           
     16            $mode = sanitize_text_field( $_POST['mode'] );
     17            update_option( 'disable_comments_mode', $mode );
     18           
     19            if ( 'selected-types' === $mode && isset( $_POST['disabled_post_types'] ) && is_array( $_POST['disabled_post_types'] ) ) {
     20                $disabled_post_types = array_map( 'sanitize_text_field', $_POST['disabled_post_types'] );
     21            } else {
     22                $disabled_post_types = array();
     23            }
     24            update_option( 'disabled_post_types', $disabled_post_types );
     25        }
     26    ?>
    6327    <form action="" method="post" id="disable-comments">
    6428        <ul>
    65             <li><label for="remove_everywhere"><input type="radio" id="remove_everywhere" name="mode" value="remove_everywhere" <?php checked( isset( $options['remove_everywhere'] ) ); ?> /> <strong><?php esc_html_e( 'Everywhere', 'wp-user-profile-avatar' ); ?></strong>: <?php esc_html_e( 'Disable all comment-related controls and settings in WordPress.', 'wp-user-profile-avatar' ); ?></label>
    66                 <p class="indent"><?php printf( esc_html__( '%1$s: This option is global and will affect your entire site. Use it only if you want to disable comments <em>everywhere</em>. A complete description of what this option does is <a href="%2$s" target="_blank">available here</a>.', 'wp-user-profile-avatar' ), '<strong style="color: #900">' . esc_html__( 'Warning', 'wp-user-profile-avatar' ) . '</strong>', 'https://wordpress.org/plugins/disable-comments/other_notes/' ); ?></p>
     29            <li>
     30                <label for="remove_everywhere">
     31                    <input type="radio" id="remove_everywhere" name="mode" value="remove_everywhere" <?php checked( get_option('disable_comments_mode'), 'remove_everywhere' ); ?> />
     32                    <strong><?php esc_html_e( 'Everywhere', 'wp-user-profile-avatar' ); ?></strong>:
     33                    <?php esc_html_e( 'Disable all comment-related controls and settings in WordPress.', 'wp-user-profile-avatar' ); ?>
     34                </label>
     35                <p class="indent">
     36                    <?php printf( esc_html__( '%1$s: This option is global and will affect your entire site. Use it only if you want to disable comments <em>everywhere</em>. A complete description of what this option does is <a href="%2$s" target="_blank">available here</a>.', 'wp-user-profile-avatar' ), '<strong style="color: #900">' . esc_html__( 'Warning', 'wp-user-profile-avatar' ) . '</strong>', 'https://wordpress.org/plugins/disable-comments/other_notes/' ); ?>
     37                </p>
    6738            </li>
    68             <?php $selected = ( empty( $_POST['delete-everywhere'] ) ) ? 'checked="checked"' : ''; ?>
    69             <li><label for="selected-types"><input type="radio" id="selected-types" name="mode" value="selected-types" <?php echo esc_attr( $selected ); ?> /> <strong><?php esc_html_e( 'On certain post types', 'wp-user-profile-avatar' ); ?></strong>:</label>
    70                 <p></p>
     39            <li>
     40                <label for="selected-types">
     41                    <input type="radio" id="selected-types" name="mode" value="selected-types" <?php checked( get_option('disable_comments_mode'), 'selected-types' ); ?> />
     42                    <strong><?php esc_html_e( 'On certain post types', 'wp-user-profile-avatar' ); ?></strong>:
     43                </label>
     44                <p class="indent"><?php esc_html_e( 'Disabling comments will also disable trackbacks and pingbacks. All comment-related fields will also be hidden from the edit/quick-edit screens of the affected posts. These settings cannot be overridden for individual posts.', 'wp-user-profile-avatar' ); ?></p>
     45               
    7146                <ul class="indent" id="listoftypes">
    7247                    <?php
    73                     if ( isset( $options['disabled_post_types'] ) && is_array( $options['disabled_post_types'] ) ) {
    74                         $disabled_post_types = $options['disabled_post_types'];
    75                     } else {
    76                         $disabled_post_types = array();
    77                     }
    78                     foreach ( $types as $k => $v ) {
    79                         echo "<li><label for='post-type-" . esc_attr( $k ) . "'><input type='checkbox' name='disabled_types[]' value='" . esc_attr( $k ) . "' " . checked( in_array( $k, $disabled_post_types ), true, false ) . " id='post-type-" . esc_attr( $k ) . "'> " . esc_attr( $v->labels->name ) . '</label></li>';
     48                    $post_types = get_post_types( array( 'public' => true ), 'objects' );
     49                    $disabled_post_types = get_option( 'disabled_post_types', array() );
     50                    foreach ( $post_types as $post_type ) {
     51                        ?>
     52                        <li>
     53                            <label for="post-type-<?php echo esc_attr( $post_type->name ); ?>">
     54                                <input type="checkbox" name="disabled_post_types[]" value="<?php echo esc_attr( $post_type->name ); ?>" <?php checked( in_array( $post_type->name, $disabled_post_types ) ); ?> id="post-type-<?php echo esc_attr( $post_type->name ); ?>">
     55                                <?php echo esc_html( $post_type->labels->name ); ?>
     56                            </label>
     57                        </li>
     58                        <?php
    8059                    }
    8160                    ?>
    8261                </ul>
    83 
    84                 <p class="indent"><?php esc_html_e( 'Disabling comments will also disable trackbacks and pingbacks. All comment-related fields will also be hidden from the edit/quick-edit screens of the affected posts. These settings cannot be overridden for individual posts.', 'wp-user-profile-avatar' ); ?></p>
    8562            </li>
    8663        </ul>
    87 
    88         <?php wp_nonce_field( 'disable-comments-admin' ); ?>
     64        <?php wp_nonce_field( 'disable_comments_nonce', 'disable_comments_nonce_field' ); ?>
    8965        <p class="submit"><input class="button-primary" type="submit" name="submit" value="<?php esc_html_e( 'Save Changes', 'wp-user-profile-avatar' ); ?>"></p>
    9066    </form>
    9167</div>
    92 <script>
    93     jQuery(document).ready(function ($) {
    94         function disable_comments_uihelper() {
    95             var indiv_bits = $("#listoftypes, #extratypes");
    96             if ($("#remove_everywhere").is(":checked"))
    97                 indiv_bits.css("color", "#888").find(":input").attr("disabled", true);
    98             else
    99                 indiv_bits.css("color", "#000").find(":input").attr("disabled", false);
    100         }
    101 
    102         $("#disable-comments :input").change(function () {
    103             $("#message").slideUp();
    104             disable_comments_uihelper();
    105         });
    106 
    107         disable_comments_uihelper();
    108     });
    109 </script>
  • wp-user-profile-avatar/trunk/admin/templates/comments-tools-page.php

    r3106296 r3123813  
    88    exit;
    99}
    10 function wpupa_update_options( $options ) {
    11 
    12     update_option( 'delete_comments_options', $options );
    13 }
    1410?>
    1511<div class="wrap">
    16     <h1><?php esc_html_e( 'Delete Comments', 'wp-user-profile-avatar' ); ?></h1>
     12    <h1><?php echo esc_html_x( 'Delete Comments', 'settings page title', 'wp-user-profile-avatar' ); ?></h1>
    1713    <?php
    18     global $wpdb;
    19     $comments_count = $wpdb->get_var( "SELECT count(comment_id) from $wpdb->comments" );
    20     // if ($comments_count <= 0) {
    21     ?>
    22         <p><strong><?php // _e('No comments available for deletion.', 'disable-comments'); ?></strong></p>
     14    if ( isset( $_POST['submit'] ) && isset( $_POST['delete_comments_nonce_field'] ) && wp_verify_nonce( $_POST['delete_comments_nonce_field'], 'delete_comments_nonce' ) ) {
     15       
     16        $mode = sanitize_text_field( $_POST['mode'] );
     17        update_option( 'delete_comments_mode', $mode );
    2318
    24     <?php
    25     // return;
    26     // }
    27     // if ($comments_count <= 0) {
    28     ?>
    29         <p><strong><?php // _e('No comments available for deletion.', 'disable-comments'); ?></strong></p>
     19        if ( 'delete_everywhere' === $mode ) {
    3020
    31     <?php
    32     // return;
    33     // }
    34     $options  = get_option( 'delete_comments_options', array() );
    35     $typeargs = array( 'public' => true );
    36 
    37     $modified_types      = array();
    38     $disabled_post_types = wpupa_get_disabled_post_types();
    39     if ( ! empty( $disabled_post_types ) ) {
    40         foreach ( $disabled_post_types as $type ) {
    41             // we need to know what native support was for later.
    42             if ( post_type_supports( $type, 'comments' ) ) {
    43                 $modified_types[] = $type;
    44                 remove_post_type_support( $type, 'comments' );
    45                 remove_post_type_support( $type, 'trackbacks' );
     21            $deleted_count = delete_comments_everywhere();
     22            echo '<div class="notice notice-success"><p>' . sprintf( esc_html__( '%d comments have been deleted from your site.', 'wp-user-profile-avatar' ), $deleted_count ) . '</p></div>';
     23            update_option( 'selected_post_types', array() );
     24           
     25        } elseif ( 'selected-post-types' === $mode ) {
     26           
     27            if ( isset( $_POST['selected_post_types'] ) && is_array( $_POST['selected_post_types'] ) && ! empty( $_POST['selected_post_types'] ) ) {
     28               
     29                $selected_post_types = array_map( 'sanitize_text_field', $_POST['selected_post_types'] );
     30                update_option( 'selected_post_types', $selected_post_types ); // Save selected post types
     31                $deleted_count = delete_comments_by_post_types( $selected_post_types );
     32                echo '<div class="notice notice-success"><p>' . sprintf( esc_html__( '%d comments have been deleted from selected post types.', 'wp-user-profile-avatar' ), $deleted_count ) . '</p></div>';
     33           
     34            } else {
     35                update_option( 'selected_post_types', array() );
     36                //   echo '<div class="notice notice-error"><p>' . esc_html__( 'Please select at least one post type to delete comments from.', 'wp-user-profile-avatar' ) . '</p></div>';
    4637            }
    4738        }
    4839    }
    49     $types = get_post_types( $typeargs, 'objects' );
    50 
    51 
    52     if ( isset( $_POST['delete'] ) && isset( $_POST['delete_mode'] ) ) {
    53         check_admin_referer( 'delete-comments-admin' );
    54         $options['remove_everywhere'] = ( $_POST['delete_mode'] == 'remove_everywhere' );
    55 
    56         if ( $options['remove_everywhere'] ) {
    57             $disabled_post_types = array_keys( $types );
    58         } else {
    59             $disabled_post_types = empty( sanitize_text_field( $_POST['delete_types'] ) ) ? array() : (array) wp_unslash( sanitize_text_field($_POST['delete_types'] ) );
    60         }
    61 
    62         $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) );
    63 
    64         $options['disabled_post_types'] = $disabled_post_types;
    65 
    66         // Extra custom post types.
    67         if ( ! empty( $_POST['extra_post_types'] ) ) {
    68             $extra_post_types            = array_filter( array_map( 'sanitize_key', explode( ',', $_POST['extra_post_types'] ) ) );
    69             $options['extra_post_types'] = array_diff( $extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins.
    70         }
    71 
    72         wpupa_update_options( $options );
    73         // echo '<div id="message" class="updated"><p>' . __('Options updated. Changes to the Admin Menu and Admin Bar will not appear until you leave or reload this page.', 'disable-comments') . '</p></div>';
    74 
    75         if ( $_POST['delete_mode'] == 'delete-everywhere' ) {
    76             if ( $wpdb->query( "TRUNCATE $wpdb->commentmeta" ) != false ) {
    77                 if ( $wpdb->query( "TRUNCATE $wpdb->comments" ) != false ) {
    78                     $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0" );
    79                     $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" );
    80                     $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" );
    81                     // echo "<p style='color:green'><strong>" . __('All comments have been deleted.', 'disable-comments') . '</strong></p>';
    82                     echo '<div id="message" class="updated"><p>' . esc_html__( 'All comments have been deleted123.', 'wp-user-profile-avatar' ) . '</p></div>';
    83                 } else {
    84                     // echo "<p style='color:red'><strong>" . __('Internal error occured. Please try again later.', 'disable-comments') . '</strong></p>';
    85                     echo '<div id="message" class="updated"><p>' . esc_html__( 'Internal error occured. Please try again later.', 'wp-user-profile-avatar' ) . '</p></div>';
    86                 }
    87             } else {
    88                 // echo "<p style='color:red'><strong>" . __('Internal error occured. Please try again later.', 'disable-comments') . '</strong></p>';
    89                 echo '<div id="message" class="updated"><p>' . esc_html__( 'Internal error occured. Please try again later.', 'wp-user-profile-avatar' ) . '</p></div>';
    90             }
    91         } else {
    92             $delete_post_types = empty( $_POST['delete_types'] ) ? array() : wp_unslash( sanitize_text_field( $_POST['delete_types'] ) );
    93             $delete_post_types = array_intersect( $delete_post_types, array_keys( $types ) );
    94 
    95             // Extra custom post types.
    96             if ( ! empty( $_POST['delete_extra_post_types'] ) ) {
    97                 $delete_extra_post_types = array_filter( array_map( 'sanitize_key', explode( ',', sanitize_text_field( $_POST['delete_extra_post_types']) ) ) );
    98                 $delete_extra_post_types = array_diff( $delete_extra_post_types, array_keys( $types ) );    // Make sure we don't double up builtins.
    99                 $delete_post_types       = array_merge( $delete_post_types, $delete_extra_post_types );
    100             }
    101 
    102             if ( ! empty( $delete_post_types ) ) {
    103                 // Loop through post_types and remove comments/meta and set posts comment_count to 0.
    104                 foreach ( $delete_post_types as $delete_post_type ) {
    105                     $wpdb->query( $wpdb->prepare( "DELETE cmeta FROM $wpdb->commentmeta cmeta INNER JOIN $wpdb->comments comments ON cmeta.comment_id=comments.comment_ID INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = %s" , $delete_post_type ));
    106                     $wpdb->query( $wpdb->prepare( "DELETE comments FROM $wpdb->comments comments INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = %s", $delete_post_type ) );
    107                     $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0 AND post_type = %s", $delete_post_type ) );
    108 
    109                     $post_type_object = get_post_type_object( $delete_post_type );
    110                     $post_type_label  = $post_type_object ? $post_type_object->labels->name : $delete_post_type;
    111                     // echo "<p style='color:green'><strong>" . sprintf(__('All comments have been deleted for %s.', 'disable-comments'), $post_type_label) . '</strong></p>';
    112                     echo '<div id="message" class="updated"><p>' . sprintf( esc_html__( 'All comments have been deleted for %s.', 'wp-user-profile-avatar' ), esc_attr( $post_type_label ) ) . '</p></div>';
    113                 }
    114 
    115                 $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" );
    116                 $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" );
    117 
    118                 // echo "<h4 style='color:green'><strong>" . __('Comment Deletion Complete', 'disable-comments') . '</strong></h4>';
    119 
    120             }
    121         }
    122 
    123         $comments_count = $wpdb->get_var( "SELECT count(comment_id) from $wpdb->comments" );
    124         // if ($comments_count <= 0) {
    125         ?>
    126         <p><strong><?php// _e('No comments available for deletion.', 'disable-comments'); ?></strong></p>
    127 
    128         <?php
    129         // return;
    130         // }
    131     }
    13240    ?>
    133 <form action="" method="post" id="delete-comments">
    134     <ul>
    135         <li>
    136 
    137         <label for="delete_everywhere"><input type="radio" id="delete_everywhere" name="delete_mode" value="<?php echo esc_attr( 'remove_everywhere' ); ?>" <?php checked( isset( $options['remove_everywhere'] ) ); ?> /> <strong><?php esc_html_e( 'Everywhere', 'wp-user-profile-avatar' ); ?></strong>: <?php esc_html_e( 'Delete all comments in WordPress.', 'wp-user-profile-avatar' ); ?></label>
    138             <p class="indent"><?php printf( esc_html__( '%s: This function and will affect your entire site. Use it only if you want to delete comments <em>everywhere</em>.', 'wp-user-profile-avatar' ), '<strong style="color: #900">' . esc_html__( 'Warning', 'wp-user-profile-avatar' ) . '</strong>' ); ?></p>
    139         </li>
    140         <?php $selected = ( empty( $_POST['delete-everywhere'] ) ) ? 'checked="checked"' : ''; ?>
    141         <li><label for="selected_delete_types"><input type="radio" id="selected_delete_types" name="delete_mode" value="selected_delete_types" <?php echo esc_attr( $selected ); ?> /> <strong><?php esc_html_e( 'For certain post types', 'wp-user-profile-avatar' ); ?></strong>:</label>
    142             <p></p>
    143             <ul class="indent" id="listofdeletetypes">
    144 
    145                 <?php
    146                 if ( isset( $options['disabled_post_types'] ) && is_array( $options['disabled_post_types'] ) ) {
    147                     $disabled_post_types = $options['disabled_post_types'];
    148                 } else {
    149                     $disabled_post_types = array();
    150                 }
    151                 foreach ( $types as $k => $v ) {
    152                     echo "<li><label for='post-type-" . esc_attr( $k ) . "'><input type='checkbox' name='delete_types[]' value='" . esc_attr( $k ) . "' " . checked( in_array( $k, $disabled_post_types ), true, false ) . " id='post-type-" . esc_attr( $k ) . "'> " . esc_attr( $v->labels->name ) . '</label></li>';
    153                 }
    154                 ?>
    155             </ul>
    156 
    157             <p class="indent"><?php printf( esc_html__( '%s: Deleting comments will remove existing comment entries in the database and cannot be reverted without a database backup.', 'wp-user-profile-avatar' ), '<strong style="color: #900">' . esc_html__( 'Warning', 'wp-user-profile-avatar' ) . '</strong>' ); ?></p>
    158         </li>
    159     </ul>
    160 
    161     <?php wp_nonce_field( 'delete-comments-admin' ); ?>
    162     <h4><?php esc_html_e( 'Total Comments:', 'wp-user-profile-avatar' ); ?> <?php echo esc_attr( $comments_count ); ?></h4>
    163     <p class="submit"><input class="button-primary" type="submit" name="delete" value="<?php esc_html_e( 'Delete Comments', 'wp-user-profile-avatar' ); ?>"></p>
    164 </form>
     41    <form action="" method="post" id="delete-comments">
     42        <ul>
     43            <li>
     44                <label for="delete_everywhere">
     45                    <input type="radio" id="delete_everywhere" name="mode" value="delete_everywhere" <?php checked( get_option('delete_comments_mode'), 'delete_everywhere' ); ?> />
     46                    <strong><?php esc_html_e( 'Everywhere', 'wp-user-profile-avatar' ); ?></strong>:
     47                    <?php esc_html_e( 'Delete all comments across your entire site.', 'wp-user-profile-avatar' ); ?>
     48                </label>
     49                <p class="indent">
     50                    <?php printf( esc_html__( '%1$s: This option is global and will affect your entire site. Use it only if you want to delete comments <em>everywhere</em>.', 'wp-user-profile-avatar' ), '<strong style="color: #900">' . esc_html__( 'Warning', 'wp-user-profile-avatar' ) . '</strong>' ); ?>
     51                </p>
     52            </li>
     53            <li>
     54                <label for="selected-post-types">
     55                    <input type="radio" id="selected-post-types" name="mode" value="selected-post-types" <?php checked( get_option('delete_comments_mode'), 'selected-post-types' ); ?> />
     56                    <strong><?php esc_html_e( 'On certain post types', 'wp-user-profile-avatar' ); ?></strong>:
     57                </label>
     58                <p class="indent"><?php esc_html_e( 'Deleting comments will permanently remove them from selected post types.', 'wp-user-profile-avatar' ); ?></p>
     59               
     60                <ul class="indent" id="list-of-post-types">
     61                    <?php
     62                    $post_types = get_post_types( array( 'public' => true ), 'objects' );
     63                    $selected_post_types = get_option( 'selected_post_types', array() );
     64                    foreach ( $post_types as $post_type ) {
     65                        ?>
     66                        <li>
     67                            <label for="post-type-<?php echo esc_attr( $post_type->name ); ?>">
     68                                <input type="checkbox" name="selected_post_types[]" value="<?php echo esc_attr( $post_type->name ); ?>" <?php checked( in_array( $post_type->name, $selected_post_types ) ); ?> id="post-type-<?php echo esc_attr( $post_type->name ); ?>">
     69                                <?php echo esc_html( $post_type->labels->name ); ?>
     70                            </label>
     71                        </li>
     72                        <?php
     73                    }
     74                    ?>
     75                </ul>
     76            </li>
     77        </ul>
     78        <?php wp_nonce_field( 'delete_comments_nonce', 'delete_comments_nonce_field' ); ?>
     79        <p class="submit"><input class="button-primary" type="submit" name="submit" value="<?php esc_html_e( 'Save Changes', 'wp-user-profile-avatar' ); ?>"></p>
     80    </form>
    16581</div>
    166 <script>
    167     jQuery(document).ready(function ($) {
    168         function delete_comments_uihelper() {
    169             var toggle_bits = $("#listofdeletetypes, #extradeletetypes");
    170             if ($("#delete_everywhere").is(":checked"))
    171                 toggle_bits.css("color", "#888").find(":input").attr("disabled", true);
    172             else
    173                 toggle_bits.css("color", "#000").find(":input").attr("disabled", false);
    174         }
    175 
    176         $("#delete-comments :input").change(function () {
    177             delete_comments_uihelper();
    178         });
    179 
    180         delete_comments_uihelper();
    181     });
    182 </script>
  • wp-user-profile-avatar/trunk/admin/wp-user-profile-avatar-admin.php

    r3106296 r3123813  
    1111class WPUPA_Admin {
    1212
     13    public $settings_page;
     14   
    1315    /**
    1416     * Constructor - get the plugin hooked in and ready
     
    2426        }
    2527
    26         include_once 'templates/wp-username-change.php';
    27         add_action( 'admin_menu', array( $this, 'admin_menu' ), 12 );
    28 
    29         add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
     28        include_once plugin_dir_path(__FILE__) . '../includes/wp-username-change.php';
     29
     30        add_action( 'admin_menu', array( $this, 'wpupa_admin_menu' ), 12 );
     31
     32        add_action( 'admin_enqueue_scripts', array( $this, 'wpupa_admin_enqueue_scripts' ) );
    3033
    3134        add_action( 'show_user_profile', array( $this, 'wpupa_add_fields' ) );
     
    3538        add_action( 'edit_user_profile_update', array( $this, 'wpupa_save_fields' ) );
    3639
    37         add_action( 'admin_init', array( $this, 'allow_contributor_subscriber_uploads' ) );
    38 
    39         add_action( 'init', array( $this, 'thickbox_model_init' ) );
     40        add_action( 'admin_init', array( $this, 'wpupa_allow_contributor_subscriber_uploads' ) );
     41
     42        add_action( 'init', array( $this, 'wpupa_thickbox_model_init' ) );
    4043        add_action( 'wp_ajax_thickbox_model_view', array( $this, 'thickbox_model_view' ) );
    4144        add_action( 'wp_ajax_nopriv_thickbox_model_view', array( $this, 'thickbox_model_view' ) );
    4245
    43         add_action( 'admin_init', array( $this, 'init_size' ) );
    44     }
    45 
    46     /**
    47      * admin_menu function.
    48      *
    49      * @access public
    50      * @param
    51      * @return
    52      * @since 1.0
    53      */
    54     public function admin_menu() {
     46        add_action( 'admin_init', array( $this, 'wpupa_init_size' ) );
     47        add_action( 'admin_init', array( $this, 'wpem_enable_event_comments' ) );
     48    }
     49
     50    /**
     51     * add admin menu page function.
     52     *
     53     * @access public
     54     * @param
     55     * @return
     56     * @since 1.0
     57     */
     58    public function wpupa_admin_menu() {
    5559        add_menu_page(
    5660            __( 'Profile Avatar Settings', 'wp-user-profile-avatar' ),
    57             __( 'WP User Profile Avtar', 'wp-user-profile-avatar' ),
     61            __( 'WP User Profile Avatar', 'wp-user-profile-avatar' ),
    5862            'manage_options',
    5963            'wp-user-profile-avatar',
     
    8993
    9094    /**
    91      * admin_enqueue_scripts function.
     95     * enqueue script and style function.
    9296     * enqueue style and script for admin
    9397     *
     
    97101     * @since 1.0.0
    98102     */
    99     public function admin_enqueue_scripts() {
     103    public function wpupa_admin_enqueue_scripts() {
    100104        global $pagenow;
    101105
     
    122126
    123127    /**
    124      * wpupa_add_fields function.
     128     * add fields function.
    125129     *
    126130     * @access public
     
    164168
    165169    /**
    166      * wpupa_save_fields function.
     170     * save the added fields function.
    167171     *
    168172     * @access public
     
    205209
    206210            $wpupa_disable_gravatar = ! empty( $_POST['wpupa-disable-gravatar'] ) ? sanitize_text_field( $_POST['wpupa-disable-gravatar'] ) : '';
    207 
    208             update_option( 'wpupa_tinymce', $wpupa_tinymce );
    209             update_option( 'wpupa_allow_upload', $wpupa_allow_upload );
    210             update_option( 'wpupa_disable_gravatar', $wpupa_disable_gravatar );
    211211
    212212            if ( ! empty( $wpupaattachmentid ) || ! empty( $wpupa_url ) ) {
     
    221221    }
    222222
    223 
    224 
    225     /**
    226      * wpupa_add_buttons function.
     223    /**
     224     * add button function.
    227225     *
    228226     * @access public
     
    240238
    241239    /**
    242      * wpupa_register_button function.
     240     * set register button function.
    243241     *
    244242     * @access public
     
    253251
    254252    /**
    255      * wpupa_add_tinymce_plugin function.
     253     * add tinymice plugin function.
    256254     *
    257255     * @access public
     
    266264
    267265    /**
    268      * thickbox_model_init function.
    269      *
    270      * @access public
    271      * @param
    272      * @return
    273      * @since 1.0
    274      */
    275     public function thickbox_model_init() {
     266     * add thickbox model function.
     267     *
     268     * @access public
     269     * @param
     270     * @return
     271     * @since 1.0
     272     */
     273    public function wpupa_thickbox_model_init() {
    276274        add_thickbox();
    277275    }
    278276
    279277    /**
    280      * thickbox_model_view function.
     278     * view thickbox model function.
    281279     *
    282280     * @access public
     
    292290
    293291    /**
    294      * allow_contributor_uploads function.
     292     * allow contributors uploads function.
    295293     * `
    296294     *
     
    300298     * @since 1.0
    301299     */
    302     public function allow_contributor_subscriber_uploads() {
     300    public function wpupa_allow_contributor_subscriber_uploads() {
    303301        $contributor = get_role( 'contributor' );
    304302        $subscriber  = get_role( 'subscriber' );
     
    321319            }
    322320        }
    323 
    324321    }
    325322
     
    337334    }
    338335
    339     public function init_size() {
     336    public function wpupa_init_size() {
    340337        if ( isset( $_POST['wpem-upload-max-file-size-field'] ) ) {
    341338           
     
    346343        add_filter( 'upload_size_limit', array( $this, 'wpem_upload_max_increase_upload' ) );
    347344    }
     345     /**
     346     * enable comments function.
     347     *
     348     * @access public
     349     * @param
     350     * @return
     351     */
     352    public function wpem_enable_event_comments() {
     353       
     354        $post_type = array( 'event_listing', 'event_zoom' );
     355        foreach( $post_type as $post ){
     356            add_post_type_support($post, 'comments');
     357        }
     358    }
    348359
    349360    /**
  • wp-user-profile-avatar/trunk/admin/wp-user-profile-avatar-settings.php

    r3106296 r3123813  
    1414     */
    1515    public function __construct() {
    16         add_action( 'wp_loaded', array( $this, 'edit_handler' ) );
     16        add_action( 'wp_loaded', array( $this, 'wpupa_edit_handler' ) );
    1717    }
    1818
     
    4141        $wpupa_default          = get_option( 'wpupa_default' );
    4242        $wpupa_attachment_id    = get_option( 'wpupa_attachment_id' );
    43         $wpupa_attachment_url   = wpupa_get_default_avatar_url( array( 'size' => 'admin' ) );
     43        $wpupa_attachment_url = get_option('wpupa_attachment_url') ? get_option('wpupa_attachment_url') : wpupa_get_default_avatar_url(array('size' => 'admin'));
    4444        $wpupa_size             = get_option( 'wpupa_size' );
    4545        $avatar_size            = get_option( 'avatar_size' );
     
    5454                    <td>
    5555                        <form method="post" action="<?php echo esc_url( admin_url( 'admin.php' ) ) . '?page=wp-user-profile-avatar'; ?>">
    56 
    5756                            <table class="form-table">
    58 
    5957                                <tr valign="top">
    6058                                    <th scope="row"><?php esc_html_e( 'Avatar Visibility', 'wp-user-profile-avatar' ); ?></th>
     
    6866                                    </td>
    6967                                </tr>
    70 
    7168                                <tr valign="top">
    7269                                    <th scope="row"><?php esc_html_e( 'Settings', 'wp-user-profile-avatar' ); ?></th>
     
    9188                                    </td>
    9289                                </tr>
    93 
    9490                                <tr valign="top">
    9591                                    <th scope="row"><?php esc_html_e( 'Avatar Rating', 'wp-user-profile-avatar' ); ?></th>
     
    104100                                    </td>
    105101                                </tr>
    106 
    107102                                <tr>
    108103                                    <th scope="row">
     
    148143                                    </td>
    149144                                </tr>
    150 
    151145                                <tr valign="top">
    152146                                    <th scope="row"><?php esc_html_e( 'Default Avatar', 'wp-user-profile-avatar' ); ?></th>
     
    184178                                                    $avatar     = get_avatar( '', 32, $name );
    185179                                                    $avatar_url = wpupa_get_selected_avatar_url( $name );
    186 
    187180                                                    $selected = ( $wpupa_default == $name ) ? 'checked="checked"' : '';
    188181                                                    ?>
     
    199192                                        </fieldset>
    200193                                    </td>
    201 
    202                                 </tr>
    203 
     194                                </tr>
    204195                                <tr>
    205196                                    <td>
     
    211202                                    </td>
    212203                                </tr>
    213 
    214204                            </table>
    215 
    216205                        </form>
    217206                    </td>
     
    219208            </table>
    220209        </div> 
    221 
    222210        <?php
    223211    }
    224212
    225213    /**
    226      * edit_handler function.
     214     * edit fields handler function.
    227215     *
    228216     * @access public
     
    231219     * @since 1.0
    232220     */
    233     public function edit_handler() {
     221    public function wpupa_edit_handler() {
    234222        if ( ! empty( $_POST['wp_user_profile_avatar_settings'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash ( $_POST['_wpnonce'] ) ), 'user_profile_avatar_settings' ) ) {
    235223            $user_id = get_current_user_id();
     
    249237            $wpupa_default = ! empty( $_POST['wpupa_default'] ) ? sanitize_text_field( wp_unslash( $_POST['wpupa_default'] ) ) : '';
    250238
    251             $wpupa_attachment_id = ! empty( $_POST['wpupaattachmentid'] ) ? sanitize_text_field( $_POST['wpupaattachmentid'] ) : '';
     239           if ( ! empty( $_POST['wpupaattachmentid'] ) ) {
     240                $wpupa_attachment_id = sanitize_text_field( $_POST['wpupaattachmentid'] );
     241                $wpupa_attachment_url = esc_url( wp_get_attachment_url( $wpupa_attachment_id ) );
     242            } else {
     243                $wpupa_attachment_id = '';
     244                $wpupa_attachment_url = esc_url( WPUPA_PLUGIN_URL . '/assets/images/wp-user-thumbnail.png' );
     245            }
    252246
    253247            $wpupa_size = ! empty( $_POST['wpupa_size'] ) ? sanitize_text_field( wp_unslash( $_POST['wpupa_size'] ) ) : '';
     
    276270            update_option( 'wpupa_default', $wpupa_default );
    277271            update_option( 'wpupa_attachment_id', $wpupa_attachment_id );
     272            update_option( 'wpupa_attachment_url', $wpupa_attachment_url);
    278273            update_option( 'wpupa_size', $wpupa_size );
    279274            update_option( 'avatar_size', $avatar_size );
     
    281276        }
    282277    }
    283 
    284278}
    285279
  • wp-user-profile-avatar/trunk/assets/css/frontend.css

    r3041275 r3123813  
    197197    margin-bottom: 5px;
    198198}
     199.update-user-profile-avatar#wp-user-profile-avatar-undo-button{
     200    margin-top:10px;
     201}
     202.size-large{
     203    width:1024px;
     204}
     205.size-medium{
     206    width:300px;
     207}
     208.size-thumbnail{
     209    width:150px;
     210}
  • wp-user-profile-avatar/trunk/assets/css/frontend.min.css

    r3041275 r3123813  
    1 #wp-user-profile-avatar-errors,#wp-user-profile-avatar-readable-size-error,.wp-user-profile-avatar-error{color:#c00!important;font-weight:700!important}#wp-user-profile-avatar-readable-size-success,#wp-user-profile-avatar-success,.wp-user-profile-avatar-success{color:#179a17!important;font-weight:700!important}#wp-user-profile-avatar-readable-size-error,#wp-user-profile-avatar-undo-button,.wp-user-profile-avatar-no-avatars{display:none}#wp-user-profile-avatar-preview,#wp_user_profile_avatar_preview-existing{margin-right:10px}#wp-user-profile-avatar-preview,#wp-user-profile-avatar-thumbnail,#wp_user_profile_avatar_preview-existing,#wp_user_profile_avatar_thumbnail-existing{display:inline-block;text-align:center;vertical-align:top}#wp-user-profile-avatar-preview img,#wp-user-profile-avatar-thumbnail img,#wp_user_profile_avatar_preview-existing img,#wp_user_profile_avatar_thumbnail-existing img{max-height:96px;border:1px solid #dfdfdf;display:block}.widget_wp_user_profile_avatar #wp-user-profile-avatar-preview img,.widget_wp_user_profile_avatar #wp-user-profile-avatar-thumbnail img,.widget_wp_user_profile_avatar #wp_user_profile_avatar_preview-existing img,.widget_wp_user_profile_avatar #wp_user_profile_avatar_thumbnail-existing img{max-height:64px}.defaultavatarpicker #wp-user-profile-avatar-preview,.defaultavatarpicker #wp_user_profile_avatar_preview-existing{width:32px;height:32px;margin-right:0;display:inline-block;overflow:hidden;vertical-align:middle}.defaultavatarpicker #wp-user-profile-avatar-preview img,.defaultavatarpicker #wp_user_profile_avatar_preview-existing img{width:32px;height:auto;border:0}#wp-user-profile-avatar-edit #wp-user-profile-avatar-remove,#wp-user-profile-avatar-edit #wp-user-profile-avatar-undo,#wp-user-profile-avatar-edit-attachment{margin-left:10px!important}#wp-user-profile-avatar-slider{width:22.75em}#wp-user-profile-avatar-upload-messages span{display:block}.wp-user-profile-avatar-hide{display:none!important}.wp-user-profile-avatar .alignleft{float:left;margin:.3rem 2rem 2rem}.wp-user-profile-avatar .alignright{float:right;margin:.3rem 0 2rem 2rem}.wp-user-profile-avatar .aligncenter,.wp-user-profile-avatar .alignnone{margin:4rem auto;text-align:center}.author-bio-section{border:1px solid #111;padding:15px 25px;margin-top:20px}.author-bio-section .author_details{display:flex;align-items:flex-start;margin-bottom:10px}.author-bio-section .author-image{margin:10px 0}.author-bio-section .author-image img{width:100px;margin-right:15px;display:block}.author-bio-section .author-info .author-bio,.update-user-profile-avatar #wp-user-profile-avatar-add-button-existing{margin:0}.author-bio-section .author-flex{display:grid;grid-template-columns:100px auto;align-items:center;margin-bottom:10px}.author-bio-section .author-info{margin-left:20px}.author-bio-section .author-info .author-name{font-weight:500;text-transform:capitalize}.author-bio-section .authorbox-social-icons{border-top:1px solid #111;margin:0 0 10px;padding-top:20px}.update-user-profile-avatar td,.update-user-profile-avatar th{border-color:#eee;padding:20px}.update-user-profile-avatar #wpupa_url{width:100%;max-width:500px;border-color:var(--wpem-gray-border-color);padding:10px}.update-user-profile-avatar #wp-user-profile-avatar-add-button-existing .button{border:1px solid var(--wpem-gray-border-color);background-color:var(--wpem-gray-bg-color);padding:10px 20px;cursor:pointer}.update-user-profile-avatar #wp-user-profile-avatar-add-button-existing .button:hover{background-color:var(--wpem-gray-border-color);color:var(--wpem-dark-color)}.update-user-profile-avatar #wp-user-profile-avatar-remove-button,.update-user-profile-avatar #wp-user-profile-avatar-undo-button,.update-user-profile-avatar #wp_user_profile_avatar_preview,.update-user-profile-avatar #wp_user_profile_avatar_thumbnail{margin-bottom:0}.update-user-profile-avatar #wp_user_profile_avatar_preview img,.update-user-profile-avatar #wp_user_profile_avatar_thumbnail img{margin-bottom:5px}
     1#wp-user-profile-avatar-errors,#wp-user-profile-avatar-readable-size-error,.wp-user-profile-avatar-error{color:#c00!important;font-weight:700!important}#wp-user-profile-avatar-readable-size-success,#wp-user-profile-avatar-success,.wp-user-profile-avatar-success{color:#179a17!important;font-weight:700!important}#wp-user-profile-avatar-readable-size-error,#wp-user-profile-avatar-undo-button,.wp-user-profile-avatar-no-avatars{display:none}#wp-user-profile-avatar-preview,#wp_user_profile_avatar_preview-existing{margin-right:10px}#wp-user-profile-avatar-preview,#wp-user-profile-avatar-thumbnail,#wp_user_profile_avatar_preview-existing,#wp_user_profile_avatar_thumbnail-existing{display:inline-block;text-align:center;vertical-align:top}#wp-user-profile-avatar-preview img,#wp-user-profile-avatar-thumbnail img,#wp_user_profile_avatar_preview-existing img,#wp_user_profile_avatar_thumbnail-existing img{max-height:96px;border:1px solid #dfdfdf;display:block}.widget_wp_user_profile_avatar #wp-user-profile-avatar-preview img,.widget_wp_user_profile_avatar #wp-user-profile-avatar-thumbnail img,.widget_wp_user_profile_avatar #wp_user_profile_avatar_preview-existing img,.widget_wp_user_profile_avatar #wp_user_profile_avatar_thumbnail-existing img{max-height:64px}.defaultavatarpicker #wp-user-profile-avatar-preview,.defaultavatarpicker #wp_user_profile_avatar_preview-existing{width:32px;height:32px;margin-right:0;display:inline-block;overflow:hidden;vertical-align:middle}.defaultavatarpicker #wp-user-profile-avatar-preview img,.defaultavatarpicker #wp_user_profile_avatar_preview-existing img{width:32px;height:auto;border:0}#wp-user-profile-avatar-edit #wp-user-profile-avatar-remove,#wp-user-profile-avatar-edit #wp-user-profile-avatar-undo,#wp-user-profile-avatar-edit-attachment{margin-left:10px!important}#wp-user-profile-avatar-slider{width:22.75em}#wp-user-profile-avatar-upload-messages span{display:block}.wp-user-profile-avatar-hide{display:none!important}.wp-user-profile-avatar .alignleft{float:left;margin:.3rem 2rem 2rem}.wp-user-profile-avatar .alignright{float:right;margin:.3rem 0 2rem 2rem}.wp-user-profile-avatar .aligncenter,.wp-user-profile-avatar .alignnone{margin:4rem auto;text-align:center}.author-bio-section{border:1px solid #111;padding:15px 25px;margin-top:20px}.author-bio-section .author_details{display:flex;align-items:flex-start;margin-bottom:10px}.author-bio-section .author-image{margin:10px 0}.author-bio-section .author-image img{width:100px;margin-right:15px;display:block}.author-bio-section .author-info .author-bio,.update-user-profile-avatar #wp-user-profile-avatar-add-button-existing{margin:0}.author-bio-section .author-flex{display:grid;grid-template-columns:100px auto;align-items:center;margin-bottom:10px}.author-bio-section .author-info{margin-left:20px}.author-bio-section .author-info .author-name{font-weight:500;text-transform:capitalize}.author-bio-section .authorbox-social-icons{border-top:1px solid #111;margin:0 0 10px;padding-top:20px}.update-user-profile-avatar td,.update-user-profile-avatar th{border-color:#eee;padding:20px}.update-user-profile-avatar #wpupa_url{width:100%;max-width:500px;border-color:var(--wpem-gray-border-color);padding:10px}.update-user-profile-avatar #wp-user-profile-avatar-add-button-existing .button{border:1px solid var(--wpem-gray-border-color);background-color:var(--wpem-gray-bg-color);padding:10px 20px;cursor:pointer}.update-user-profile-avatar #wp-user-profile-avatar-add-button-existing .button:hover{background-color:var(--wpem-gray-border-color);color:var(--wpem-dark-color)}.update-user-profile-avatar #wp-user-profile-avatar-remove-button,.update-user-profile-avatar #wp-user-profile-avatar-undo-button,.update-user-profile-avatar #wp_user_profile_avatar_preview,.update-user-profile-avatar #wp_user_profile_avatar_thumbnail{margin-bottom:0}.update-user-profile-avatar #wp_user_profile_avatar_preview img,.update-user-profile-avatar #wp_user_profile_avatar_thumbnail img{margin-bottom:5px}#wp-user-profile-avatar-undo-button{margin-top:10px}.size-large{width:1024px;}.size-medium{width:300px;}.size-thumbnail{width:150px;}
  • wp-user-profile-avatar/trunk/assets/js/admin-avatar.js

    r3041275 r3123813  
    55        init: function ()
    66        {
    7             jQuery('#wp-user-profile-avatar-add').on('click', AdminAvatar.actions.chooseAvatar);
    8             jQuery('#wp-user-profile-avatar-remove').on('click', AdminAvatar.actions.removeAvatar);
    9             jQuery('#wp-user-profile-avatar-undo').on('click', AdminAvatar.actions.undoAvatar);
    10 
    11             jQuery('body').on('click', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .nav-tab-wrapper a', AdminAvatar.actions.showShortcodeAvatarTab);
    12 
    13             jQuery('body').on('change', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to', AdminAvatar.actions.imageLinkTo);
    14 
    15             jQuery('body').on('click', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #user-avatar-form-btn', AdminAvatar.actions.addUserAvatarShortcode);
    16 
    17             jQuery('body').on('click', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-upload-avatar #upload-avatar-form-btn', AdminAvatar.actions.addUploadAvatarShortcode);
    18 
    19             if (typeof (tinymce) != "undefined")
    20             {
    21                 tinymce.PluginManager.add('wp_user_profile_avatar_shortcodes', function (editor, url) {
    22                     editor.addButton('wp_user_profile_avatar_shortcodes', {
     7            jQuery( '#wp-user-profile-avatar-add' ).off( "click" ).on( 'click', AdminAvatar.actions.chooseAvatar );
     8            jQuery( '#wp-user-profile-avatar-remove' ).off( "click" ).on( 'click', AdminAvatar.actions.removeAvatar );
     9            jQuery( '#wp-user-profile-avatar-undo' ).off( "click" ).on( 'click', AdminAvatar.actions.undoAvatar );
     10
     11            jQuery( 'body' ).off("click", "#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .nav-tab-wrapper a" ).on( 'click', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .nav-tab-wrapper a', AdminAvatar.actions.showShortcodeAvatarTab );
     12
     13            jQuery( 'body' ).off( "change", "#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to" ).on( 'change', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to', AdminAvatar.actions.imageLinkTo );
     14
     15            jQuery( 'body' ).off( "click", "#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #user-avatar-form-btn" ).on( 'click', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #user-avatar-form-btn', AdminAvatar.actions.addUserAvatarShortcode );
     16
     17            jQuery( 'body' ).off( "click", "#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-upload-avatar #upload-avatar-form-btn" ).on( 'click', '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-upload-avatar #upload-avatar-form-btn', AdminAvatar.actions.addUploadAvatarShortcode );
     18
     19            if ( typeof ( tinymce ) != "undefined" )
     20            {
     21                tinymce.PluginManager.add( 'wp_user_profile_avatar_shortcodes', function ( editor, url ) {
     22                    editor.addButton( 'wp_user_profile_avatar_shortcodes', {
    2323                        title: wp_user_profile_avatar_admin_avatar.icon_title,
    2424                        classes: 'thickbox',
     
    3131                });
    3232
    33                 setTimeout(function () {
    34                     jQuery('.mce-thickbox button').remove();
    35                     jQuery('.mce-thickbox').html('<a href="' + wp_user_profile_avatar_admin_avatar.thinkbox_ajax_url + '" class="thickbox mce-toolbar" title="' + wp_user_profile_avatar_admin_avatar.thinkbox_title + '"><img class="mce-ico" src="' + wp_user_profile_avatar_admin_avatar.default_avatar + '"></a>');
    36                 }, 1500);
     33                setTimeout( function () {
     34                    jQuery( '.mce-thickbox button' ).remove();
     35                    jQuery( '.mce-thickbox' ).html( '<a href="' + wp_user_profile_avatar_admin_avatar.thinkbox_ajax_url + '" class="thickbox mce-toolbar" title="' + wp_user_profile_avatar_admin_avatar.thinkbox_title + '"><img class="mce-ico" src="' + wp_user_profile_avatar_admin_avatar.default_avatar + '"></a>' );
     36                }, 1500 );
    3737            }
    38 
    3938        },
    40 
    4139        actions:
     40        {
     41            /**
     42             * showShortcodeAvatarTab function.
     43             *
     44             * @access public
     45             * @param
     46             * @return
     47             * @since 1.0
     48             */
     49            showShortcodeAvatarTab: function ( event )
     50            {
     51                jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left .settings-panel' ).hide();
     52
     53                var id = jQuery(event.target).attr('href');
     54
     55                jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left ' + id ).show();
     56            },
     57
     58            /**
     59             * imageLinkTo function.
     60             *
     61             * @access public
     62             * @param
     63             * @return
     64             * @since 1.0
     65             */
     66            imageLinkTo: function ( event )
     67            {
     68                var link_to = jQuery( event.target ).val();
     69
     70                if ( link_to == 'custom' )
    4271                {
    43                     /**
    44                      * showShortcodeAvatarTab function.
    45                      *
    46                      * @access public
    47                      * @param
    48                      * @return
    49                      * @since 1.0
    50                      */
    51                     showShortcodeAvatarTab: function (event)
    52                     {
    53                         jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left .settings-panel').hide();
    54 
    55                         var id = jQuery(event.target).attr('href');
    56 
    57                         jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left ' + id).show();
     72                    jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to' ).attr( 'type', 'text' );
     73                } else
     74                {
     75                    jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to' ).attr( 'type', 'hidden' );
     76                }
     77            },
     78
     79            /**
     80             * addUserAvatarShortcode function.
     81             *
     82             * @access public
     83             * @param
     84             * @return
     85             * @since 1.0
     86             */
     87            addUserAvatarShortcode: function ( event )
     88            {
     89                var user_id = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-user-id' ).val();
     90
     91                var size = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-size' ).val();
     92
     93                var align = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-alignment' ).val();
     94
     95                var link = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to' ).val();
     96
     97                var custom_link = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to' ).val();
     98
     99                var target = '';
     100                if (jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window' ).prop( "checked" ) == true )
     101                {
     102                    target = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window' ).val();
     103                }
     104
     105                var caption = jQuery( 'body' ).find( '#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-caption').val();
     106
     107                var user_tag = ( user_id != "" ) ? ' user_id="' + user_id + '"' : "";
     108
     109                var size_tag = ( size != "" ) ? ' size="' + size + '"' : "";
     110
     111                var align_tag = ( align != "" ) ? ' align="' + align + '"' : "";
     112
     113                var link_tag = ( link != "" && link != 'custom' && custom_link == "" ) ? ' link="' + link + '"' : "";
     114                link_tag = ( custom_link != "" ) ? ' link="' + custom_link + '"' : link_tag;
     115
     116                var target_tag = ( target != "" ) ? ' target="' + target + '"' : "";
     117
     118                var shortcode = "<p>[user_profile_avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + "] " + caption + " [/user_profile_avatar]</p>";
     119
     120                tinymce.activeEditor.insertContent( shortcode );
     121               
     122                jQuery( 'body' ).find( '#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton' ).trigger( "click" );
     123            },
     124
     125            /**
     126             * addUploadAvatarShortcode function.
     127             *
     128             * @access public
     129             * @param
     130             * @return
     131             * @since 1.0
     132             */
     133            addUploadAvatarShortcode: function ( event )
     134            {
     135                var shortcode = "<p>[user_profile_avatar_upload]</p>";
     136
     137                tinymce.activeEditor.insertContent( shortcode );
     138
     139                jQuery( 'body' ).find( '#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton' ).trigger("click");
     140            },
     141
     142            /**
     143             * chooseAvatar function.
     144             *
     145             * @access public
     146             * @param
     147             * @return
     148             * @since 1.0
     149             */
     150            chooseAvatar: function ( event )
     151            {
     152                var upload = wp.media({
     153                    library: {
     154                        type: 'image'
    58155                    },
    59 
    60                     /**
    61                      * imageLinkTo function.
    62                      *
    63                      * @access public
    64                      * @param
    65                      * @return
    66                      * @since 1.0
    67                      */
    68                     imageLinkTo: function (event)
    69                     {
    70                         var link_to = jQuery(event.target).val();
    71 
    72                         if (link_to == 'custom')
     156                    title: wp_user_profile_avatar_admin_avatar.media_box_title,
     157                    multiple: false
     158                })
     159                        .on( 'select', function ()
    73160                        {
    74                             jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to').attr('type', 'text');
    75                         } else
    76                         {
    77                             jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to').attr('type', 'hidden');
    78                         }
    79                     },
    80 
    81                     /**
    82                      * addUserAvatarShortcode function.
    83                      *
    84                      * @access public
    85                      * @param
    86                      * @return
    87                      * @since 1.0
    88                      */
    89                     addUserAvatarShortcode: function (event)
    90                     {
    91                         var user_id = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-user-id').val();
    92 
    93                         var size = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-size').val();
    94 
    95                         var align = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-alignment').val();
    96 
    97                         var link = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to').val();
    98 
    99                         var custom_link = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to').val();
    100 
    101                         var target = '';
    102                         if (jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window').prop("checked") == true)
    103                         {
    104                             target = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window').val();
    105                         }
    106 
    107                         var caption = jQuery('body').find('#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-caption').val();
    108 
    109                         var user_tag = (user_id != "") ? ' user_id="' + user_id + '"' : "";
    110 
    111                         var size_tag = (size != "") ? ' size="' + size + '"' : "";
    112 
    113                         var align_tag = (align != "") ? ' align="' + align + '"' : "";
    114 
    115                         var link_tag = (link != "" && link != 'custom' && custom_link == "") ? ' link="' + link + '"' : "";
    116                         link_tag = (custom_link != "") ? ' link="' + custom_link + '"' : link_tag;
    117 
    118                         var target_tag = (target != "") ? ' target="' + target + '"' : "";
    119 
    120                         var shortcode = "<p>[user_profile_avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + "] " + caption + " [/user_profile_avatar]</p>";
    121 
    122                         tinymce.activeEditor.insertContent(shortcode);
    123                         //editor.insertContent('[wdm_shortcode]');
    124 
    125                         jQuery('body').find('#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton').trigger("click");
    126                     },
    127 
    128                     /**
    129                      * addUploadAvatarShortcode function.
    130                      *
    131                      * @access public
    132                      * @param
    133                      * @return
    134                      * @since 1.0
    135                      */
    136                     addUploadAvatarShortcode: function (event)
    137                     {
    138                         var shortcode = "<p>[user_profile_avatar_upload]</p>";
    139 
    140                         tinymce.activeEditor.insertContent(shortcode);
    141                         //editor.insertContent('[wdm_shortcode]');
    142 
    143                         jQuery('body').find('#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton').trigger("click");
    144                     },
    145 
    146                     /**
    147                      * chooseAvatar function.
    148                      *
    149                      * @access public
    150                      * @param
    151                      * @return
    152                      * @since 1.0
    153                      */
    154                     chooseAvatar: function (event)
    155                     {
    156                         var upload = wp.media({
    157                             library: {
    158                                 type: 'image'
    159                             },
    160                             title: wp_user_profile_avatar_admin_avatar.media_box_title, /*Title for Media Box*/
    161                             multiple: false /*For limiting multiple image*/
     161                            var select = upload.state().get( 'selection' );
     162                            var attach = select.first().toJSON();
     163
     164                            jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', attach.url );
     165                            jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', attach.url );
     166                            jQuery( '#wpupaattachmentid' ).attr( 'value', attach.id );
     167                            jQuery( '#wp_user_profile_avatar_radio' ).trigger( 'click' );
     168                            jQuery( '#wp-user-profile-avatar-undo-button' ).show();
    162169                        })
    163                                 .on('select', function ()
    164                                 {
    165                                     var select = upload.state().get('selection');
    166                                     var attach = select.first().toJSON();
    167 
    168                                     jQuery('#wp-user-profile-avatar-preview img').attr('src', attach.url);
    169                                     jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', attach.url);
    170                                     jQuery('#wpupaattachmentid').attr('value', attach.id);
    171                                     jQuery('#wp_user_profile_avatar_radio').trigger('click');
    172                                     jQuery('#wp-user-profile-avatar-undo-button').show();
    173                                 })
    174                                 .open();
    175                     },
    176 
    177                     /**
    178                      * removeAvatar function.
    179                      *
    180                      * @access public
    181                      * @param
    182                      * @return
    183                      * @since 1.0
    184                      */
    185                     removeAvatar: function (event)
    186                     {
    187                         jQuery('#wp-user-profile-avatar-preview img').attr('src', wp_user_profile_avatar_admin_avatar.default_avatar);
    188                         jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', wp_user_profile_avatar_admin_avatar.default_avatar);
    189                         jQuery('#wpupaattachmentid').attr('value', '');
    190                         jQuery('#wpupa-url').attr('value', '');
    191 
    192                         jQuery('#wp-user-profile-avatar-remove').hide();
    193                     },
    194 
    195                     /**
    196                      * undoAvatar function.
    197                      *
    198                      * @access public
    199                      * @param
    200                      * @return
    201                      * @since 1.0
    202                      */
    203                     undoAvatar: function (event)
    204                     {
    205                         jQuery('#wp-user-profile-avatar-preview img').attr('src', wp_user_profile_avatar_admin_avatar.default_avatar);
    206                         jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', wp_user_profile_avatar_admin_avatar.default_avatar);
    207                         jQuery('#wpupaattachmentid').attr('value', '');
    208 
    209                         jQuery('#wp-user-profile-avatar-undo-button').hide();
    210                     },
    211 
    212                 } /* end of action */
    213 
     170                        .open();
     171            },
     172
     173            /**
     174             * removeAvatar function.
     175             *
     176             * @access public
     177             * @param
     178             * @return
     179             * @since 1.0
     180             */
     181            removeAvatar: function ( event )
     182            {
     183                jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', wp_user_profile_avatar_admin_avatar.default_avatar );
     184                jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', wp_user_profile_avatar_admin_avatar.default_avatar );
     185                jQuery( '#wpupaattachmentid' ).attr( 'value', '' );
     186                jQuery( '#wpupa-url' ).attr( 'value', '' );
     187
     188                jQuery( '#wp-user-profile-avatar-remove' ).hide();
     189            },
     190
     191            /**
     192             * undoAvatar function.
     193             *
     194             * @access public
     195             * @param
     196             * @return
     197             * @since 1.0
     198             */
     199            undoAvatar: function ( event )
     200            {
     201                jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', wp_user_profile_avatar_admin_avatar.default_avatar );
     202                jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', wp_user_profile_avatar_admin_avatar.default_avatar );
     203                jQuery( '#wpupaattachmentid' ).attr( 'value', '' );
     204
     205                jQuery( '#wp-user-profile-avatar-undo-button' ).hide();
     206            },
     207
     208        } /* end of action */
    214209    }; /* enf of return */
    215 
    216210}; /* end of class */
    217211
    218212AdminAvatar = AdminAvatar();
    219213
    220 jQuery(document).ready(function ($)
     214jQuery( document ).ready( function ($)
    221215{
    222216    AdminAvatar.init();
  • wp-user-profile-avatar/trunk/assets/js/admin-avatar.min.js

    r3012437 r3123813  
    1 var AdminAvatar=(AdminAvatar=function(){return{init:function(){jQuery("#wp-user-profile-avatar-add").on("click",AdminAvatar.actions.chooseAvatar),jQuery("#wp-user-profile-avatar-remove").on("click",AdminAvatar.actions.removeAvatar),jQuery("#wp-user-profile-avatar-undo").on("click",AdminAvatar.actions.undoAvatar),jQuery("body").on("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .nav-tab-wrapper a",AdminAvatar.actions.showShortcodeAvatarTab),jQuery("body").on("change","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to",AdminAvatar.actions.imageLinkTo),jQuery("body").on("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #user-avatar-form-btn",AdminAvatar.actions.addUserAvatarShortcode),jQuery("body").on("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-upload-avatar #upload-avatar-form-btn",AdminAvatar.actions.addUploadAvatarShortcode),"undefined"!=typeof tinymce&&(tinymce.PluginManager.add("wp_user_profile_avatar_shortcodes",function(a,r){a.addButton("wp_user_profile_avatar_shortcodes",{title:wp_user_profile_avatar_admin_avatar.icon_title,classes:"thickbox",image:wp_user_profile_avatar_admin_avatar.default_avatar,icon:!1,onclick:function(){}})}),setTimeout(function(){jQuery(".mce-thickbox button").remove(),jQuery(".mce-thickbox").html('<a href="'+wp_user_profile_avatar_admin_avatar.thinkbox_ajax_url+'" class="thickbox mce-toolbar" title="'+wp_user_profile_avatar_admin_avatar.thinkbox_title+'"><img class="mce-ico" src="'+wp_user_profile_avatar_admin_avatar.default_avatar+'"></a>')},1500))},actions:{showShortcodeAvatarTab:function(a){jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left .settings-panel").hide();a=jQuery(a.target).attr("href");jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left "+a).show()},imageLinkTo:function(a){"custom"==jQuery(a.target).val()?jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to").attr("type","text"):jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to").attr("type","hidden")},addUserAvatarShortcode:function(a){var r=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-user-id").val(),t=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp_image_size").val(),e=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-alignment").val(),o=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to").val(),i=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to").val(),_="";1==jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window").prop("checked")&&(_=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window").val());o=""!=o&&"custom"!=o&&""==i?' link="'+o+'"':"",_="<p>[user_profile_avatar"+(""!=r?' user_id="'+r+'"':"")+(""!=t?' size="'+t+'"':"")+(""!=e?' align="'+e+'"':"")+(o=""!=i?' link="'+i+'"':o)+(""!=_?' target="'+_+'"':"")+"] "+jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-caption").val()+" [/user_profile_avatar]</p>";tinymce.activeEditor.insertContent(_),jQuery("body").find("#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton").trigger("click")},addUploadAvatarShortcode:function(a){tinymce.activeEditor.insertContent("<p>[user_profile_avatar_upload]</p>"),jQuery("body").find("#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton").trigger("click")},chooseAvatar:function(a){var r=wp.media({library:{type:"image"},title:wp_user_profile_avatar_admin_avatar.media_box_title,multiple:!1}).on("select",function(){var a=r.state().get("selection").first().toJSON();jQuery("#wp_user_profile_avatar_preview img").attr("src",a.url),jQuery("#wp_user_profile_avatar_thumbnail img").attr("src",a.url),jQuery("#wpupaattachmentid").attr("value",a.id),jQuery("#wp_user_profile_avatar_radio").trigger("click"),jQuery("#wp-user-profile-avatar-undo-button").show()}).open()},removeAvatar:function(a){jQuery("#wp_user_profile_avatar_preview img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wp_user_profile_avatar_thumbnail img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wpupaattachmentid").attr("value",""),jQuery("#wpupa_url").attr("value",""),jQuery("#wp-user-profile-avatar-remove").hide()},undoAvatar:function(a){jQuery("#wp_user_profile_avatar_preview img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wp_user_profile_avatar_thumbnail img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wpupaattachmentid").attr("value",""),jQuery("#wp-user-profile-avatar-undo-button").hide()}}}})();jQuery(document).ready(function(a){AdminAvatar.init()});
     1var AdminAvatar=(AdminAvatar=function(){return{init:function(){jQuery("#wp-user-profile-avatar-add").off("click").on("click",AdminAvatar.actions.chooseAvatar),jQuery("#wp-user-profile-avatar-remove").off("click").on("click",AdminAvatar.actions.removeAvatar),jQuery("#wp-user-profile-avatar-undo").off("click").on("click",AdminAvatar.actions.undoAvatar),jQuery("body").off("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .nav-tab-wrapper a").on("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .nav-tab-wrapper a",AdminAvatar.actions.showShortcodeAvatarTab),jQuery("body").off("change","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to").on("change","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to",AdminAvatar.actions.imageLinkTo),jQuery("body").off("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #user-avatar-form-btn").on("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #user-avatar-form-btn",AdminAvatar.actions.addUserAvatarShortcode),jQuery("body").off("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-upload-avatar #upload-avatar-form-btn").on("click","#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-upload-avatar #upload-avatar-form-btn",AdminAvatar.actions.addUploadAvatarShortcode),"undefined"!=typeof tinymce&&(tinymce.PluginManager.add("wp_user_profile_avatar_shortcodes",function(a,r){a.addButton("wp_user_profile_avatar_shortcodes",{title:wp_user_profile_avatar_admin_avatar.icon_title,classes:"thickbox",image:wp_user_profile_avatar_admin_avatar.default_avatar,icon:!1,onclick:function(){}})}),setTimeout(function(){jQuery(".mce-thickbox button").remove(),jQuery(".mce-thickbox").html('<a href="'+wp_user_profile_avatar_admin_avatar.thinkbox_ajax_url+'" class="thickbox mce-toolbar" title="'+wp_user_profile_avatar_admin_avatar.thinkbox_title+'"><img class="mce-ico" src="'+wp_user_profile_avatar_admin_avatar.default_avatar+'"></a>')},1500))},actions:{showShortcodeAvatarTab:function(a){jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left .settings-panel").hide();a=jQuery(a.target).attr("href");jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap .admin-setting-left "+a).show()},imageLinkTo:function(a){"custom"==jQuery(a.target).val()?jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to").attr("type","text"):jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to").attr("type","hidden")},addUserAvatarShortcode:function(a){var r=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-user-id").val(),t=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-size").val(),e=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-alignment").val(),o=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-link-to").val(),i=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-custom-link-to").val(),_="";1==jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window").prop("checked")&&(_=jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-open-new-window").val());o=""!=o&&"custom"!=o&&""==i?' link="'+o+'"':"",_="<p>[user_profile_avatar"+(""!=r?' user_id="'+r+'"':"")+(""!=t?' size="'+t+'"':"")+(""!=e?' align="'+e+'"':"")+(o=""!=i?' link="'+i+'"':o)+(""!=_?' target="'+_+'"':"")+"] "+jQuery("body").find("#TB_window #TB_ajaxContent .wp-user-profile-avatar-shortcode-wrap #settings-user-avatar #wp-image-caption").val()+" [/user_profile_avatar]</p>";tinymce.activeEditor.insertContent(_),console.log(_),jQuery("body").find("#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton").trigger("click")},addUploadAvatarShortcode:function(a){tinymce.activeEditor.insertContent("<p>[user_profile_avatar_upload]</p>"),jQuery("body").find("#TB_window #TB_title #TB_closeAjaxWindow #TB_closeWindowButton").trigger("click")},chooseAvatar:function(a){var r=wp.media({library:{type:"image"},title:wp_user_profile_avatar_admin_avatar.media_box_title,multiple:!1}).on("select",function(){var a=r.state().get("selection").first().toJSON();jQuery("#wp-user-profile-avatar-preview img").attr("src",a.url),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",a.url),console.log(a),jQuery("#wpupaattachmentid").attr("value",a.id),jQuery("#wp_user_profile_avatar_radio").trigger("click"),jQuery("#wp-user-profile-avatar-undo-button").show()}).open()},removeAvatar:function(a){jQuery("#wp-user-profile-avatar-preview img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wpupaattachmentid").attr("value",""),jQuery("#wpupa_url").attr("value",""),jQuery("#wp-user-profile-avatar-remove").hide()},undoAvatar:function(a){jQuery("#wp-user-profile-avatar-preview img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",wp_user_profile_avatar_admin_avatar.default_avatar),jQuery("#wpupaattachmentid").attr("value",""),jQuery("#wp-user-profile-avatar-undo-button").hide()}}}})();jQuery(document).ready(function(a){AdminAvatar.init()});
  • wp-user-profile-avatar/trunk/assets/js/frontend-avatar.js

    r3106296 r3123813  
    55        init: function ()
    66        {
    7             jQuery('#wp-user-profile-avatar-add').on('click', FrontendAvatar.actions.chooseAvatar);
    8             jQuery('#wp-user-profile-avatar-remove').on('click', FrontendAvatar.actions.removeAvatar);
    9             jQuery('#wp-user-profile-avatar-undo').on('click', FrontendAvatar.actions.undoAvatar);
    10             jQuery('#wp-user-profile-avatar-update-profile').on('click', FrontendAvatar.actions.updateAvatar);
     7            jQuery('#wp-user-profile-avatar-add').off("click").on('click', FrontendAvatar.actions.chooseAvatar);
     8            jQuery('#wp-user-profile-avatar-remove').off("click").on('click', FrontendAvatar.actions.removeAvatar);
     9            jQuery('#wp-user-profile-avatar-undo').off("click").on('click', FrontendAvatar.actions.undoAvatar);
     10            jQuery('#wp-user-profile-avatar-update-profile').off("click").on('click', FrontendAvatar.actions.updateAvatar);
    1111        },
    1212
     
    2323                    chooseAvatar: function (event)
    2424                    {
    25                         var file_frame;
    26                         event.preventDefault();
    27                         // if the file_frame has already been created, just reuse it
    28                         if (file_frame) {
    29                             file_frame.open();
    30                             return;
    31                         }
     25                        var upload = wp.media({
     26                            library: {
     27                                type: 'image'
     28                            },
     29                            title: wp_user_profile_avatar_frontend_avatar.media_box_title,
     30                            multiple: false
     31                        })
     32                        .on( 'select', function ()
     33                        {
     34                            var select = upload.state().get( 'selection' );
     35                            var attach = select.first().toJSON();
    3236
    33                         file_frame = wp.media.frames.file_frame = wp.media({
    34                             title: jQuery(this).data('uploader_title'),
    35                             button: {
    36                                 text: jQuery(this).data('uploader_button_text'),
    37                             },
    38                             multiple: false // set this to true for multiple file selection
    39                         });
    40                         file_frame.on('select', function () {
    41                             attachment = file_frame.state().get('selection').first().toJSON();
    42                             console.log(attachment);
    43                             // do something with the file here
    44                             jQuery('#wpupaattachmentid').attr('value', attachment.id);
    45                             jQuery('#wp-user-profile-avatar-preview img').attr('src', attachment.sizes['full']['url']);
    46                             jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', attachment.sizes['thumbnail']['url']);
    47                         });
    48                         file_frame.open();
     37                            jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', attach.url );
     38                            jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', attach.url );
     39                            jQuery( '#wpupaattachmentid' ).attr( 'value', attach.id );
     40                            jQuery( '#wp_user_profile_avatar_radio' ).trigger( 'click' );
     41                            jQuery( '#wp-user-profile-avatar-undo-button' ).show();
     42                        })
     43                        .open();
    4944                    },
    5045                    /**
     
    5853                    removeAvatar: function (event)
    5954                    {
    60                         jQuery('#upload-avatar-responce').removeClass('wp-user-profile-avatar-error');
    61                         jQuery('#upload-avatar-responce').removeClass('wp-user-profile-avatar-success');
    62                         jQuery('#upload-avatar-responce').html('');
     55                        jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', wp_user_profile_avatar_frontend_avatar.default_avatar );
     56                        jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', wp_user_profile_avatar_frontend_avatar.default_avatar );
     57                        jQuery( '#wpupaattachmentid' ).attr( 'value', '' );
     58                        jQuery( '#wpupa-url' ).attr( 'value', '' );
    6359
    64                         var form_data = jQuery('.update-user-profile-avatar').serialize();
    65 
    66                         var fd = new FormData();
    67                         fd.append("action", 'remove_user_avatar');
    68                         fd.append("form_data", form_data);
    69                         fd.append("security", wp_user_profile_avatar_frontend_avatar.wp_user_profile_avatar_security);
    70 
    71                         jQuery.ajax({
    72                             url: wp_user_profile_avatar_frontend_avatar.ajax_url,
    73                             type: 'post',
    74                             dataType: 'JSON',
    75                             data: fd,
    76                             processData: false,
    77                             contentType: false,
    78                             success: function (responce)
    79                             {
    80                                 jQuery('#upload-avatar-responce').addClass(responce.class);
    81                                 //jQuery('#upload-avatar-responce').html(responce.message);
    82 
    83                                 if (responce.class == 'wp-user-profile-avatar-success')
    84                                 {
    85                                     jQuery('#wp-user-profile-avatar-preview img').attr('src', responce.avatar_original);
    86                                     jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', responce.avatar_thumbnail);
    87 
    88                                     jQuery('.update-user-profile-avatar #wpupa-url').val('');
    89                                     jQuery('.update-user-profile-avatar #wpupaattachmentid').val('');
    90                                     jQuery('#wp-user-profile-avatar-remove-button').hide();
    91                                 }
    92                             }
    93                         });
     60                        jQuery( '#wp-user-profile-avatar-remove' ).hide();
    9461                    },
    9562
     
    10471                    undoAvatar: function (event)
    10572                    {
    106                         jQuery('#upload-avatar-responce').removeClass('wp-user-profile-avatar-error');
    107                         jQuery('#upload-avatar-responce').removeClass('wp-user-profile-avatar-success');
    108                         jQuery('#upload-avatar-responce').html('');
     73                        jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', wp_user_profile_avatar_frontend_avatar.default_avatar );
     74                        jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', wp_user_profile_avatar_frontend_avatar.default_avatar );
     75                        jQuery( '#wpupaattachmentid' ).attr( 'value', '' );
    10976
    110                         var form_data = jQuery('.update-user-profile-avatar').serialize();
    111 
    112                         var fd = new FormData();
    113                         fd.append("action", 'undo_user_avatar');
    114                         fd.append("form_data", form_data);
    115                         fd.append("security", wp_user_profile_avatar_frontend_avatar.wp_user_profile_avatar_security);
    116 
    117                         jQuery.ajax({
    118                             url: wp_user_profile_avatar_frontend_avatar.ajax_url,
    119                             type: 'post',
    120                             dataType: 'JSON',
    121                             data: fd,
    122                             processData: false,
    123                             contentType: false,
    124                             success: function (responce)
    125                             {
    126                                 jQuery('#upload-avatar-responce').addClass(responce.class);
    127                                 jQuery('#upload-avatar-responce').html(responce.message);
    128 
    129                                 if (responce.class == 'wp-user-profile-avatar-success')
    130                                 {
    131                                     jQuery('#wp-user-profile-avatar-preview img').attr('src', responce.avatar_original);
    132                                     jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', responce.avatar_thumbnail);
    133 
    134                                     jQuery('#wp-user-profile-avatar-undo-button').hide();
    135                                 }
    136                             }
    137                         });
     77                        jQuery( '#wp-user-profile-avatar-undo-button' ).hide();
     78                        jQuery('#update-user-profile-avatar').trigger('reset');
    13879                    },
    13980
     
    169110                            success: function (responce)
    170111                            {
    171                                 console.log(responce);
    172112                                jQuery('#upload-avatar-responce').addClass(responce.class);
    173113                                jQuery('#upload-avatar-responce').html(responce.message);
     
    178118                                    jQuery('#wp-user-profile-avatar-thumbnail img').attr('src', responce.avatar_thumbnail);
    179119                                    jQuery('#update-user-profile-avatar').trigger('reset');
    180                                     //jQuery('#wp-user-profile-avatar-undo-button').show();
     120                                    jQuery('#wpupaattachmentid').val(response.form_wpupaattachmentid);
     121
     122                                    if (response.form_wpupaattachmentid == '0') {
     123                                        jQuery('#wp-user-profile-avatar-remove-button').hide();
     124                                         jQuery( '#wp-user-profile-avatar-preview img' ).attr( 'src', wp_user_profile_avatar_frontend_avatar.default_avatar );
     125                                        jQuery( '#wp-user-profile-avatar-thumbnail img' ).attr( 'src', wp_user_profile_avatar_frontend_avatar.default_avatar );
     126                                       
     127                                    } else {
     128                                        jQuery('#wp-user-profile-avatar-remove-button').show();
     129                                    }
    181130                                }
    182 
    183131                                location.reload();
    184132                            }
    185133                        });
    186 
    187134                    },
    188 
    189135                } /* end of action */
    190 
    191136    }; /* enf of return */
    192 
    193137}; /* end of class */
    194138
  • wp-user-profile-avatar/trunk/assets/js/frontend-avatar.min.js

    r3106296 r3123813  
    1 var FrontendAvatar=function(){return{init:function(){jQuery("#wp-user-profile-avatar-add").on("click",FrontendAvatar.actions.chooseAvatar),jQuery("#wp-user-profile-avatar-remove").on("click",FrontendAvatar.actions.removeAvatar),jQuery("#wp-user-profile-avatar-undo").on("click",FrontendAvatar.actions.undoAvatar),jQuery("#wp-user-profile-avatar-update-profile").on("click",FrontendAvatar.actions.updateAvatar)},actions:{chooseAvatar:function(a){var r;if(a.preventDefault(),r){r.open();return}(r=wp.media.frames.file_frame=wp.media({title:jQuery(this).data("uploader_title"),button:{text:jQuery(this).data("uploader_button_text")},multiple:!1})).on("select",function(){attachment=r.state().get("selection").first().toJSON(),console.log(attachment),jQuery("#wpupaattachmentid").attr("value",attachment.id),jQuery("#wp-user-profile-avatar-preview img").attr("src",attachment.sizes.full.url),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",attachment.sizes.thumbnail.url)}),r.open()},removeAvatar:function(a){jQuery("#upload-avatar-responce").removeClass("wp-user-profile-avatar-error"),jQuery("#upload-avatar-responce").removeClass("wp-user-profile-avatar-success"),jQuery("#upload-avatar-responce").html("");var r=jQuery(".update-user-profile-avatar").serialize(),e=new FormData;e.append("action","remove_user_avatar"),e.append("form_data",r),e.append("security",wp_user_profile_avatar_frontend_avatar.wp_user_profile_avatar_security),jQuery.ajax({url:wp_user_profile_avatar_frontend_avatar.ajax_url,type:"post",dataType:"JSON",data:e,processData:!1,contentType:!1,success:function(a){jQuery("#upload-avatar-responce").addClass(a.class),"wp-user-profile-avatar-success"==a.class&&(jQuery("#wp-user-profile-avatar-preview img").attr("src",a.avatar_original),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",a.avatar_thumbnail),jQuery(".update-user-profile-avatar #wpupa-url").val(""),jQuery(".update-user-profile-avatar #wpupaattachmentid").val(""),jQuery("#wp-user-profile-avatar-remove-button").hide())}})},undoAvatar:function(a){jQuery("#upload-avatar-responce").removeClass("wp-user-profile-avatar-error"),jQuery("#upload-avatar-responce").removeClass("wp-user-profile-avatar-success"),jQuery("#upload-avatar-responce").html("");var r=jQuery(".update-user-profile-avatar").serialize(),e=new FormData;e.append("action","undo_user_avatar"),e.append("form_data",r),e.append("security",wp_user_profile_avatar_frontend_avatar.wp_user_profile_avatar_security),jQuery.ajax({url:wp_user_profile_avatar_frontend_avatar.ajax_url,type:"post",dataType:"JSON",data:e,processData:!1,contentType:!1,success:function(a){jQuery("#upload-avatar-responce").addClass(a.class),jQuery("#upload-avatar-responce").html(a.message),"wp-user-profile-avatar-success"==a.class&&(jQuery("#wp-user-profile-avatar-preview img").attr("src",a.avatar_original),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",a.avatar_thumbnail),jQuery("#wp-user-profile-avatar-undo-button").hide())}})},updateAvatar:function(a){jQuery("#upload-avatar-responce").removeClass("wp-user-profile-avatar-error"),jQuery("#upload-avatar-responce").removeClass("wp-user-profile-avatar-success"),jQuery("#upload-avatar-responce").html("");var r=jQuery(".update-user-profile-avatar").serialize(),e=new FormData;e.append("user-avatar",jQuery("#wp-user-profile-avatar-add")),e.append("action","update_user_avatar"),e.append("form_data",r),e.append("security",wp_user_profile_avatar_frontend_avatar.wp_user_profile_avatar_security),jQuery.ajax({url:wp_user_profile_avatar_frontend_avatar.ajax_url,type:"post",dataType:"JSON",data:e,processData:!1,contentType:!1,success:function(a){console.log(a),jQuery("#upload-avatar-responce").addClass(a.class),jQuery("#upload-avatar-responce").html(a.message),"wp-user-profile-avatar-success"==a.class&&(jQuery("#wp-user-profile-avatar-preview img").attr("src",a.avatar_original),jQuery("#wp-user-profile-avatar-thumbnail img").attr("src",a.avatar_thumbnail),jQuery("#update-user-profile-avatar").trigger("reset")),location.reload()}})}}}};FrontendAvatar=FrontendAvatar(),jQuery(document).ready(function(a){FrontendAvatar.init()});
     1var FrontendAvatar=function(){return{init:function(){jQuery('#wp-user-profile-avatar-add').off("click").on('click',FrontendAvatar.actions.chooseAvatar);jQuery('#wp-user-profile-avatar-remove').off("click").on('click',FrontendAvatar.actions.removeAvatar);jQuery('#wp-user-profile-avatar-undo').off("click").on('click',FrontendAvatar.actions.undoAvatar);jQuery('#wp-user-profile-avatar-update-profile').off("click").on('click',FrontendAvatar.actions.updateAvatar)},actions:{chooseAvatar:function(event){var upload=wp.media({library:{type:'image'},title:wp_user_profile_avatar_frontend_avatar.media_box_title,multiple:false}).on('select',function(){var select=upload.state().get('selection');var attach=select.first().toJSON();jQuery('#wp-user-profile-avatar-preview img').attr('src',attach.url);jQuery('#wp-user-profile-avatar-thumbnail img').attr('src',attach.url);jQuery('#wpupaattachmentid').attr('value',attach.id);jQuery('#wp_user_profile_avatar_radio').trigger('click');jQuery('#wp-user-profile-avatar-undo-button').show()}).open()},removeAvatar:function(event){jQuery('#wp-user-profile-avatar-preview img').attr('src',wp_user_profile_avatar_frontend_avatar.default_avatar);jQuery('#wp-user-profile-avatar-thumbnail img').attr('src',wp_user_profile_avatar_frontend_avatar.default_avatar);jQuery('#wpupaattachmentid').attr('value','');jQuery('#wpupa-url').attr('value','');jQuery('#wp-user-profile-avatar-remove').hide()},undoAvatar:function(event){jQuery('#wp-user-profile-avatar-preview img').attr('src',wp_user_profile_avatar_frontend_avatar.default_avatar);jQuery('#wp-user-profile-avatar-thumbnail img').attr('src',wp_user_profile_avatar_frontend_avatar.default_avatar);jQuery('#wpupaattachmentid').attr('value','');jQuery('#wp-user-profile-avatar-undo-button').hide();jQuery('#update-user-profile-avatar').trigger('reset')},updateAvatar:function(event){jQuery('#upload-avatar-responce').removeClass('wp-user-profile-avatar-error');jQuery('#upload-avatar-responce').removeClass('wp-user-profile-avatar-success');jQuery('#upload-avatar-responce').html('');var form_data=jQuery('.update-user-profile-avatar').serialize();var fd=new FormData();fd.append("user-avatar",jQuery('#wp-user-profile-avatar-add'));fd.append("action",'update_user_avatar');fd.append("form_data",form_data);fd.append("security",wp_user_profile_avatar_frontend_avatar.wp_user_profile_avatar_security);jQuery.ajax({url:wp_user_profile_avatar_frontend_avatar.ajax_url,type:'post',dataType:'JSON',data:fd,processData:false,contentType:false,success:function(responce){jQuery('#upload-avatar-responce').addClass(responce.class);jQuery('#upload-avatar-responce').html(responce.message);if(responce.class=='wp-user-profile-avatar-success'){jQuery('#wp-user-profile-avatar-preview img').attr('src',responce.avatar_original);jQuery('#wp-user-profile-avatar-thumbnail img').attr('src',responce.avatar_thumbnail);jQuery('#update-user-profile-avatar').trigger('reset');jQuery('#wpupaattachmentid').val(response.form_wpupaattachmentid);if(response.form_wpupaattachmentid=='0'){jQuery('#wp-user-profile-avatar-remove-button').hide();jQuery('#wp-user-profile-avatar-preview img').attr('src',wp_user_profile_avatar_frontend_avatar.default_avatar);jQuery('#wp-user-profile-avatar-thumbnail img').attr('src',wp_user_profile_avatar_frontend_avatar.default_avatar)}else{jQuery('#wp-user-profile-avatar-remove-button').show()}}location.reload()}})}}}};FrontendAvatar=FrontendAvatar();jQuery(document).ready(function($){FrontendAvatar.init()});
  • wp-user-profile-avatar/trunk/external/elementor-widgets/elementor-user-profile-avatar.php

    r3106296 r3123813  
    148148
    149149        $this->add_control(
     150            'custom_link',
     151            array(
     152                'label'   => esc_html__( 'Custom URL', 'wp-user-profile-avatar' ),
     153                'type'    => Controls_Manager::TEXT,
     154                'default' => '',
     155                'condition' => array(
     156                    'link' => 'custom',
     157                ),
     158            )
     159        );
     160
     161        $this->add_control(
    150162            'target',
    151163            array(
     
    186198            $target = '_self';
    187199        }
    188 
     200        if ( $settings['link'] == 'custom' ){
     201            $settings['link'] = $settings['custom_link'];
     202        }
    189203        echo '<div class="elementor-user-profile-avatar-widget">';
    190204        echo do_shortcode( '[user_profile_avatar user_id="' . $settings['user_id'] . '" size="' . $settings['size'] . '" align="' . $settings['align'] . '" link="' . $settings['link'] . '" target="' . $target . '"]' . $settings['content'] . '[/user_profile_avatar]' );
  • wp-user-profile-avatar/trunk/external/external.php

    r3106296 r3123813  
    77
    88// check Elementor Plugin istallation.
    9 if ( ! function_exists( '_is_elementor_installed' ) ) {
     9if ( ! function_exists( 'wpupa_is_elementor_installed' ) ) {
    1010
    11     function _is_elementor_installed() {
     11    function wpupa_is_elementor_installed() {
    1212        $file_path         = 'elementor/elementor.php';
    1313        $installed_plugins = get_plugins();
  • wp-user-profile-avatar/trunk/includes/wp-user-profile-avatar-user.php

    r3106296 r3123813  
    55    exit;
    66}
    7 
    87/**
    9  * WPUPA_User class.
     8 * WPUPA_User class. 
    109 */
    1110class WPUPA_User {
    12 
    1311    /**
    1412     * Constructor - get the plugin hooked in and ready
     
    1614    public function __construct() {
    1715        add_filter( 'get_avatar_url', array( $this, 'wpupa_get_user_avatar_url' ), 10, 3 );
     16        add_filter('get_avatar', array( $this, 'wpupa_integrate_user_avatar_to_bbpress_profile' ), 10, 5);
    1817    }
    19 
    2018    /**
    2119     * wpupa_get_user_avatar_url function.
     
    3634            return false;
    3735        }
    38 
    3936        $user_id = null;
    4037        if ( is_object( $id_or_email ) ) {
     
    5451
    5552        // First checking custom avatar.
    56         if ( check_wpupa_url( $user_id ) ) {
     53        if ( wpupa_check_wpupa_url( $user_id ) ) {
    5754            $url = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
    5855        } elseif ( $wpupa_disable_gravatar ) {
    5956            $url = wpupa_get_default_avatar_url( array( 'size' => 'thumbnail' ) );
    6057        } else {
    61             $has_valid_url = check_wpupa_gravatar( $id_or_email );
     58            $has_valid_url = wpupa_check_wpupa_gravatar( $id_or_email );
    6259            if ( ! $has_valid_url ) {
    6360                $url = wpupa_get_default_avatar_url( array( 'size' => 'thumbnail' ) );
     
    6865            }
    6966        }
    70 
    7167        return esc_url( $url );
    7268    }
     69    /**
     70     * wpupa_integrate_user_avatar_to_bbpress_profile function.
     71     *
     72     * @access public
     73     * @param $avatar, $id_or_email, $size, $default, $alt
     74     * @return
     75     * @since 1.0
     76     */
     77    public function wpupa_integrate_user_avatar_to_bbpress_profile($avatar, $id_or_email, $size, $default, $alt) {
     78       
     79        // Get the user ID
     80        if (is_numeric($id_or_email)) {
     81            $user_id = (int) $id_or_email;
     82        } elseif (is_object($id_or_email)) {
     83            $user_id = $id_or_email->user_id;
     84        } else {
     85            $user = get_user_by('email', $id_or_email);
     86            $user_id = $user ? $user->ID : 0;
     87        }
    7388
     89        // Get the user avatar profile picture URL
     90        $attachment_id = esc_attr( get_user_meta( $user_id, '_wpupa_attachment_id', true ) );
     91        $image_source = wp_get_attachment_image_src( $attachment_id );
     92         
     93        if ($image_source) {
     94            $avatar = "<img alt='{$alt}' src='{$image_source[0]}' class='avatar avatar-{$size} photo' height='{$image_source[2]}' width='{$image_source[1]}' />";
     95        }
     96
     97        return $avatar;
     98    }
    7499}
    75 
    76100new WPUPA_User();
  • wp-user-profile-avatar/trunk/readme.txt

    r3106296 r3123813  
    66Requires at least: 5.8
    77Tested up to: 6.5.4
    8 Stable tag: 1.0.3
     8Stable tag: 1.0.4
    99Requires PHP: 8.0.2
    1010License: GNU General Public License v3.0
     
    327327
    328328== Changelog ==
     329
     330= 1.0.4 [July 19th, 2024] =
     331
     332Fixed: The Avatar spelling is rectified.
     333Fixed : Deprecated code error is fixed.
     334Fixed : Check marked again visible in the box.
     335Fixed: Profile image remains the same when changing user name.
     336Fixed: Issue related to the “Avatar link to” option is resolved.
     337Fixed: Adding shortcode-related problem is resolved.
     338Fixed: New profile image is no more visible after refreshing the page.
     339Fixed: No undefined text is visible in the size attribute value.
     340Fixed: Shortcode attribute-related issue is resolved.
     341Fixed: Proper user image is now displayed in each user profile avatar.
     342Fixed: Issue related to the option “open link in a new window” is resolved.
     343Fixed: Space is added between the two buttons.
     344Fixed: User role is now saved properly.
     345Fixed: The issue related to the appearance of a new image when the update button is pressed is resolved.
     346Fixed: The image button is not visible after removing an image.
     347Fixed: The Undo button is now visible on the shortcode page.
     348Fixed: The blue default user icon is now visible.
     349Fixed : Comment enable/disable issue is fixed.
    329350
    330351= 1.0.3 [June 11th, 2024] =
  • wp-user-profile-avatar/trunk/shortcodes/wp-author-social-info-shortcodes.php

    r3106296 r3123813  
    66 * Class to define author box social info by using shortcode
    77 */
    8 
    9 class WPUPA_authorbox_socialinfo_Shortcodes {
     8class WPUPA_Authorbox_Socialinfo_Shortcodes {
    109
    1110    /**
     
    1312     */
    1413    public function __construct() {
    15         add_shortcode( 'authorbox_social_link', array( $this, 'authorbox_social_link' ) );
     14        add_shortcode( 'authorbox_social_link', array( $this, 'wpupa_authorbox_social_link' ) );
    1615    }
    1716
    1817    /**
    19      * authorbox_social_link function
     18     * wpupa_authorbox_social_link function
    2019     *
    2120     * @access public
     
    2322     * @since 1.0
    2423     */
    25     public function authorbox_social_link() {
     24    public function wpupa_authorbox_social_link() {
    2625
    2726        $id = get_current_user_id();
     
    3130        ob_start();
    3231
    33         include_once WPUPA_PLUGIN_DIR . '/templates/wp-author-box-social-info.php';
     32        include_once WPUPA_PLUGIN_DIR . '/includes/wp-author-box-social-info.php';
    3433
    3534        return ob_get_clean();
     
    3837}
    3938
    40 new WPUPA_authorbox_socialinfo_Shortcodes();
     39new WPUPA_Authorbox_Socialinfo_Shortcodes();
  • wp-user-profile-avatar/trunk/shortcodes/wp-user-display.php

    r3106296 r3123813  
    66 * Class to define user details by using shortcode
    77 */
    8 
    98class WPUPA_User_Shortcodes {
    109
     
    1312     */
    1413    public function __construct() {
    15         add_shortcode( 'user_display', array( $this, 'user_display' ) );
     14        add_shortcode( 'user_display', array( $this, 'wpupa_user_display' ) );
    1615    }
    1716
    1817    /**
    19      * user_display function
     18     * display user profile avatar function
    2019     *
    2120     * @access public
     
    2423     * @since 1.0
    2524     */
    26     public function user_display() {
     25    public function wpupa_user_display( $atts ) {
    2726
    28         $id = get_current_user_id();
     27        $atts = shortcode_atts(
     28            array(
     29                'id' => '',
     30                'email' => '',
     31                'avatar_size' => '',
     32                'avatar_align' => 'center',
     33            ),
     34            $atts,
     35            'user_display'
     36        );
     37
     38        // Ensure either 'id' or 'email' is provided
     39        if ( empty( $atts['id'] ) && empty( $atts['email'] ) ) {
     40            return 'Error: Please provide either a user ID or email.';
     41        }
     42
     43        // Determine user ID
     44        if ( ! empty( $atts['id'] ) ) {
     45            $id = intval( $atts['id'] );
     46        } elseif ( ! empty( $atts['email'] ) ) {
     47            $user = get_user_by( 'email', $atts['email'] );
     48            $id = $user ? $user->ID : 0;
     49        }
     50
     51        // If no user found, return an error message
     52        if ( $id == 0 ) {
     53            return 'Error: User not found.';
     54        }
     55
     56        // Fetch user profile image
     57        $attachment = get_user_meta( $id, '_wpupa_attachment_id', true );
     58        $image_source = wp_get_attachment_image_src( $attachment );
     59 
     60        if ( $details['avatar_size'] != '' && $image_source ) {
     61            $size = $details['avatar_size'];
     62            $image_source[1] = $size;
     63        }
    2964
    3065        $details = array(
     
    3570            'sabox_social_links'  => get_the_author_meta( 'sabox_social_links', $id ),
    3671            'sabox-profile-image' => esc_url( get_the_author_meta( 'sabox-profile-image', $id ) ),
     72            'avatar_size'         => $atts['avatar_size'],
     73            'avatar_align'        => esc_attr( $atts['avatar_align'] ),
    3774        );
    3875
  • wp-user-profile-avatar/trunk/shortcodes/wp-user-profile-avatar-shortcodes.php

    r3106296 r3123813  
    22
    33if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    4 
    54class WPUPA_Shortcodes {
    65
     
    87     * Constructor - get the plugin hooked in and ready
    98     */
    10     public function __construct() {
    11 
    12         add_shortcode( 'authorbox_social_info', array( $this, 'authorbox_social_info' ) );
    13         add_shortcode( 'authorbox_social_link', array( $this, 'authorbox_social_link' ) );
    14         add_shortcode( 'user_display', array( $this, 'user_display' ) );
    15         add_shortcode( 'user_profile_avatar', array( $this, 'user_profile_avatar' ) );
    16         add_shortcode( 'user_profile_avatar_upload', array( $this, 'user_profile_avatar_upload' ) );
     9    public function __construct() {
     10
     11        add_shortcode( 'authorbox_social_info', array( $this, 'wpupa_authorbox_social_info' ) );
     12        add_shortcode( 'authorbox_social_link', array( $this, 'wpupa_authorbox_social_link' ) );
     13        add_shortcode( 'user_display', array( $this, 'wpupa_user_display' ) );
     14        add_shortcode( 'user_profile_avatar', array( $this, 'wpupa_user_profile_avatar' ) );
     15        add_shortcode( 'user_profile_avatar_upload', array( $this, 'wpupa_user_profile_avatar_upload' ) );
     16        add_shortcode( 'all_user_avatars', array( $this, 'wpupa_all_user_avatars' ) );
    1717
    1818        add_action( 'wp_ajax_update_user_avatar', array( $this, 'update_user_avatar' ) );
     
    3333     * @since 1.0
    3434     */
    35     public function authorbox_social_info( $atts = array(), $content = null ) {
     35    public function wpupa_authorbox_social_info( $atts = array(), $content = null ) {
    3636        global $blog_id, $post, $wpdb;
    3737
     
    5151        ob_start();
    5252
    53         include_once WPUPA_PLUGIN_DIR . '/templates/wp-author-box-display.php';
     53        include_once WPUPA_PLUGIN_DIR . '/includes/wp-author-box-display.php';
    5454
    5555        return ob_get_clean();
     
    5757
    5858    /**
    59      * authorbox_social_link function
     59     * wpupa_authorbox_social_link function
    6060     *
    6161     * @access public
     
    6464     * @since 1.0
    6565     */
    66     public function authorbox_social_link() {
     66    public function wpupa_authorbox_social_link() {
    6767
    6868        $id = get_current_user_id();
     
    7878
    7979    /**
    80      * user_display function
     80     * wpupa_user_display function
    8181     *
    8282     * @access public
     
    8585     * @since 1.0
    8686     */
    87     public function user_display() {
     87    public function wpupa_user_display() {
    8888
    8989        $id = get_current_user_id();
     
    106106
    107107    /**
    108      * user_profile_avatar function.
     108     * wpupa_all_user_avatars function
     109     *
     110     * @access public
     111     * @param $atts
     112     * @return
     113     *
     114     */
     115    public function wpupa_all_user_avatars( $atts ) {
     116        $atts = shortcode_atts( array(
     117            'roles'             => '',
     118            'avatar_size'       => 100,
     119            'border_radius'     => 0,
     120            'align'             => '',
     121            'limit'             => '',
     122            'max_bio_length'    => -1,
     123            'min_post_count'    => 0,
     124            'page_size'         => 10,
     125            'order'             => 'ID',
     126            'sort_direction'    => 'asc',
     127            'render_as_list'    => 'false',
     128            'hiddenusers'       => '',
     129            'link_to_authorpage'=> '',
     130            'user_link'         => '',
     131            'show_name'         => '',
     132            'show_biography'    => '',
     133            'show_postcount'    => '',
     134            'blogs'             => '',
     135        ), $atts, 'all_user_avatars');
     136       
     137        $roles = !empty( $atts['roles'] ) ? array_map( 'trim', explode( ',', $atts['roles'] ) ) : array();
     138
     139        $hidden_users = !empty( $atts['hiddenusers'] ) ? array_map( 'trim', explode( ',', $atts['hiddenusers'] ) ) : array();
     140
     141        $order = !empty( $atts['order'] ) ? esc_attr( $atts['order'] ) : 'ID';
     142        $sort_direction = in_array( strtolower( $atts['sort_direction'] ), array( 'desc', 'descending' ) ) ? 'DESC' : 'ASC';
     143
     144        $paged = max( 1, get_query_var( 'paged', 1 ) );
     145        $offset = ( $paged - 1 ) * $atts['page_size'];
     146
     147        $user_avatars = array();
     148
     149        // Check if blogs attribute is specified for WPMU mode
     150        if ( !empty( $atts['blogs'] ) && is_multisite() ) {
     151            $blog_ids = array_map( 'trim', explode( ',', $atts['blogs'] ) );
     152
     153            foreach ( $blog_ids as $blog_id ) {
     154               
     155                switch_to_blog( $blog_id );
     156
     157                $args = array(
     158                    'role__in'      => $roles,
     159                    'exclude'       => $hidden_users,
     160                    'fields'        => array( 'ID', 'display_name', 'description' ),
     161                    'number'        => $atts['limit'],
     162                    'orderby'       => $order,
     163                    'order'         => $sort_direction,
     164                    'count_total'   => false,
     165                );
     166
     167                $user_query = new WP_User_Query( $args );
     168                $users = $user_query->get_results();
     169               
     170                if ( !empty( $atts['min_post_count'] ) ) {
     171                    $min_post_count = ( int ) $atts['min_post_count'];
     172                    if ( $min_post_count > 0 ) {
     173                        $users = array_filter( $users, function( $user ) use ( $min_post_count ) {
     174                            return count_user_posts( $user->ID ) >= $min_post_count;
     175                        });
     176                    }
     177                }
     178
     179                foreach ( $users as $user ) {
     180                    $avatar_url = get_avatar_url( $user->ID, array( 'size' => $atts['avatar_size'] ) );
     181                    $user_data = array(
     182                        'display_name'  => esc_html( $user->display_name ),
     183                        'avatar_url'    => esc_url( $avatar_url ),
     184                        'ID'            => $user->ID,
     185                    );
     186
     187                    if ( !empty( $atts['show_name'] ) && $atts['show_name'] === 'true' ) {
     188                        $user_data['show_name'] = true;
     189                    }
     190
     191                    if ( !empty( $atts['show_biography'] ) && $atts['show_biography'] === 'true' ) {
     192                        if ( $atts['max_bio_length'] > 0 ) {
     193                           
     194                            $user_data['biography'] = substr(get_the_author_meta( 'description', $user->ID ), 0, $atts['max_bio_length']);
     195                        } else {
     196                            $user_data['biography'] = get_the_author_meta( 'description', $user->ID );
     197                        }
     198                    }
     199
     200                    if ( !empty($atts['show_postcount'] ) && $atts['show_postcount'] === 'true' ) {
     201                        $user_data['post_count'] = count_user_posts( $user->ID );
     202                    }
     203
     204                    if ( !empty($atts['user_link'] ) ) {
     205                        $user_data['user_link'] = sanitize_key($atts['user_link']);
     206                    }
     207                    if ( ! empty( $atts['align'] ) ) {
     208                        $this->userlist->align = esc_attr( $atts['align'] );
     209                    }
     210                   
     211                    $user_avatars[] = $user_data;
     212                }
     213
     214                // Restore the original blog context
     215                restore_current_blog();
     216            }
     217        } else {
     218            // No specific blogs provided
     219            $args = array(
     220                'role__in'  => $roles,
     221                'exclude'   => $hidden_users,
     222                'fields'    => array( 'ID', 'display_name', 'description' ),
     223                'number'    => $atts['limit'],
     224                'orderby'   => $order,
     225                'order'     => $sort_direction,
     226                'count_total'=> false,
     227            );
     228
     229            $user_query = new WP_User_Query( $args );
     230            $users = $user_query->get_results();
     231           
     232            if ( !empty( $atts['min_post_count'] ) ) {
     233                $min_post_count = ( int ) $atts['min_post_count'];
     234                if ( $min_post_count > 0 ) {
     235                    $users = array_filter( $users, function( $user ) use ( $min_post_count ) {
     236                        return count_user_posts( $user->ID ) >= $min_post_count;
     237                    } );
     238                }
     239            }
     240
     241            $total_users = count( $users );
     242            $total_pages = ceil( $total_users / $atts['page_size'] );
     243            $users = array_slice( $users, $offset, $atts['page_size'] );
     244
     245            foreach ( $users as $user ) {
     246                $avatar_url = get_avatar_url( $user->ID, array( 'size' => $atts['avatar_size'] ) );
     247                $user_data = array(
     248                    'display_name'  => esc_html( $user->display_name ),
     249                    'avatar_url'    => esc_url( $avatar_url ),
     250                    'ID'            => $user->ID,
     251                );
     252
     253                if ( !empty( $atts['show_name'] ) && $atts['show_name'] === 'true' ) {
     254                    $user_data['show_name'] = true;
     255                }
     256
     257                if ( !empty( $atts['show_biography'] ) && $atts['show_biography'] === 'true' ) {
     258                    if ( $atts['max_bio_length'] > 0 ) {
     259                       
     260                        $user_data['biography'] = substr(get_the_author_meta( 'description', $user->ID ), 0, $atts['max_bio_length']);
     261                    } else {
     262                        $user_data['biography'] = get_the_author_meta( 'description', $user->ID );
     263                    }
     264                }
     265
     266                if ( !empty($atts['show_postcount'] ) && $atts['show_postcount'] === 'true' ) {
     267                    $user_data['post_count'] = count_user_posts( $user->ID );
     268                }
     269
     270                if ( !empty( $atts['user_link'] ) ) {
     271                    $user_data['user_link'] = sanitize_key( $atts['user_link'] );
     272                }
     273               
     274                $user_avatars[] = $user_data;
     275            }
     276        }
     277
     278        ob_start();
     279
     280        include_once WPUPA_PLUGIN_DIR . '/templates/wp-display-user-avatar-list.php';
     281
     282        return ob_get_clean();
     283    }
     284    /**
     285     * wpupa_user_profile_avatar function.
    109286     *
    110287     * @access public
     
    113290     * @since 1.0
    114291     */
    115     public function user_profile_avatar( $atts = array(), $content = null ) {
     292    public function wpupa_user_profile_avatar( $atts = array(), $content = null ) {
    116293        global $blog_id, $post, $wpdb;
    117294
     
    126303                    'size'    => esc_attr( 'thumbnail' ),
    127304                    'align'   => esc_attr( 'alignnone' ),
    128                     'link'    => esc_url( '#' ),
     305                    'link'    => esc_attr( '#' ),
    129306                    'target'  => esc_attr( '_self' ),
     307                    'url'     => esc_attr( '' ),
    130308                ),
    131309                $atts
     
    133311        );
    134312
    135         if ( $admin_avatar_size ) {
    136             $size = $admin_avatar_size;
    137         }
     313        $user_id = !empty( $user_id ) ? esc_attr( $user_id ) : $current_user_id;
     314        $size = !empty( $atts['size'] ) ? sanitize_text_field( $atts['size'] ) : sanitize_text_field( $admin_avatar_size );
     315        $align = sanitize_text_field( $atts['align'] );
     316        $link =  !empty($atts['link']) ? sanitize_text_field($atts['link']) : '#' ;
     317        $target = !empty($atts['target']) ? sanitize_text_field($atts['target']) : '_self';
     318        $url = !empty($atts['url']) ?  sanitize_text_field($atts['url'])  : '';
     319
     320        if( !empty( $atts['size'] ) ){
     321            $size = esc_attr( $atts['size'] );
     322        }else{
     323            $size = esc_attr( $admin_avatar_size );
     324        }
     325
     326        if ($link === 'custom' && empty($url)) {
     327            return '<div class="error-message" style="color:red;">Error: You must provide a URL when using the "custom" link option. Please include the "url" attribute in your shortcode.</div>';
     328        }
    138329
    139330        ob_start();
    140             $image_url = esc_url( wpupa_get_url( $current_user_id, array( 'size' => esc_attr( $size ) ) ) );
     331           
     332        $image_url = esc_url( wpupa_get_url( $user_id, array( 'size' => esc_attr( $size ) ) ) );
    141333        if ( $link == 'image' ) {
    142334            // Get image src
    143             $link = wpupa_get_url( $current_user_id, array( 'size' => 'original' ) );
     335            $link = esc_url( wpupa_get_url( $user_id, array( 'size' => 'original' ) ) );
    144336        } elseif ( $link == 'attachment' ) {
    145337            // Get attachment URL
    146             $link = get_attachment_link( get_the_author_meta( $wpdb->get_blog_prefix( esc_attr( $blog_id ) ) . 'user_avatar', esc_attr( $user_id ) ) );
    147         }
     338            $link = esc_url( get_attachment_link( get_the_author_meta( $wpdb->get_blog_prefix( esc_attr( $blog_id ) ) . 'user_avatar', esc_attr( $user_id ) ) ) );
     339        } elseif ( $link == 'custom' ){
     340            $link = $url;
     341       } elseif ( $link == 'none' ){
     342           $link = '#';
     343       }
    148344
    149345        include_once WPUPA_PLUGIN_DIR . '/templates/wp-user-avatar.php';
     
    151347        return ob_get_clean();
    152348    }
    153 
    154     /**
    155      * user_profile_avatar_upload function.
     349    /**
     350     * wpupa_user_profile_avatar_upload function.
    156351     *
    157352     * @access public
     
    160355     * @since 1.0
    161356     */
    162     public function user_profile_avatar_upload( $atts = array(), $content = null ) {
     357    public function wpupa_user_profile_avatar_upload( $atts = array(), $content = null ) {
    163358        extract(
    164359            shortcode_atts(
     
    211406        $wpupa_thumbnail = esc_url( wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) ) );
    212407
    213         $wpupaattachmentid = esc_attr( get_user_meta( $user_id, '_wpupaattachmentid', true ) );
     408        $wpupaattachmentid = esc_attr( get_user_meta( $user_id, '_wpupa_attachment_id', true ) );
    214409        $wpupa_url         = esc_url( get_user_meta( $user_id, '_wpupa_url', true ) );
    215410
     
    253448                // Upload file
    254449                $overrides     = array( 'test_form' => false );
    255                 $uploaded_file = $this->handle_upload( $file, $overrides );
     450                $uploaded_file = $this->wpupa_handle_upload( $file, $overrides );
    256451
    257452                $attachment = array(
     
    288483            }
    289484
    290             /*
    291             $wpupaattachmentid = get_user_meta($user_id, '_wpupa_attachment_id', true);
    292             $wpupa_url = get_user_meta($user_id, '_wpupa_url', true);
    293 
    294             if (empty($wpupaattachmentid) && empty($wpupa_url)) {
    295                 $wpupa_original = '';
    296                 $wpupa_thumbnail = '';
    297                 $message = __('Error! Select Image', 'wp-user-profile-avatar');
    298                 $class = 'wp-user-profile-avatar-error';
    299             } else {*/
    300                 $wpupa_original  = wpupa_get_url( $user_id, array( 'size' => 'original' ) );
    301                 $wpupa_thumbnail = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
    302                 $message         = __( 'Successfully Updated Avatar', 'wp-user-profile-avatar' );
    303                 $class           = 'wp-user-profile-avatar-success';
    304             /*}*/
     485            $wpupa_original  = wpupa_get_url( $user_id, array( 'size' => 'original' ) );
     486            $wpupa_thumbnail = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
     487            $message         = __( 'Successfully Updated Avatar', 'wp-user-profile-avatar' );
     488            $class           = 'wp-user-profile-avatar-success';           
     489
     490            echo wp_json_encode(
     491                array(
     492                    'avatar_original'  => $wpupa_original,
     493                    'avatar_thumbnail' => $wpupa_thumbnail,
     494                    'message'          => esc_attr( $message ),
     495                    'class'            => esc_attr( $class ),
     496                    'form_wpupaattachmentid' => esc_attr( $form_wpupaattachmentid ),
     497                )
     498            );
     499        else :
     500            $message = __( 'Permission Denied', 'wp-user-profile-avatar' );
     501            $class   = 'wp-user-profile-avatar-errors';
     502            echo wp_json_encode(
     503                array(
     504                    'message' => $message,
     505                    'class'   => $class,
     506                )
     507            );
     508        endif;
     509        wp_die();
     510    }
     511
     512    /**
     513     * remove_user_avatar function.
     514     *
     515     * @access public
     516     * @param
     517     * @return
     518     * @since 1.0
     519     */
     520    public function remove_user_avatar() {
     521        check_ajax_referer( '_nonce_user_profile_avatar_security', 'security' );
     522
     523        parse_str( sanitize_text_field($_POST['form_data']), $form_data );
     524
     525        // sanitize each of the values of form data
     526        $wpupa_url         = esc_url_raw( $form_data['wpupa-url'] );
     527        $wpupaattachmentid = absint( $form_data['wpupaattachmentid'] );
     528        $user_id           = absint( $form_data['user_id'] );
     529        $current_user_id   = get_current_user_id();
     530
     531        if ( $current_user_id == $user_id ) :
     532            if ( isset( $user_id ) ) {
     533                update_user_meta( $user_id, '_wpupaattachmentid', '' );
     534                update_user_meta( $user_id, '_wpupa_url', '' );
     535                update_user_meta( $user_id, '_wpupa_default', '' );
     536
     537                // delete also attachment
     538                wp_delete_attachment( $wpupaattachmentid, true );
     539            }
     540
     541            $wpupa_original  = wpupa_get_url( $user_id, array( 'size' => 'original' ) );
     542            $wpupa_thumbnail = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
     543
     544            $message = __( 'Successfully Removed Avatar', 'wp-user-profile-avatar' );
     545            $class   = 'wp-user-profile-avatar-success';
    305546
    306547            echo wp_json_encode(
     
    317558            echo wp_json_encode(
    318559                array(
    319                     'message' => $message,
    320                     'class'   => $class,
     560                    'message' => esc_attr( $message ),
     561                    'class'   => esc_attr( $class ),
    321562                )
    322563            );
     
    326567
    327568    /**
    328      * remove_user_avatar function.
     569     * undo_user_avatar function.
    329570     *
    330571     * @access public
     
    333574     * @since 1.0
    334575     */
    335     public function remove_user_avatar() {
     576    public function undo_user_avatar() {
    336577        check_ajax_referer( '_nonce_user_profile_avatar_security', 'security' );
    337578
     
    349590                update_user_meta( $user_id, '_wpupa_url', '' );
    350591                update_user_meta( $user_id, '_wpupa_default', '' );
    351 
    352                 // delete also attachment
    353                 wp_delete_attachment( $wpupaattachmentid, true );
    354592            }
    355593
     
    357595            $wpupa_thumbnail = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
    358596
    359             $message = __( 'Successfully Removed Avatar', 'wp-user-profile-avatar' );
     597            $message = __( 'Successfully Undo Avatar', 'wp-user-profile-avatar' );
    360598            $class   = 'wp-user-profile-avatar-success';
    361599
     
    380618        wp_die();
    381619    }
    382 
    383     /**
    384      * undo_user_avatar function.
    385      *
    386      * @access public
    387      * @param
    388      * @return
    389      * @since 1.0
    390      */
    391     public function undo_user_avatar() {
    392         check_ajax_referer( '_nonce_user_profile_avatar_security', 'security' );
    393 
    394         parse_str( sanitize_text_field($_POST['form_data']), $form_data );
    395 
    396         // sanitize each of the values of form data
    397         $wpupa_url         = esc_url_raw( $form_data['wpupa-url'] );
    398         $wpupaattachmentid = absint( $form_data['wpupaattachmentid'] );
    399         $user_id           = absint( $form_data['user_id'] );
    400         $current_user_id   = get_current_user_id();
    401 
    402         if ( $current_user_id == $user_id ) :
    403             if ( isset( $user_id ) ) {
    404                 update_user_meta( $user_id, '_wpupaattachmentid', '' );
    405                 update_user_meta( $user_id, '_wpupa_url', '' );
    406                 update_user_meta( $user_id, '_wpupa_default', '' );
    407             }
    408 
    409             $wpupa_original  = wpupa_get_url( $user_id, array( 'size' => 'original' ) );
    410             $wpupa_thumbnail = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
    411 
    412             $message = __( 'Successfully Undo Avatar', 'wp-user-profile-avatar' );
    413             $class   = 'wp-user-profile-avatar-success';
    414 
    415             echo wp_json_encode(
    416                 array(
    417                     'avatar_original'  => $wpupa_original,
    418                     'avatar_thumbnail' => $wpupa_thumbnail,
    419                     'message'          => esc_attr( $message ),
    420                     'class'            => esc_attr( $class ),
    421                 )
    422             );
    423         else :
    424             $message = __( 'Permission Denied', 'wp-user-profile-avatar' );
    425             $class   = 'wp-user-profile-avatar-errors';
    426             echo wp_json_encode(
    427                 array(
    428                     'message' => esc_attr( $message ),
    429                     'class'   => esc_attr( $class ),
    430                 )
    431             );
    432         endif;
    433         wp_die();
    434     }
    435 
    436     /**
    437      * handle_upload function.
     620    /**
     621     * wpupa_handle_upload function.
    438622     *
    439623     * @access public
     
    442626     * @since 1.0
    443627     */
    444     public function handle_upload( $file_handler, $overrides ) {
     628    public function wpupa_handle_upload( $file_handler, $overrides ) {
    445629        require_once ABSPATH . 'wp-admin/includes/image.php';
    446630        require_once ABSPATH . 'wp-admin/includes/file.php';
    447631        require_once ABSPATH . 'wp-admin/includes/media.php';
    448 
    449632        $upload = wp_handle_upload( $file_handler, $overrides );
    450 
    451633        return $upload;
    452634    }
    453 
    454635    /**
    455636     * wpupa_get_user_avatar_url function.
     
    471652            return false;
    472653        }
    473 
    474654        $user_id = null;
    475655        if ( is_object( $id_or_email ) ) {
    476             if ( ! empty( $id_or_email->comment_author_email ) ) {
     656            if ( ! empty( $id_or_email->comment_author_email ) ) { 
    477657                $user_id = $id_or_email->user_id;
    478658            }
     
    490670        // First checking custom avatar.
    491671        if ( get_current_user_id() == $user_id || is_admin() ) {
    492             if ( check_wpupa_url( $user_id ) ) {
     672            if ( wpupa_check_wpupa_url( $user_id ) ) {
    493673                $url = wpupa_get_url( $user_id, array( 'size' => 'thumbnail' ) );
    494674            } elseif ( $wpupa_disable_gravatar ) {
    495675                $url = wpupa_get_default_avatar_url( array( 'size' => 'thumbnail' ) );
    496676            } else {
    497                 $has_valid_url = check_wpupa_gravatar( $id_or_email );
     677                $has_valid_url = wpupa_check_wpupa_gravatar( $id_or_email );
    498678                if ( ! $has_valid_url ) {
    499679                    $url = wpupa_get_default_avatar_url( array( 'size' => 'thumbnail' ) );
     
    505685            }
    506686        }
    507 
    508687        return $url;
    509688    }
    510 
    511689}
    512690new WPUPA_Shortcodes();
  • wp-user-profile-avatar/trunk/templates/wp-author-box-display.php

    r3106296 r3123813  
    1818        </div>
    1919    </div>
    20     <?php
    21     /**
    22      * authorbox_social_link function
    23      *
    24      * @access public
    25      * @param $atts
    26      * @return
    27      * @since 1.0
    28      */
    29     ?>
    3020         
    3121    <!-- Display social link to the author  page-->
  • wp-user-profile-avatar/trunk/templates/wp-avatar-upload.php

    r3106296 r3123813  
    2121                        <button type="button" class="button" id="wp-user-profile-avatar-add" ><?php esc_html_e( 'Choose Image', 'wp-user-profile-avatar' ); ?></button>
    2222
    23                         <input type="hidden" name="wpupaattachmentid" id="wpupaattachmentid">
     23                        <input type="hidden" name="wpupaattachmentid" id="wpupaattachmentid" value="<?php echo esc_attr( $wpupaattachmentid ); ?>">
    2424                        <input type="hidden" name="user_id" id="wp-user-id" value="<?php echo esc_attr( $user_id ); ?>">
    25 
    2625                    </p>
    2726                </td>
     
    2928
    3029            <?php
    31             // $class_hide = 'wp-user-profile-avatar-hide';
     30            $class_hide = 'wp-user-profile-avatar-hide';
    3231            if ( ! empty( $wpupaattachmentid ) || ! empty( $wpupa_url ) ) {
    3332                $class_hide = '';
     
    4443                        <span class="description"><?php esc_html_e( 'Thumbnail', 'wp-user-profile-avatar' ); ?></span>
    4544                    </p>
    46                     <p id="wp-user-profile-avatar-remove-button" class="<?php // echo esc_attr($class_hide); ?>">
     45                    <p id="wp-user-profile-avatar-remove-button" class="<?php echo esc_attr($class_hide); ?>">
    4746                        <button type="button" class="button" id="wp-user-profile-avatar-remove"><?php esc_html_e( 'Remove Image', 'wp-user-profile-avatar' ); ?></button>
    4847                    </p>
  • wp-user-profile-avatar/trunk/templates/wp-display-user.php

    r3106296 r3123813  
    88?>
    99
    10 <div class="author-details">
     10<div class="author-details" style="text-align: <?php echo esc_attr( $details['avatar_align'] ); ?>;">
    1111    <p class="caption-text"><?php echo isset( $details['first_name'] ) ? esc_attr( $details['first_name'] ) : ''; ?></p>
    1212    <p class="caption-text"><?php echo isset( $details['last_name'] ) ? esc_attr( $details['last_name'] ) : ''; ?></p>
     
    2222    }
    2323
    24     if ( '' != esc_attr( $details['sabox-profile-image'] ) ) {
     24    if ( isset( $image_source ) && $image_source ) {
    2525        ?>
    26         <img src="<?php echo esc_attr( $details['sabox-profile-image'] ); ?>" />
    27     <?php } ?>
     26        <img src="<?php echo esc_url( $image_source[0] ); ?>" width="<?php echo esc_attr( $image_source[1] ); ?>" />
     27        <?php
     28    }
     29    ?>
    2830
    2931</div>
  • wp-user-profile-avatar/trunk/templates/wp-user-avatar.php

    r3106296 r3123813  
    44 */
    55if ( ! defined( 'ABSPATH' ) ) {
    6     exit;
     6    exit; 
    77}
    88?>
     
    1111    <a href="<?php echo esc_url( $link ); ?>" target="<?php echo esc_attr( $target ); ?>" class="wp-user-profile-avatar-link">
    1212        <?php if ( is_array( $image_url ) ) { ?>
    13             <img src="<?php echo esc_url( $image_url[0] ); ?>" class="size-<?php echo esc_attr( $size ); ?> <?php echo esc_attr( $align ); ?>" width="<?php echo esc_attr( $image_url[1] ); ?>" height="<?php echo esc_attr( $image_url[2] ); ?>" alt="<?php echo esc_attr( $content ); ?>" />
     13            <img src="<?php echo esc_url( $image_url[0] ); ?>" class="size-<?php echo esc_attr( $size ); ?> <?php echo esc_attr( $align ); ?>" width="<?php echo esc_attr( $image_url[1] ); ?>" height="<?php echo esc_attr( $image_url[2] ); ?>" alt="<?php echo esc_attr( $content ); ?>" target="<?php echo esc_url( $target ); ?>"/>
    1414        <?php } else { ?>
    15             <img src="<?php echo esc_url( $image_url ); ?>" class="size-<?php echo esc_attr( $size ); ?> <?php echo esc_attr( $align ); ?>" alt="<?php echo esc_attr( $content ); ?>" />
     15            <img src="<?php echo esc_url( $image_url ); ?>" class="size-<?php echo esc_attr( $size ); ?> <?php echo esc_attr( $align ); ?>" alt="<?php echo esc_attr( $content ); ?>" target="<?php echo esc_url( $target ); ?>"/>
    1616        <?php } ?>
    1717    </a>
  • wp-user-profile-avatar/trunk/wp-user-profile-avatar-functions.php

    r3106296 r3123813  
    33
    44    /**
    5      * wpupa_get_rating function.
     5     * get user avatar rating function.
    66     *
    77     * @access public
     
    2626
    2727    /**
    28      * wpupa_get_file_size function.
     28     * get file size function.
    2929     *
    3030     * @access public
     
    5656
    5757    /**
    58      * wpupa_get_default_avatar function.
     58     * get default user avatar function.
    5959     *
    6060     * @access public
     
    110110
    111111    /**
    112      * wpupa_get_default_avatar_url function.
     112     * get default avatar urlS function.
    113113     *
    114114     * @access public
     
    173173
    174174    /**
    175      * wpupa_get_url function.
     175     * get url fro usser profile avatar function.
    176176     *
    177177     * @access public
     
    221221            );
    222222        }
    223 
    224     }
    225 }
    226 
    227 if ( ! function_exists( 'check_wpupa_url' ) ) {
    228 
    229     /**
    230      * check_wpupa_url function.
     223    }
     224}
     225
     226if ( ! function_exists( 'wpupa_check_wpupa_url' ) ) {
     227
     228    /**
     229     * check if profile avatar url or not function.
    231230     *
    232231     * @access public
     
    235234     * @since 1.0
    236235     */
    237     function check_wpupa_url( $user_id = '' ) {
     236    function wpupa_check_wpupa_url( $user_id = '' ) {
    238237        $attachment_url = esc_url( get_user_meta( $user_id, '_wpupa_url', true ) );
    239238
     
    250249}
    251250
    252 if ( ! function_exists( 'check_wpupa_gravatar' ) ) {
    253 
    254     /**
    255      * check_wpupa_gravatar function.
     251if ( ! function_exists( 'wpupa_check_wpupa_gravatar' ) ) {
     252
     253    /**
     254     * check it is gratavatar or not function.
    256255     *
    257256     * @access public
     
    260259     * @since 1.0
    261260     */
    262     function check_wpupa_gravatar( $id_or_email = '', $check_gravatar = 0, $user = '', $email = '' ) {
     261    function wpupa_check_wpupa_gravatar( $id_or_email = '', $check_gravatar = 0, $user = '', $email = '' ) {
    263262        $wp_user_hash_gravatar = get_option( 'wp_user_hash_gravatar' );
    264263
     
    336335            $check_gravatar = false;
    337336        }
    338 
    339             // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
     337        // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
    340338        return (bool) $check_gravatar;
    341339    }
     
    345343
    346344    /**
    347      * wpupa_get_image_sizes function.
     345     * get profile image size function.
    348346     *
    349347     * @access public
     
    368366
    369367    /**
    370      * wpupa_get_image_alignment function.
     368     * get profile image alignment function.
    371369     *
    372370     * @access public
     
    390388
    391389    /**
    392      * wpupa_get_image_link_to function.
     390     * get profile image link function.
    393391     *
    394392     * @access public
     
    416414
    417415    /**
    418      * wpb_show_current_user_attachments function.
     416     * show current user attachments function.
    419417     *
    420418     * @access public
     
    438436
    439437    /**
    440      * wpupa_file_size_limit function.
     438     * get file size limit function.
    441439     *
    442440     * Limit upload size for non-admins. Admins get the default limit
     
    457455    add_filter( 'upload_size_limit', 'wpupa_file_size_limit' );
    458456}
     457if ( ! function_exists( 'delete_comments_everywhere' ) ) {
     458   
     459    /**
     460     * delete comments from entire website function.
     461     *
     462     * delete comment on entire website
     463     *
     464     * @access public
     465     * @param
     466     * @return array
     467     * @since 1.0
     468     */
     469    function delete_comments_everywhere() {
     470        global $wpdb;
     471        return $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE 1=1" );
     472    }
     473}
     474
     475if ( ! function_exists( 'delete_comments_by_post_types' ) ) {
     476   
     477    /**
     478     * delete comments from selected post types in website function.
     479     *
     480     * delete comment on selected places on website
     481     *
     482     * @access public
     483     * @param
     484     * @return array
     485     * @since 1.0
     486     */
     487    function delete_comments_by_post_types( $post_types ) {
     488        global $wpdb;
     489        $post_type_placeholders = implode( "','", $post_types );
     490        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->comments} WHERE comment_post_ID IN (SELECT ID FROM {$wpdb->posts} WHERE post_type IN ('%s'))", $post_type_placeholders ) );
     491    }
     492}
     493use \WPUPA_WpUserNameChange\WPUPA_WpUserNameChange;
     494
     495if ( ! function_exists( 'wpupa_username_edit' ) ) {
     496    /**
     497     * edit user name function.
     498     *
     499     * edit username from backend side
     500     *
     501     * @access public
     502     * @param
     503     * @return array
     504     * @since 1.0
     505     */
     506    function wpupa_username_edit() { ?>
     507        <div class="wrap userupdater">
     508            <p>
     509                <h1>
     510                    <?php esc_html_e( 'Wp Users List', 'wp-user-profile-avatar' ); ?>
     511                </h1>
     512            </p>
     513            <?php
     514            $wpuser  = new WPUPA_WpUserNameChange();
     515            $records = $wpuser->wpuser_select();
     516
     517            if ( $records ) {
     518                ?>
     519                <table class="wp-list-table widefat fixed striped users"  cellpadding="3" cellspacing="3" width="100%">
     520                    <thead>
     521                        <tr>
     522                            <th>
     523                                <strong>
     524                                    <?php esc_html_e( 'User ID', 'wp-user-profile-avatar' ); ?>
     525                                </strong>
     526                            </th>
     527                            <th>
     528                                <strong>
     529                                    <?php esc_html_e( 'User Name', 'wp-user-profile-avatar' ); ?>
     530                                </strong>
     531                            </th>
     532                            <th>
     533                                <strong>
     534                                    <?php esc_html_e( 'Role', 'wp-user-profile-avatar' ); ?>
     535                                </strong>
     536                            </th>
     537                            <th>
     538                                <strong>
     539                                    <?php esc_html_e( 'Update', 'wp-user-profile-avatar' ); ?>
     540                                </strong>
     541                            </th>
     542                        </tr>
     543                    </thead>
     544                    <tbody>
     545                        <?php
     546                        foreach ( $records as $user ) {
     547                            $user_info = get_userdata( $user->ID );
     548                            ?>
     549                            <tr>
     550                                <td><?php echo esc_attr( $user->ID ); ?></td>
     551                                <td><?php echo esc_attr( $user->user_login ); ?></td>
     552                                <td><?php echo esc_html( implode( ', ', ( $user_info->roles ) ) ); ?></td>
     553                                <td>
     554                                    <a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=wpupa_username_update&update=' . $user->ID ) ) ); ?>">
     555                                        <?php esc_html_e( 'update', 'wp-user-profile-avatar' ); ?>
     556                                    </a>
     557                                </td>
     558                            </tr>
     559                        <?php } ?>
     560                    </tbody>
     561                </table>
     562            <?php } ?>
     563        </div>
     564        <?php
     565    }
     566}
     567
     568if ( ! function_exists( 'wpupa_user_update' ) ) {
     569    /**
     570     * update username function.
     571     *
     572     * update username from backend side
     573     *
     574     * @access public
     575     * @param
     576     * @return array
     577     * @since 1.0
     578     */
     579    function wpupa_user_update() {
     580        if ( isset( $_REQUEST['update'] ) ) {
     581            if(!current_user_can('manage_options' ) || wp_verify_nonce( 'update','_wpnonce' ) ){
     582                return;
     583            }
     584            $wpuser = new WPUPA_WpUserNameChange();
     585            global $wpdb;
     586            $id        = trim( sanitize_text_field( $_REQUEST['update'] ) );
     587            $user_info = get_userdata( $id );
     588            $result    = $wpdb->get_results( $wpdb->prepare( "SELECT * from $wpdb->users WHERE ID = %d", $id ) );
     589            foreach ( $result as $user ) {
     590                $username = $user->user_login;
     591            }
     592            if ( ! empty( $_REQUEST['submit'] ) ) {
     593                $name = sanitize_user( $_POST['user_login'] );
     594                if ( empty( $name ) ) {
     595                    $errorMsg = 'Error : Please do not enter  empty username.';
     596                } elseif ( username_exists( $name ) ) {
     597                    $errorMsg = 'Error: This username(<i>' . esc_attr( $name ) . '</i>) is already exist.';
     598                } else {
     599                    $wpuser->wpuser_update( $id, $name );
     600                    echo '<div class="updated"><p><strong>Username Updated</strong></p></div>';
     601                }
     602            }
     603            ?>
     604            <div class="wrap">
     605                <h1><?php esc_html_e( 'Update WP Username', 'wp-user-profile-avatar' ); ?></h1>
     606                <?php
     607                if ( isset( $errorMsg ) ) {
     608                    echo "<div class='error'><p><strong>" . esc_attr( $errorMsg ) . '</strong></p></div>';
     609                }
     610                ?>
     611            </div>
     612            <form method="post" id="user-udate" action="<?php echo esc_url( sanitize_url( $_SERVER['REQUEST_URI'] ) ); ?>">
     613                <table class="form-table">
     614                    <tr>
     615                        <th><label for="olduser-login"><?php esc_html_e( 'Old Username', 'wp-user-profile-avatar' ); ?></label></th>
     616                        <td><strong><?php echo esc_attr( $username ); ?></strong></td>
     617                    </tr>
     618                    <tr>
     619                        <th><label for="user-login"><?php esc_html_e( 'New Username', 'wp-user-profile-avatar' ); ?></label></th>
     620                        <td><input type="text" name="user_login" class="regular-text" id="user_login" value="
     621                        <?php
     622                        if ( ! empty( $_POST['user-login'] ) ) {
     623                            echo esc_attr( $name );
     624                        }
     625                        ?>
     626                        "/></td>
     627                    </tr>
     628                </table>
     629                <input type="submit" name="submit" id="submit" class="button button-primary" value="Update WP Username">
     630            </form>
     631        <?php } else { ?>
     632            <script>
     633                window.location = '<?php echo esc_url( admin_url( 'admin.php?page=wpupa_username_change' ) ); ?>'
     634            </script>
     635            <?php
     636        }
     637    }
     638}
  • wp-user-profile-avatar/trunk/wp-user-profile-avatar.php

    r3106296 r3123813  
    88 * Text Domain: wp-user-profile-avatar
    99 * Domain Path: /languages
    10  * Version: 1.0.3
     10 * Version: 1.0.4
    1111 * Since: 1.0.0
    1212 * Requires WordPress Version at least: 5.8
     
    2323
    2424/**
    25  * WP_User_Profile_Avatar class.
     25 * WPUPA_User_Profile_Avatar class.
    2626 */
    27 class WP_User_Profile_Avatar {
     27class WPUPA_User_Profile_Avatar {
    2828
    2929    /**
     
    5858
    5959        // Define constants
    60         define( 'WPUPA_VERSION', '1.0.3' );
     60        define( 'WPUPA_VERSION', '1.0.4' );
    6161        define( 'WPUPA_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
    6262        define( 'WPUPA_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
     
    6464        // Includes
    6565        include 'includes/wp-user-profile-avatar-install.php';
    66         // include( 'includes/wp-user-profile-avatar-user.php' );
    6766        include 'wp-user-profile-avatar-functions.php';
    68         include_once 'admin/templates/wp-username-change.php';
    69         include_once 'disable-comments.php';
    70         include_once 'templates/wp-author-box-social-info.php';
    71         include_once 'templates/wp-add-new-avatar.php';
    72         include_once 'templates/wp-avatar-social profile-picture.php';
     67        include_once 'includes/wp-username-change.php';
     68        include_once 'wp-user-profile-avatar-disable-comments.php';
     69        include_once 'includes/wp-author-box-social-info.php';
     70        include_once 'includes/wp-add-new-avatar.php';
     71        include_once 'includes/wp-avatar-social profile-picture.php';
    7372
    7473        // shortcodes
     
    8079        include 'external/external.php';
    8180
    82         include_once 'templates/wp-author-box-social-info.php';
    83 
    8481        // Activation / deactivation - works with symlinks
    85         register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this, 'activate' ) );
     82        register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this, 'wpupa_activate' ) );
    8683
    8784        // Actions
    88         add_action( 'after_setup_theme', array( $this, 'load_plugin_textdomain' ) );
     85        add_action( 'after_setup_theme', array( $this, 'wpupa_load_plugin_textdomain' ) );
    8986
    90         add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
     87        add_action( 'wp_enqueue_scripts', array( $this, 'wpupa_frontend_scripts' ) );
    9188
    9289        if ( is_admin() ) {
     
    9693        // Filters
    9794        add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'wpupa_settings_link' ) );
    98 
    9995    }
    10096
    10197    /**
    102      * activate function.
     98     * plugin activation function.
    10399     *
    104100     * @access public
     
    107103     * @since 1.0.0
    108104     */
    109     public function activate() {
     105    public function wpupa_activate() {
    110106        // installation process after activating
    111107        WPUPA_Install::install();
     
    113109
    114110    /**
    115      * load_plugin_textdomain function.
     111     * load plugin text domain function.
    116112     *
    117113     * @access public
     
    120116     * @since 1.0.0
    121117     */
    122     public function load_plugin_textdomain() {
     118    public function wpupa_load_plugin_textdomain() {
    123119
    124120        $domain = 'wp-user-profile-avatar';
     
    132128
    133129    /**
    134      * frontend_scripts function.
     130     * enqueue script and style function.
    135131     *
    136132     * @access public
     
    139135     * @since 1.0
    140136     */
    141     public function frontend_scripts() {
     137    public function wpupa_frontend_scripts() {
    142138
    143139        wp_enqueue_media();
     
    146142
    147143        wp_register_script( 'wp-user-profile-avatar-frontend-avatar', WPUPA_PLUGIN_URL . '/assets/js/frontend-avatar.min.js', array( 'jquery' ), WPUPA_VERSION, true );
    148         wp_enqueue_script( 'wp-user-profile-avatar-frontend-avatar-custom', WPUPA_PLUGIN_URL . '/assets/js/frontend-custom.js', array( 'jquery' ), WPUPA_VERSION, true );
     144       
    149145        wp_localize_script(
    150146            'wp-user-profile-avatar-frontend-avatar',
     
    160156
    161157    /**
    162      * wpupa_settings_link function.
     158     * set the setting page link function.
    163159     *
    164160     * Create link on plugin page for wp user profile avatar plugin settings.
     
    185181function WPUPA() {
    186182    // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
    187     return WP_User_Profile_Avatar::instance();
     183    return WPUPA_User_Profile_Avatar::instance();
    188184}
    189185$GLOBALS['wp_user_profile_avatar'] = WPUPA();
Note: See TracChangeset for help on using the changeset viewer.