| @@ -1,220 +1,287 @@ | ||
| 1 | -<?php | |
| 2 | -if (! defined('ABSPATH')) exit; // if direct access | |
| 1 | +<?php | |
| 3 | 2 | |
| 4 | -if (!(current_user_can('manage_options'))) exit; | |
| 3 | +/* | |
| 4 | +* @Author ParaTheme | |
| 5 | +* Copyright: 2015 ParaTheme | |
| 6 | +*/ | |
| 5 | 7 | |
| 8 | +if ( ! defined('ABSPATH')) exit; // if direct access | |
| 6 | 9 | |
| 7 | -$current_tab = isset($_REQUEST['tab']) ? sanitize_text_field(wp_unslash($_REQUEST['tab'])) : 'general'; | |
| 8 | 10 | |
| 9 | -$team_settings_tab = array(); | |
| 10 | 11 | |
| 11 | -$team_settings_tab[] = array( | |
| 12 | - 'id' => 'general', | |
| 13 | -/* translators: Icon HTML */ | |
| 14 | - 'title' => sprintf(__('%s General', 'team'), '<i class="fas fa-list-ul"></i>'), | |
| 15 | - 'priority' => 1, | |
| 16 | - 'active' => ($current_tab == 'general') ? true : false, | |
| 17 | -); | |
| 12 | +if(empty($_POST['team_hidden'])){ | |
| 13 | + $team_member_slug = get_option( 'team_member_slug' ); | |
| 14 | + $team_member_meta_fields = get_option( 'team_member_meta_fields' ); | |
| 15 | + $team_member_social_field = get_option( 'team_member_social_field' ); | |
| 18 | 16 | |
| 19 | -$team_settings_tab[] = array( | |
| 20 | - 'id' => 'team_member', | |
| 21 | -/* translators: Icon HTML */ | |
| 22 | - 'title' => sprintf(__('%s Team member', 'team'), '<i class="fas fa-user-tag"></i>'), | |
| 23 | - 'priority' => 2, | |
| 24 | - 'active' => ($current_tab == 'team_member') ? true : false, | |
| 25 | -); | |
| 17 | + } | |
| 18 | +else{ | |
| 19 | + if($_POST['team_hidden'] == 'Y') { | |
| 20 | + //Form data sent | |
| 26 | 21 | |
| 22 | + $team_member_slug = sanitize_text_field($_POST['team_member_slug']); | |
| 23 | + update_option('team_member_slug', $team_member_slug); | |
| 24 | + | |
| 25 | + if(empty($_POST['team_member_meta_fields'])){ | |
| 26 | + | |
| 27 | + $_POST['team_member_meta_fields'] = array(); | |
| 28 | + } | |
| 29 | + $team_member_meta_fields = stripslashes_deep($_POST['team_member_meta_fields']); | |
| 30 | + update_option('team_member_meta_fields', $team_member_meta_fields); | |
| 27 | 31 | |
| 28 | -$team_settings_tab[] = array( | |
| 29 | - 'id' => 'help_support', | |
| 30 | -/* translators: Icon HTML */ | |
| 31 | - 'title' => sprintf(__('%s Help & support', 'team'), '<i class="fas fa-hands-helping"></i>'), | |
| 32 | - 'priority' => 3, | |
| 33 | - 'active' => ($current_tab == 'help_support') ? true : false, | |
| 34 | -); | |
| 32 | + $team_member_social_field = stripslashes_deep($_POST['team_member_social_field']); | |
| 33 | + update_option('team_member_social_field', $team_member_social_field); | |
| 35 | 34 | |
| 36 | -$team_settings_tab[] = array( | |
| 37 | - 'id' => 'buy_pro', | |
| 38 | -/* translators: Icon HTML */ | |
| 39 | - 'title' => sprintf(__('%s Buy Pro', 'team'), '<i class="fas fa-store"></i>'), | |
| 40 | - 'priority' => 9, | |
| 41 | - 'active' => ($current_tab == 'buy_pro') ? true : false, | |
| 42 | -); | |
| 35 | + ?> | |
| 36 | + <div class="updated"><p><strong><?php _e('Changes Saved.', 'team' ); ?></strong></p></div> | |
| 37 | + | |
| 38 | + <?php | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 43 | 42 | |
| 44 | -$team_settings_tab = apply_filters('team_settings_tabs', $team_settings_tab); | |
| 45 | 43 | |
| 46 | -$tabs_sorted = array(); | |
| 47 | 44 | |
| 48 | -if (!empty($team_settings_tab)) | |
| 49 | - foreach ($team_settings_tab as $page_key => $tab) $tabs_sorted[$page_key] = isset($tab['priority']) ? $tab['priority'] : 0; | |
| 50 | -array_multisort($tabs_sorted, SORT_ASC, $team_settings_tab); | |
| 45 | + $class_team_functions = new class_team_functions(); | |
| 46 | + $default_social_field = $class_team_functions->team_member_social_field(); | |
| 51 | 47 | |
| 48 | +?> | |
| 52 | 49 | |
| 53 | -wp_enqueue_script('jquery'); | |
| 54 | -wp_enqueue_script('jquery-ui-sortable'); | |
| 55 | -wp_enqueue_script('jquery-ui-core'); | |
| 56 | -wp_enqueue_script('jquery-ui-accordion'); | |
| 57 | -wp_enqueue_style('wp-color-picker'); | |
| 58 | -wp_enqueue_script('wp-color-picker'); | |
| 59 | -wp_enqueue_style('font-awesome-5'); | |
| 60 | -wp_enqueue_style('settings-tabs'); | |
| 61 | -wp_enqueue_script('settings-tabs'); | |
| 62 | 50 | |
| 63 | - | |
| 64 | -$review_status = isset($_GET['review_status']) ? sanitize_text_field(wp_unslash($_GET['review_status'])) : ''; | |
| 65 | -$team_plugin_info = get_option('team_plugin_info'); | |
| 66 | -$team_settings = get_option('team_settings'); | |
| 67 | - | |
| 68 | -?> | |
| 69 | 51 | <div class="wrap"> |
| 70 | - <div id="icon-tools" class="icon32"><br></div> | |
| 71 | - <h2><?php | |
| 72 | -/* translators: PLugin Name */ | |
| 73 | -echo esc_html(sprintf(__('%s Settings', 'team'), team_plugin_name)) ?></h2> | |
| 74 | 52 | |
| 53 | + <div id="icon-tools" class="icon32"><br></div><?php echo "<h2>".__(team_plugin_name.' Settings', 'team')."</h2>";?> | |
| 54 | + <form method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> | |
| 55 | + <input type="hidden" name="team_hidden" value="Y"> | |
| 56 | + <?php settings_fields( 'team_plugin_options' ); | |
| 57 | + do_settings_sections( 'team_plugin_options' ); | |
| 58 | + | |
| 59 | + ?> | |
| 75 | 60 | |
| 76 | - <?php | |
| 77 | - $gmt_offset = get_option('gmt_offset'); | |
| 78 | - $current_date = gmdate('Y-m-d H:i:s', strtotime('+' . $gmt_offset . ' hour')); | |
| 79 | - //echo '<pre>'.var_export($current_date, true).'</pre>'; | |
| 61 | + <div class="para-settings team-settings"> | |
| 62 | + | |
| 63 | + <ul class="tab-nav"> | |
| 64 | + <li nav="1" class="nav1 active"><i class="fa fa-cogs"></i> Options</li> | |
| 65 | + | |
| 66 | + </ul> <!-- tab-nav end --> | |
| 67 | + <ul class="box"> | |
| 68 | + <li style="display: block;" class="box1 tab-box active"> | |
| 69 | + | |
| 70 | + <div class="option-box"> | |
| 71 | + <p class="option-title"><?php _e('Team member slug.','team'); ?></p> | |
| 72 | + <p class="option-info"><?php _e('ex: volunteers','team'); ?></p> | |
| 73 | + <input type="text" size="30" placeholder="team_member_slug" name="team_member_slug" value="<?php if(!empty($team_member_slug)) echo $team_member_slug; ?>" /> | |
| 74 | + | |
| 75 | + </div> | |
| 76 | + <div class="option-box"> | |
| 77 | + <p class="option-title"><?php _e('Custom meta fields on team member profile.','team'); ?></p> | |
| 78 | + <p class="option-info"><?php _e('','team'); ?></p> | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + <div class=""> | |
| 83 | + <table class="widefat team-member-meta-fields"> | |
| 84 | + <thead> | |
| 85 | + <tr> | |
| 86 | + <th>Sorting</th> | |
| 87 | + <th>Meta Name</th> | |
| 88 | + <th >Meta Key<br/><i style="font-size:10px;">Must be unique, no blank space, can use (_)underscore</i></th> | |
| 89 | + <th>Remove</th> | |
| 90 | + </tr> | |
| 91 | + </thead> | |
| 92 | + <tbody> | |
| 93 | + | |
| 94 | + <?php | |
| 95 | + | |
| 96 | + if(empty($team_member_meta_fields)){ | |
| 97 | + | |
| 98 | + $team_member_meta_fields = array( | |
| 99 | + //'address' => array('name'=>'Address','meta_key'=>'team_address'), | |
| 100 | + //'mobile' => array('name'=>'Mobile','meta_key'=>'team_mobile'), | |
| 101 | + ); | |
| 102 | + | |
| 103 | + } | |
| 104 | + //var_dump($team_member_skill); | |
| 105 | + | |
| 106 | + foreach ($team_member_meta_fields as $meta_key=>$meta_info) { | |
| 107 | + | |
| 108 | + ?> | |
| 109 | + <tr> | |
| 110 | + <td class="sorting"></td> | |
| 111 | + <td> | |
| 112 | + | |
| 113 | + <?php //var_dump($skill_info); ?> | |
| 114 | + | |
| 115 | + <input type="text" size="30" placeholder="Meta Name" name="team_member_meta_fields[<?php echo $meta_key; ?>][name]" value="<?php if(!empty($team_member_meta_fields[$meta_key]['name'])) echo $team_member_meta_fields[$meta_key]['name']; ?>" /> | |
| 116 | + | |
| 117 | + </td> | |
| 118 | + <td> | |
| 119 | + <input type="text" size="30" placeholder="meta_key" name="team_member_meta_fields[<?php echo $meta_key; ?>][meta_key]" value="<?php if(!empty($team_member_meta_fields[$meta_key]['meta_key'])) echo $team_member_meta_fields[$meta_key]['meta_key']; ?>" /> | |
| 120 | + </td> | |
| 121 | + | |
| 122 | + <td> | |
| 123 | + <span class="remove-meta">X</span> | |
| 124 | + </td> | |
| 125 | + </tr> | |
| 126 | + <?php | |
| 127 | + } | |
| 128 | + ?> | |
| 129 | + </tbody> | |
| 130 | + </table> | |
| 131 | + | |
| 132 | + <div class="button add_team_member_meta">Add new</div> | |
| 133 | + </div> | |
| 134 | + | |
| 135 | + | |
| 136 | + <script> | |
| 137 | + jQuery(document).ready(function($) | |
| 138 | + { | |
| 139 | + $(function() { | |
| 140 | + $( ".team-member-meta-fields tbody" ).sortable(); | |
| 141 | + //$( ".items" ).disableSelection(); | |
| 142 | + }); | |
| 143 | + | |
| 144 | + }) | |
| 80 | 145 | |
| 81 | - | |
| 82 | - if ($review_status == 'remind_later'): | |
| 83 | - | |
| 84 | - $team_plugin_info['review_status'] = 'remind_later'; | |
| 85 | - $team_plugin_info['remind_date'] = gmdate('Y-m-d H:i:s', strtotime('+30 days')); | |
| 86 | - | |
| 87 | - | |
| 88 | - ?> | |
| 89 | - <div class="update-nag is-dismissible">We will remind you later.</div> | |
| 90 | - <?php | |
| 91 | - update_option('team_plugin_info', $team_plugin_info); | |
| 92 | - | |
| 93 | - elseif ($review_status == 'done'): | |
| 94 | - | |
| 95 | - $team_plugin_info['review_status'] = 'done'; | |
| 96 | - ?> | |
| 97 | - <div class="update-nag notice is-dismissible">Thanks for your time and feedback.</div> | |
| 98 | - <?php | |
| 99 | - | |
| 100 | - update_option('team_plugin_info', $team_plugin_info); | |
| 101 | - | |
| 102 | - endif; | |
| 103 | - | |
| 104 | - ?> | |
| 105 | - | |
| 106 | - | |
| 107 | - | |
| 108 | - <form method="post" action="<?php echo esc_url(str_replace('%7E', '~', esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])))); ?>"> | |
| 109 | - <input type="hidden" name="team_hidden" value="Y"> | |
| 110 | - <input type="hidden" name="tab" value="<?php echo esc_html($current_tab); ?>"> | |
| 111 | - | |
| 112 | - <?php | |
| 113 | - if (!empty($_POST['team_hidden'])) { | |
| 114 | - | |
| 115 | - $nonce = sanitize_text_field(wp_unslash($_POST['_wpnonce'])); | |
| 116 | - | |
| 117 | - if (wp_verify_nonce($nonce, 'team_nonce') && $_POST['team_hidden'] == 'Y') { | |
| 118 | - | |
| 119 | - do_action('team_settings_save'); | |
| 120 | - | |
| 121 | - ?> | |
| 122 | - <div class="updated notice is-dismissible"> | |
| 123 | - <p><strong><?php echo esc_html__('Changes Saved.', 'team'); ?></strong></p> | |
| 146 | +</script> | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 124 | 150 | </div> |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + <div class="option-box"> | |
| 158 | + <p class="option-title"><?php _e('Display social field on team member profile.','team'); ?></p> | |
| 159 | + <p class="option-info"><?php _e('By adding bellow input you can control extra input field under member page. if you want to remove one profile field then please empty this field and save changes or to add new profile field simply click add new. some default profile fields are mobile, website, email, skype, facebook, twitter, googleplus, pinterest.','team'); ?></p> | |
| 160 | + | |
| 161 | + <div class="button reset_team_member_social_field">Reset</div> | |
| 162 | + <table class="team_member_social_field widefat " id="team_member_social_field"> | |
| 163 | + <thead><tr><th>Sort</th><th>Meta name</th><th>Meta key</th><th>Icon</th><th>Visibility</th><th>Remove</th> | |
| 164 | + | |
| 165 | + </tr> | |
| 166 | + </thead> | |
| 167 | + <?php | |
| 125 | 168 | |
| 126 | - <?php | |
| 127 | - } | |
| 128 | - } | |
| 129 | - ?> | |
| 169 | + | |
| 170 | + if(empty($team_member_social_field)){ | |
| 171 | + $team_member_social_field = $default_social_field; | |
| 172 | + } | |
| 130 | 173 | |
| 131 | - <div class="settings-tabs-loading" style="">Loading...</div> | |
| 132 | - <div class="settings-tabs vertical has-right-panel" style="display: none"> | |
| 133 | - | |
| 134 | - | |
| 135 | - <div class="settings-tabs-right-panel"> | |
| 136 | - <?php | |
| 137 | - if (!empty($team_settings_tab)) | |
| 138 | - foreach ($team_settings_tab as $tab) { | |
| 139 | - $id = $tab['id']; | |
| 140 | - $active = $tab['active']; | |
| 141 | - | |
| 142 | - ?> | |
| 143 | - <div class="right-panel-content <?php if ($active) echo 'active'; ?> right-panel-content-<?php echo esc_attr($id); ?>"> | |
| 144 | - <?php | |
| 145 | - | |
| 146 | - do_action('team_settings_tabs_right_panel_' . $id); | |
| 174 | + foreach ($team_member_social_field as $field_key=>$field_info) { | |
| 175 | + if(!empty($field_key)) | |
| 176 | + { | |
| 147 | 177 | ?> |
| 178 | + <tr><td class="sorting"></td> | |
| 179 | + <td> | |
| 148 | 180 | |
| 149 | - </div> | |
| 150 | - <?php | |
| 181 | + <input name="team_member_social_field[<?php echo $field_key; ?>][name]" type="text" value="<?php if(isset($team_member_social_field[$field_key]['name'])) echo $team_member_social_field[$field_key]['name']; ?>" /> | |
| 182 | + </td> | |
| 183 | + | |
| 184 | + <td> | |
| 185 | + | |
| 186 | + <input name="team_member_social_field[<?php echo $field_key; ?>][meta_key]" type="text" value="<?php if(isset($team_member_social_field[$field_key]['meta_key'])) echo $team_member_social_field[$field_key]['meta_key']; ?>" /> | |
| 187 | + | |
| 188 | + | |
| 189 | + </td> | |
| 190 | + | |
| 191 | + <td> | |
| 192 | + <span style=" <?php if(!empty($team_member_social_field[$field_key]['icon'])) echo 'background:url('.$team_member_social_field[$field_key]['icon'].') no-repeat scroll 0 0 rgba(0, 0, 0, 0);'; ?>" title="Icon for this field." class="team_member_social_icon <?php if(empty($team_member_social_field[$field_key]['icon'])) echo 'empty_icon';?>" icon-name="<?php echo $field_key; ?>"> </span> | |
| 193 | + | |
| 194 | + <input class="team_member_social_icon team_member_social_icon_<?php echo $field_key; ?>" name="team_member_social_field[<?php echo $field_key; ?>][icon]" type="hidden" value="<?php if(isset($team_member_social_field[$field_key]['icon'])) echo $team_member_social_field[$field_key]['icon']; ?>" /> | |
| 195 | + | |
| 196 | + | |
| 197 | + </td> | |
| 198 | + <td> | |
| 199 | + | |
| 200 | + <?php if(isset($team_member_social_field[$field_key]['visibility'])) $checked = 'checked'; else $checked = ''; ?> | |
| 201 | + | |
| 202 | + | |
| 203 | + <input <?php echo $checked; ?> name="team_member_social_field[<?php echo $field_key; ?>][visibility]" type="checkbox" value="1" /> | |
| 204 | + | |
| 205 | + </td> | |
| 206 | + <td> | |
| 207 | + | |
| 208 | + <?php | |
| 209 | + if($field_info['can_remove']=='yes'){ | |
| 210 | + ?> | |
| 211 | + | |
| 212 | + <span class="remove_icon">X</span> | |
| 151 | 213 | |
| 152 | - } | |
| 153 | - ?> | |
| 154 | - </div> | |
| 155 | - | |
| 156 | - <ul class="tab-navs"> | |
| 157 | - <?php | |
| 158 | - if (!empty($team_settings_tab)) | |
| 159 | - foreach ($team_settings_tab as $tab) { | |
| 160 | - $id = $tab['id']; | |
| 161 | - $title = $tab['title']; | |
| 162 | - $active = $tab['active']; | |
| 163 | - $data_visible = isset($tab['data_visible']) ? $tab['data_visible'] : ''; | |
| 164 | - $hidden = isset($tab['hidden']) ? $tab['hidden'] : false; | |
| 165 | - $is_pro = isset($tab['is_pro']) ? $tab['is_pro'] : false; | |
| 166 | - $pro_text = isset($tab['pro_text']) ? $tab['pro_text'] : ''; | |
| 167 | - | |
| 168 | - | |
| 169 | - ?> | |
| 170 | - <li <?php if (!empty($data_visible)): ?> data_visible="<?php echo esc_attr($data_visible); ?>" <?php endif; ?> class="tab-nav <?php if ($hidden) echo 'hidden'; ?> <?php if ($active) echo 'active'; ?>" data-id="<?php echo esc_attr($id); ?>"> | |
| 171 | - <?php echo wp_kses_post($title); ?> | |
| 214 | + <?php | |
| 215 | + } | |
| 216 | + else{ | |
| 217 | + echo '<span title="Can\'t remove.">...</span>'; | |
| 218 | + | |
| 219 | + } | |
| 220 | + | |
| 221 | + ?> | |
| 222 | + | |
| 223 | + <input name="team_member_social_field[<?php echo $field_key; ?>][can_remove]" type="hidden" value="<?php echo $field_info['can_remove']; ?>" /> | |
| 224 | + | |
| 225 | + | |
| 226 | + </td> | |
| 227 | + | |
| 228 | + | |
| 229 | + </tr> | |
| 172 | 230 | <?php |
| 173 | - if ($is_pro): | |
| 174 | - ?><span class="pro-feature"><?php echo esc_html($pro_text); ?></span> <?php | |
| 175 | - endif; | |
| 176 | - ?> | |
| 177 | - | |
| 178 | - </li> | |
| 179 | - <?php | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 180 | 234 | } |
| 181 | - ?> | |
| 235 | + } | |
| 236 | + | |
| 237 | + ?> | |
| 182 | 238 | |
| 239 | + | |
| 240 | + </table> | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + <script> | |
| 247 | + jQuery(document).ready(function($){ | |
| 248 | + | |
| 249 | + $(function() { | |
| 250 | + $( "#team_member_social_field tbody" ).sortable(); | |
| 251 | + //$( ".items" ).disableSelection(); | |
| 252 | + }); | |
| 253 | + | |
| 254 | + }) | |
| 255 | + | |
| 256 | + </script> | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + <div class="button new_team_member_social_field"><?php _e('Add New','team'); ?></div> | |
| 262 | + | |
| 263 | + </div> | |
| 183 | 264 | |
| 265 | + | |
| 266 | + </li> | |
| 267 | + | |
| 268 | + </ul> | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 184 | 272 | |
| 185 | - </ul> | |
| 273 | + | |
| 274 | + </div> | |
| 186 | 275 | |
| 187 | 276 | |
| 188 | 277 | |
| 189 | - <?php | |
| 190 | 278 | |
| 191 | - if (!empty($team_settings_tab)) | |
| 192 | - foreach ($team_settings_tab as $tab) { | |
| 193 | - $id = $tab['id']; | |
| 194 | - $title = $tab['title']; | |
| 195 | - $active = $tab['active']; | |
| 196 | - ?> | |
| 197 | 279 | |
| 198 | - <div class="tab-content <?php if ($active) echo 'active'; ?>" id="<?php echo esc_attr($id); ?>"> | |
| 199 | - <?php | |
| 200 | - do_action('team_settings_content_' . $id, $tab); | |
| 201 | - ?> | |
| 202 | 280 | |
| 281 | +<p class="submit"> | |
| 282 | + <input class="button button-primary" type="submit" name="Submit" value="<?php _e('Save Changes','team' ); ?>" /> | |
| 283 | + </p> | |
| 284 | + </form> | |
| 203 | 285 | |
| 204 | - </div> | |
| 205 | 286 | |
| 206 | - <?php | |
| 207 | - } | |
| 208 | - ?> | |
| 209 | - | |
| 210 | - <div class="clear clearfix"></div> | |
| 211 | - <p class="submit"> | |
| 212 | - <?php wp_nonce_field('team_nonce'); ?> | |
| 213 | - <input class="button button-primary" type="submit" name="Submit" value="<?php echo esc_html__('Save Changes', 'team'); ?>" /> | |
| 214 | - </p> | |
| 215 | - | |
| 216 | - </div> | |
| 217 | - | |
| 218 | - | |
| 219 | - </form> | |
| 220 | -</div> | |
| 287 | +</div> | |