| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly. |
| 4 |
} |
| 5 |
|
| 6 |
class Fep_Admin_Settings { |
| 7 |
private static $instance; |
| 8 |
private $priority = 0; |
| 9 |
|
| 10 |
public static function init() { |
| 11 |
if ( ! self::$instance instanceof self ) { |
| 12 |
self::$instance = new self; |
| 13 |
} |
| 14 |
return self::$instance; |
| 15 |
} |
| 16 |
|
| 17 |
function actions_filters() { |
| 18 |
add_action( 'admin_menu', array( $this, 'addAdminPage' ) ); |
| 19 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
| 20 |
add_action( 'admin_init', array( $this, 'settings_output' ) ); |
| 21 |
add_action( 'admin_notices', array( $this, 'notice_review' ) ); |
| 22 |
add_filter( 'plugin_action_links_' . plugin_basename( FEP_PLUGIN_FILE ), array( $this, 'add_settings_link' ) ); |
| 23 |
add_action( 'add_option_FEP_admin_options', array( $this, 'after_option_save' ), 99 ); |
| 24 |
add_action( 'update_option_FEP_admin_options', array( $this, 'after_option_save' ), 99 ); |
| 25 |
add_action( 'fep_action_after_admin_options_save', array( $this, 'recalculate_user_message_count' ), 10, 2 ); |
| 26 |
add_action( 'publish_page', array( $this, 'set_page_id' ), 10, 2 ); |
| 27 |
} |
| 28 |
|
| 29 |
function addAdminPage() { |
| 30 |
$admin_cap = apply_filters( 'fep_admin_cap', 'manage_options' ); |
| 31 |
|
| 32 |
add_submenu_page( 'fep-all-messages', 'Front End PM - ' . __( 'Settings', 'front-end-pm' ), __( 'Settings', 'front-end-pm' ), $admin_cap, 'fep_settings', array( $this, 'settings_page' ) ); |
| 33 |
} |
| 34 |
|
| 35 |
function admin_enqueue_scripts() { |
| 36 |
if ( isset( $_GET['tab'] ) && 'appearance' == $_GET['tab'] ) { |
| 37 |
wp_enqueue_style( 'wp-color-picker' ); |
| 38 |
wp_enqueue_script( 'wp-color-picker' ); |
| 39 |
} |
| 40 |
wp_enqueue_script( 'fep-admin', FEP_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery' ), FEP_PLUGIN_VERSION, true ); |
| 41 |
wp_localize_script( 'fep-admin', 'fep_admin', |
| 42 |
array( |
| 43 |
'token' => wp_create_nonce( 'fep-admin' ), |
| 44 |
'delete' => __( 'Delete', 'front-end-pm' ), |
| 45 |
'del_confirm' => __( 'Are you sure you want to delete this?', 'front-end-pm' ), |
| 46 |
) |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
function recalculate_user_message_count( $old_value, $tab ) { |
| 51 |
global $wpdb; |
| 52 |
if ( isset( $old_value['message_view'] ) && fep_get_message_view() != $old_value['message_view'] ) { |
| 53 |
if ( 'threaded' != fep_get_message_view() ) { |
| 54 |
delete_metadata( 'user', 0, '_fep_user_message_count', '', true ); |
| 55 |
} else { |
| 56 |
update_option( '_fep_message_view_changed', 1 ); |
| 57 |
//delete_metadata( 'post', 0, '_fep_last_reply_by', '', true ); |
| 58 |
$wpdb->update( FEP_MESSAGE_TABLE, [ 'mgs_last_reply_by' => 0 ], [ 'mgs_type' => 'message', 'mgs_parent' => 0 ], ['%d'], [ '%s', '%d'] ); |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
function after_option_save( $old_value ) { |
| 64 |
global $wp_settings_sections; |
| 65 |
if ( ! is_array( $old_value ) ) { |
| 66 |
$old_value = array(); |
| 67 |
} |
| 68 |
$tab = 'general'; |
| 69 |
$is_settings_page = false; |
| 70 |
if ( ! empty( $_POST['_wp_http_referer'] ) ) { |
| 71 |
wp_parse_str( parse_url( $_POST['_wp_http_referer'], PHP_URL_QUERY ), $referrer ); |
| 72 |
$tab = ! empty( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
| 73 |
if ( isset( $referrer['page'] ) && 'fep_settings' == $referrer['page'] && ! empty( $wp_settings_sections['fep_settings_' . $tab ] ) ) { |
| 74 |
$is_settings_page = true; |
| 75 |
} |
| 76 |
} |
| 77 |
do_action( 'fep_action_after_admin_options_save', $old_value, $tab, $is_settings_page ); |
| 78 |
} |
| 79 |
|
| 80 |
public function form_fields( $section = 'general' ) { |
| 81 |
$user_role = array(); |
| 82 |
foreach ( get_editable_roles() as $key => $role ) { |
| 83 |
$user_role[ $key ] = $role['name']; |
| 84 |
} |
| 85 |
$pages = array( '' => __( 'Select Page', 'front-end-pm' ) ); |
| 86 |
foreach ( get_pages( array( 'hierarchical' => 0, 'number' => 100 ) ) as $page ) { |
| 87 |
$pages[ $page->ID ] = $page->post_title; |
| 88 |
} |
| 89 |
$page_id = fep_get_option( 'page_id', 0 ); |
| 90 |
if ( $page_id && ! isset( $pages[ $page_id ] ) && get_post( $page_id ) ) { |
| 91 |
$pages[ $page_id ] = get_the_title( $page_id ); |
| 92 |
} |
| 93 |
$fields = array( |
| 94 |
//General Settings |
| 95 |
'page_id' => array( |
| 96 |
'type' => 'select', |
| 97 |
'value' => $page_id, |
| 98 |
'priority' => 2, |
| 99 |
'label' => __( 'Front End PM Page', 'front-end-pm' ), |
| 100 |
'options' => $pages, |
| 101 |
'description'=> sprintf( __( 'The page must have %s shortcode in content.', 'front-end-pm' ), '<code>[front-end-pm]</code>' ), |
| 102 |
), |
| 103 |
'message_view' => array( |
| 104 |
'type' => 'select', |
| 105 |
'value' => fep_get_message_view(), |
| 106 |
'priority' => 3, |
| 107 |
//'section' => 'message', |
| 108 |
'label' => __( 'Message view', 'front-end-pm' ), |
| 109 |
'description'=> ( 'threaded' == fep_get_message_view() ) ? '' : __( 'This setting change will redirect you to update page for database update.', 'front-end-pm' ), |
| 110 |
'options' => array( |
| 111 |
'threaded' => __( 'Threaded', 'front-end-pm' ), |
| 112 |
'individual'=> __( 'Individual', 'front-end-pm' ), |
| 113 |
), |
| 114 |
), |
| 115 |
'messages_page' => array( |
| 116 |
'type' => 'number', |
| 117 |
'value' => fep_get_option( 'messages_page', 15 ), |
| 118 |
'priority' => 4, |
| 119 |
'label' => __( 'Messages per page', 'front-end-pm' ), |
| 120 |
'description'=> __( 'Messages to show per page.', 'front-end-pm' ), |
| 121 |
), |
| 122 |
'announcements_page' => array( |
| 123 |
'type' => 'number', |
| 124 |
'value' => fep_get_option( 'announcements_page', 15 ), |
| 125 |
'priority' => 5, |
| 126 |
'label' => __( 'Announcements per page', 'front-end-pm' ), |
| 127 |
'description'=> __( 'Announcements to show per page.', 'front-end-pm' ), |
| 128 |
), |
| 129 |
'user_page' => array( |
| 130 |
'type' => 'number', |
| 131 |
'value' => fep_get_option( 'user_page', 50 ), |
| 132 |
'priority' => 6, |
| 133 |
'label' => __( 'Maximum users per page in directory', 'front-end-pm' ), |
| 134 |
'description'=> __( 'Maximum users per page in directory.', 'front-end-pm' ), |
| 135 |
), |
| 136 |
'time_delay' => array( |
| 137 |
'type' => 'number', |
| 138 |
'value' => fep_get_option( 'time_delay', 5 ), |
| 139 |
'priority' => 8, |
| 140 |
'label' => __( 'Time delay', 'front-end-pm' ), |
| 141 |
'description'=> __( 'Time delay between two sent messages by a user in minutes (0 = no delay required).', 'front-end-pm' ), |
| 142 |
), |
| 143 |
'editor_type' => array( |
| 144 |
'type' => 'select', |
| 145 |
'value' => fep_get_option( 'editor_type', 'wp_editor' ), |
| 146 |
'priority' => 12, |
| 147 |
'label' => __( 'Editor Type', 'front-end-pm' ), |
| 148 |
//'description'=> __( 'Admin alwayes have WP Editor.', 'front-end-pm' ), |
| 149 |
'options' => array( |
| 150 |
'wp_editor' => __( 'WP Editor', 'front-end-pm' ), |
| 151 |
'teeny' => __( 'WP Editor (Teeny)', 'front-end-pm' ), |
| 152 |
'textarea' => __( 'Textarea', 'front-end-pm' ), |
| 153 |
), |
| 154 |
), |
| 155 |
'parent_post_status' => array( |
| 156 |
'type' => 'select', |
| 157 |
'value' => fep_get_option( 'parent_post_status', 'publish' ), |
| 158 |
'priority' => 14, |
| 159 |
'label' => __( 'Parent Message Status', 'front-end-pm' ), |
| 160 |
'description'=> __( 'Parent Message status when sent from front end.', 'front-end-pm' ), |
| 161 |
'options' => fep_get_statuses( 'message' ), |
| 162 |
), |
| 163 |
'reply_post_status' => array( |
| 164 |
'type' => 'select', |
| 165 |
'value' => fep_get_option( 'reply_post_status', 'publish' ), |
| 166 |
'priority' => 16, |
| 167 |
'label' => __( 'Reply Message Status', 'front-end-pm' ), |
| 168 |
'description'=> __( 'Reply Message status when sent from front end.', 'front-end-pm' ), |
| 169 |
'options' => fep_get_statuses( 'message' ), |
| 170 |
), |
| 171 |
'att_status' => array( |
| 172 |
'type' => 'select', |
| 173 |
'value' => fep_get_option( 'att_status', 'publish' ), |
| 174 |
'priority' => 16, |
| 175 |
'label' => __( 'Attachment Default Status', 'front-end-pm' ), |
| 176 |
'description'=> __( 'Only publish attachments will show to users', 'front-end-pm' ), |
| 177 |
'options' => fep_get_statuses( 'attachment' ), |
| 178 |
), |
| 179 |
'allow_attachment' => array( |
| 180 |
'type' => 'checkbox', |
| 181 |
'value' => fep_get_option( 'allow_attachment', 1 ), |
| 182 |
'priority' => 18, |
| 183 |
'class' => 'fep_toggle_next_tr fep_toggle_next_tr-2', |
| 184 |
'label' => __( 'Allow Attachment', 'front-end-pm' ), |
| 185 |
'cb_label' => __( 'Allow to attach attachment with message?', 'front-end-pm' ), |
| 186 |
), |
| 187 |
'attachment_size' => array( |
| 188 |
'type' => 'text', |
| 189 |
'value' => fep_get_option( 'attachment_size', '4MB' ), |
| 190 |
'priority' => 20, |
| 191 |
'label' => __( 'Maximum size of attachment', 'front-end-pm' ), |
| 192 |
'description'=> __( 'Use KB, MB or GB (eg. 4MB).', 'front-end-pm' ), |
| 193 |
), |
| 194 |
'attachment_no' => array( |
| 195 |
'type' => 'number', |
| 196 |
'value' => fep_get_option( 'attachment_no', '4' ), |
| 197 |
'priority' => 22, |
| 198 |
'label' => __( 'Maximum attachments', 'front-end-pm' ), |
| 199 |
'description'=> __( 'Maximum Number of attachments a user can add with message.', 'front-end-pm' ), |
| 200 |
), |
| 201 |
'show_directory' => array( |
| 202 |
'type' => 'checkbox', |
| 203 |
'value' => fep_get_option( 'show_directory', 1 ), |
| 204 |
'priority' => 24, |
| 205 |
'class' => '', |
| 206 |
'label' => __( 'Show Directory', 'front-end-pm' ), |
| 207 |
'cb_label' => __( 'Show Directory in front end?', 'front-end-pm' ), |
| 208 |
'description'=> __( 'Always shown to Admins.', 'front-end-pm' ), |
| 209 |
), |
| 210 |
'show_branding' => array( |
| 211 |
'type' => 'checkbox', |
| 212 |
'value' => fep_get_option( 'show_branding', 1 ), |
| 213 |
'priority' => 30, |
| 214 |
'class' => '', |
| 215 |
'label' => __( 'Show Branding Footer', 'front-end-pm' ), |
| 216 |
), |
| 217 |
'delete_data_on_uninstall' => array( |
| 218 |
'type' => 'checkbox', |
| 219 |
'value' => fep_get_option( 'delete_data_on_uninstall', false ), |
| 220 |
'priority' => 35, |
| 221 |
'class' => '', |
| 222 |
'label' => __( 'Remove Data on Uninstall?', 'front-end-pm' ), |
| 223 |
'description'=> '<div style="color:red">' . sprintf( __( 'Check this box if you would like %s to completely remove all of its data when the plugin is deleted.', 'front-end-pm' ), fep_is_pro() ? 'Front End PM PRO' : 'Front End PM' ) . '</div>', |
| 224 |
), |
| 225 |
'load_css' => array( |
| 226 |
'type' => 'select', |
| 227 |
'section' => 'appearance', |
| 228 |
'value' => fep_get_option( 'load_css', 'only_in_message_page' ), |
| 229 |
'priority' => 2, |
| 230 |
'label' => __( 'Load CSS file', 'front-end-pm' ), |
| 231 |
'description'=> __( 'Select when you want to load CSS file of this plugin.', 'front-end-pm' ), |
| 232 |
'options' => array( |
| 233 |
'always' => __( 'Always', 'front-end-pm' ), |
| 234 |
'only_in_message_page' => __( 'Only in message page', 'front-end-pm' ), |
| 235 |
'never' => __( 'Never', 'front-end-pm' ), |
| 236 |
), |
| 237 |
), |
| 238 |
'custom_css' => array( |
| 239 |
'type' => 'textarea', |
| 240 |
'section' => 'appearance', |
| 241 |
'value' => fep_get_option( 'custom_css' ), |
| 242 |
'priority' => 3, |
| 243 |
'label' => __( 'Custom CSS', 'front-end-pm' ), |
| 244 |
'description'=> __( 'Add or override.', 'front-end-pm' ), |
| 245 |
), |
| 246 |
'bg_color' => array( |
| 247 |
'type' => 'color_picker', |
| 248 |
//'class' => 'fep-color-picker', |
| 249 |
'section' => 'appearance', |
| 250 |
'value' => fep_get_option( 'bg_color', '#ffffff' ), |
| 251 |
'default_value' => '#ffffff', |
| 252 |
'priority' => 5, |
| 253 |
'label' => __( 'Background Color', 'front-end-pm' ), |
| 254 |
), |
| 255 |
'text_color' => array( |
| 256 |
'type' => 'color_picker', |
| 257 |
//'class' => 'fep-color-picker', |
| 258 |
'section' => 'appearance', |
| 259 |
'value' => fep_get_option( 'text_color', '#000000' ), |
| 260 |
'default_value' => '#000000', |
| 261 |
'priority' => 10, |
| 262 |
'label' => __( 'Text Color', 'front-end-pm' ), |
| 263 |
), |
| 264 |
'link_color' => array( |
| 265 |
'type' => 'color_picker', |
| 266 |
//'class' => 'fep-color-picker', |
| 267 |
'section' => 'appearance', |
| 268 |
'value' => fep_get_option( 'link_color', '#000080' ), |
| 269 |
'default_value' => '#000080', |
| 270 |
'priority' => 20, |
| 271 |
'label' => __( 'Link Color', 'front-end-pm' ), |
| 272 |
), |
| 273 |
'btn_bg_color' => array( |
| 274 |
'type' => 'color_picker', |
| 275 |
//'class' => 'fep-color-picker', |
| 276 |
'section' => 'appearance', |
| 277 |
'value' => fep_get_option( 'btn_bg_color', '#F0FCFF' ), |
| 278 |
'default_value' => '#F0FCFF', |
| 279 |
'priority' => 25, |
| 280 |
'label' => __( 'Button Color', 'front-end-pm' ), |
| 281 |
), |
| 282 |
'btn_text_color' => array( |
| 283 |
'type' => 'color_picker', |
| 284 |
//'class' => 'fep-color-picker', |
| 285 |
'section' => 'appearance', |
| 286 |
'value' => fep_get_option( 'btn_text_color', '#000000' ), |
| 287 |
'default_value' => '#000000', |
| 288 |
'priority' => 30, |
| 289 |
'label' => __( 'Button Text Color', 'front-end-pm' ), |
| 290 |
), |
| 291 |
'active_btn_bg_color' => array( |
| 292 |
'type' => 'color_picker', |
| 293 |
//'class' => 'fep-color-picker', |
| 294 |
'section' => 'appearance', |
| 295 |
'value' => fep_get_option( 'active_btn_bg_color', '#D3EEF5' ), |
| 296 |
'default_value' => '#D3EEF5', |
| 297 |
'priority' => 35, |
| 298 |
'label' => __( 'Active Button Color', 'front-end-pm' ), |
| 299 |
), |
| 300 |
'active_btn_text_color' => array( |
| 301 |
'type' => 'color_picker', |
| 302 |
//'class' => 'fep-color-picker', |
| 303 |
'section' => 'appearance', |
| 304 |
'value' => fep_get_option( 'active_btn_text_color', '#000000' ), |
| 305 |
'default_value' => '#000000', |
| 306 |
'priority' => 40, |
| 307 |
'label' => __( 'Active Button Text Color', 'front-end-pm' ), |
| 308 |
), |
| 309 |
'odd_color' => array( |
| 310 |
'type' => 'color_picker', |
| 311 |
//'class' => 'fep-color-picker', |
| 312 |
'section' => 'appearance', |
| 313 |
'value' => fep_get_option( 'odd_color', '#F2F7FC' ), |
| 314 |
'default_value' => '#F2F7FC', |
| 315 |
'priority' => 45, |
| 316 |
'label' => __( 'Odd Messages Color', 'front-end-pm' ), |
| 317 |
), |
| 318 |
'even_color' => array( |
| 319 |
'type' => 'color_picker', |
| 320 |
//'class' => 'fep-color-picker', |
| 321 |
'section' => 'appearance', |
| 322 |
'value' => fep_get_option( 'even_color', '#FAFAFA' ), |
| 323 |
'default_value' => '#FAFAFA', |
| 324 |
'priority' => 50, |
| 325 |
'label' => __( 'Even Messages Color', 'front-end-pm' ), |
| 326 |
), |
| 327 |
'mgs_heading_color' => array( |
| 328 |
'type' => 'color_picker', |
| 329 |
//'class' => 'fep-color-picker', |
| 330 |
'section' => 'appearance', |
| 331 |
'value' => fep_get_option( 'mgs_heading_color', '#F2F7FC' ), |
| 332 |
'default_value' => '#F2F7FC', |
| 333 |
'priority' => 50, |
| 334 |
'label' => __( 'Messages Heading Color', 'front-end-pm' ), |
| 335 |
), |
| 336 |
//Recipient Settings |
| 337 |
'show_autosuggest' => array( |
| 338 |
'type' => 'checkbox', |
| 339 |
'value' => fep_get_option( 'show_autosuggest', 1 ), |
| 340 |
'priority' => 5, |
| 341 |
'section' => 'recipient', |
| 342 |
'class' => '', |
| 343 |
'label' => __( 'Show Autosuggestion', 'front-end-pm' ), |
| 344 |
'cb_label' => __( 'Show Autosuggestion when typing recipient name?', 'front-end-pm' ), |
| 345 |
'description'=> __( 'Always shown to Admins.', 'front-end-pm' ), |
| 346 |
), |
| 347 |
//Message |
| 348 |
//Announcement |
| 349 |
// Privacy |
| 350 |
'export_messages' => array( |
| 351 |
'type' => 'checkbox', |
| 352 |
'value' => fep_get_option( 'export_messages', 1 ), |
| 353 |
'priority' => 5, |
| 354 |
'section' => 'privacy_export', |
| 355 |
'class' => '', |
| 356 |
'label' => __( 'Export Messages', 'front-end-pm' ), |
| 357 |
), |
| 358 |
'export_announcements' => array( |
| 359 |
'type' => 'checkbox', |
| 360 |
'value' => fep_get_option( 'export_announcements', 1 ), |
| 361 |
'priority' => 5, |
| 362 |
'section' => 'privacy_export', |
| 363 |
'class' => '', |
| 364 |
'label' => __( 'Export Announcements', 'front-end-pm' ), |
| 365 |
), |
| 366 |
'erase_messages' => array( |
| 367 |
'type' => 'select', |
| 368 |
'value' => fep_get_option( 'erase_messages', 'anonymize' ), |
| 369 |
'priority' => 10, |
| 370 |
'section' => 'privacy_erase', |
| 371 |
'label' => __( 'Erase Messages', 'front-end-pm' ), |
| 372 |
'description' => __( 'If set Erase and message view as threaded, then all replies of that message will also be erased regardless of sender and erase replies setup.', 'front-end-pm' ), |
| 373 |
'options' => array( |
| 374 |
'none' => __( 'No Action', 'front-end-pm' ), |
| 375 |
'erase' => __( 'Erase', 'front-end-pm' ), |
| 376 |
'anonymize' => __( 'Anonymize', 'front-end-pm' ), |
| 377 |
), |
| 378 |
), |
| 379 |
'erase_replies' => array( |
| 380 |
'type' => 'select', |
| 381 |
'value' => fep_get_option( 'erase_replies', 'erase' ), |
| 382 |
'priority' => 15, |
| 383 |
'section' => 'privacy_erase', |
| 384 |
'label' => __( 'Erase Replies', 'front-end-pm' ), |
| 385 |
'options' => array( |
| 386 |
'none' => __( 'No Action', 'front-end-pm' ), |
| 387 |
'erase' => __( 'Erase', 'front-end-pm' ), |
| 388 |
'anonymize' => __( 'Anonymize', 'front-end-pm' ), |
| 389 |
), |
| 390 |
), |
| 391 |
'erase_announcements' => array( |
| 392 |
'type' => 'select', |
| 393 |
'value' => fep_get_option( 'erase_announcements', 'erase' ), |
| 394 |
'priority' => 20, |
| 395 |
'section' => 'privacy_erase', |
| 396 |
'label' => __( 'Erase Announcements', 'front-end-pm' ), |
| 397 |
'options' => array( |
| 398 |
'none' => __( 'No Action', 'front-end-pm' ), |
| 399 |
'erase' => __( 'Erase', 'front-end-pm' ), |
| 400 |
'anonymize' => __( 'Anonymize', 'front-end-pm' ), |
| 401 |
), |
| 402 |
), |
| 403 |
//Email Settings |
| 404 |
'email_content_type' => array( |
| 405 |
'type' => 'select', |
| 406 |
'value' => fep_get_option( 'email_content_type', 'plain_text' ), |
| 407 |
'priority' => 5, |
| 408 |
'section' => 'emails', |
| 409 |
'label' => __( 'Email Content Type', 'front-end-pm' ), |
| 410 |
'options' => array( |
| 411 |
'html' => __( 'HTML', 'front-end-pm' ), |
| 412 |
'plain_text'=> __( 'Plain Text', 'front-end-pm' ), |
| 413 |
), |
| 414 |
), |
| 415 |
'from_name' => array( |
| 416 |
'type' => 'text', |
| 417 |
'value' => fep_get_option( 'from_name', get_bloginfo( 'name' ) ), |
| 418 |
'priority' => 10, |
| 419 |
'section' => 'emails', |
| 420 |
'label' => __( 'From Name', 'front-end-pm' ), |
| 421 |
'description'=> __( 'All sent emails by Front End PM plugin will have this name as sender.', 'front-end-pm' ), |
| 422 |
), |
| 423 |
'from_email' => array( |
| 424 |
'type' => 'email', |
| 425 |
'value' => fep_get_option( 'from_email', get_bloginfo( 'admin_email' ) ), |
| 426 |
'priority' => 15, |
| 427 |
'section' => 'emails', |
| 428 |
'label' => __( 'From Email', 'front-end-pm' ), |
| 429 |
'description'=> __( 'All sent emails by Front End PM plugin will have this email address as sender.', 'front-end-pm' ) |
| 430 |
), |
| 431 |
'notify_ann' => array( |
| 432 |
'type' => 'checkbox', |
| 433 |
'value' => fep_get_option( 'notify_ann', '1' ), |
| 434 |
'priority' => 20, |
| 435 |
'class' => '', |
| 436 |
'section' => 'emails', |
| 437 |
'label' => __( 'Send email?', 'front-end-pm' ), |
| 438 |
'cb_label' => __( 'Send email to all users of selected role(s) when a new announcement is published?', 'front-end-pm' ), |
| 439 |
), |
| 440 |
'ann_to' => array( |
| 441 |
'type' => 'email', |
| 442 |
'value' => fep_get_option( 'ann_to', get_bloginfo( 'admin_email' ) ), |
| 443 |
'priority' => 25, |
| 444 |
'section' => 'emails', |
| 445 |
'label' => __( 'Valid email address for "to" field of announcement email', 'front-end-pm' ), |
| 446 |
'description'=> __( 'All users email will be in "Bcc" field.', 'front-end-pm' ), |
| 447 |
), |
| 448 |
//Security Settings |
| 449 |
'userrole_access' => array( |
| 450 |
'type' => 'checkbox', |
| 451 |
'value' => fep_get_option( 'userrole_access', array() ), |
| 452 |
'priority' => 5, |
| 453 |
'class' => '', |
| 454 |
'section' => 'security', |
| 455 |
'multiple' => true, |
| 456 |
'label' => __( 'Who can access message system?', 'front-end-pm' ), |
| 457 |
'options' => $user_role, |
| 458 |
'description'=> __( 'User must have access permission to send new message or reply.', 'front-end-pm' ), |
| 459 |
), |
| 460 |
'userrole_new_message' => array( |
| 461 |
'type' => 'checkbox', |
| 462 |
'value' => fep_get_option( 'userrole_new_message', array() ), |
| 463 |
'priority' => 10, |
| 464 |
'class' => '', |
| 465 |
'section' => 'security', |
| 466 |
'multiple' => true, |
| 467 |
'label' => __( 'Who can send new messages?', 'front-end-pm' ), |
| 468 |
'options' => $user_role, |
| 469 |
), |
| 470 |
'userrole_reply' => array( |
| 471 |
'type' => 'checkbox', |
| 472 |
'value' => fep_get_option( 'userrole_reply', array() ), |
| 473 |
'priority' => 15, |
| 474 |
'class' => '', |
| 475 |
'section' => 'security', |
| 476 |
'multiple' => true, |
| 477 |
'label' => __( 'Who can send replies?', 'front-end-pm' ), |
| 478 |
'options' => $user_role, |
| 479 |
), |
| 480 |
'whitelist_username' => array( |
| 481 |
'type' => 'textarea', |
| 482 |
'value' => fep_get_option( 'whitelist_username' ), |
| 483 |
'section' => 'security', |
| 484 |
'priority' => 20, |
| 485 |
'label' => __( 'Whitelist Username', 'front-end-pm' ), |
| 486 |
'description'=> __( 'Separated by comma. These users have all permission if blocked by role also.', 'front-end-pm' ), |
| 487 |
), |
| 488 |
'have_permission' => array( |
| 489 |
'type' => 'textarea', |
| 490 |
'value' => fep_get_option( 'have_permission' ), |
| 491 |
'section' => 'security', |
| 492 |
'priority' => 25, |
| 493 |
'label' => __( 'Blacklist Username', 'front-end-pm' ), |
| 494 |
'description'=> __( 'Separated by comma. These users have NO permission if allowed by role also.', 'front-end-pm' ), |
| 495 |
), |
| 496 |
'block_other_users' => array( |
| 497 |
'type' => 'checkbox', |
| 498 |
'value' => fep_get_option( 'block_other_users', 1 ), |
| 499 |
'priority' => 30, |
| 500 |
'section' => 'security', |
| 501 |
'class' => '', |
| 502 |
'label' => __( 'Block other users', 'front-end-pm' ), |
| 503 |
'cb_label' => __( 'Can user block other users?', 'front-end-pm' ), |
| 504 |
), |
| 505 |
'add_ann_frontend' => array( |
| 506 |
'type' => 'checkbox', |
| 507 |
'value' => fep_get_option( 'add_ann_frontend', 1 ), |
| 508 |
'priority' => 35, |
| 509 |
'section' => 'security', |
| 510 |
'class' => '', |
| 511 |
'label' => __( 'Add Announcement', 'front-end-pm' ), |
| 512 |
'cb_label' => __( 'Can permitted users add Announcement from front end?', 'front-end-pm' ), |
| 513 |
), |
| 514 |
'reply_deleted_mgs' => array( |
| 515 |
'type' => 'checkbox', |
| 516 |
'value' => fep_get_option( 'reply_deleted_mgs', '' ), |
| 517 |
'priority' => 40, |
| 518 |
'section' => 'security', |
| 519 |
'class' => '', |
| 520 |
'label' => __( 'Reply Deleted Message', 'front-end-pm' ), |
| 521 |
'cb_label' => __( 'Can user reply messages deleted by other user?', 'front-end-pm' ), |
| 522 |
), |
| 523 |
//Notification Settings |
| 524 |
'show_notification' => array( |
| 525 |
'type' => 'checkbox', |
| 526 |
'value' => fep_get_option( 'show_notification', 1 ), |
| 527 |
'priority' => 5, |
| 528 |
'section' => 'notification', |
| 529 |
'class' => '', |
| 530 |
'label' => __( 'Show notification', 'front-end-pm' ), |
| 531 |
'cb_label' => __( 'Show site wide notification in header site?', 'front-end-pm' ), |
| 532 |
), |
| 533 |
'show_unread_count_in_title' => array( |
| 534 |
'type' => 'checkbox', |
| 535 |
'value' => fep_get_option( 'show_unread_count_in_title', 1 ), |
| 536 |
'priority' => 10, |
| 537 |
'section' => 'notification', |
| 538 |
'class' => '', |
| 539 |
'label' => __( 'Show count', 'front-end-pm' ), |
| 540 |
'cb_label' => __( 'Show unread messages count in website title?', 'front-end-pm' ), |
| 541 |
), |
| 542 |
'show_unread_count_in_desktop' => array( |
| 543 |
'type' => 'checkbox', |
| 544 |
'value' => fep_get_option( 'show_unread_count_in_desktop', 1 ), |
| 545 |
'priority' => 15, |
| 546 |
'section' => 'notification', |
| 547 |
'class' => '', |
| 548 |
'label' => __( 'Show desktop notification', 'front-end-pm' ), |
| 549 |
'cb_label' => __( 'Show desktop notification for new messages and announcements?', 'front-end-pm' ), |
| 550 |
), |
| 551 |
'play_sound' => array( |
| 552 |
'type' => 'checkbox', |
| 553 |
'value' => fep_get_option( 'play_sound', 1 ), |
| 554 |
'priority' => 20, |
| 555 |
'section' => 'notification', |
| 556 |
'class' => '', |
| 557 |
'label' => __( 'Play Sound', 'front-end-pm' ), |
| 558 |
'cb_label' => __( 'Play notification sound on message and announcement received?', 'front-end-pm' ), |
| 559 |
), |
| 560 |
); |
| 561 |
foreach ( $user_role as $key => $role ) { |
| 562 |
$fields["message_box_{$key}"] = array( |
| 563 |
'type' => 'number', |
| 564 |
'value' => fep_get_option( "message_box_{$key}", 50 ), |
| 565 |
'section' => 'message_box', |
| 566 |
'label' => $role, |
| 567 |
'description'=> sprintf( __( 'Max messages a %s can keep in box? (0 = unlimited)', 'front-end-pm' ), $role ), |
| 568 |
); |
| 569 |
} |
| 570 |
if ( ! fep_get_option( 'page_id', 0 ) ) { |
| 571 |
$fields['page_id']['description'] = $fields['page_id']['description'] . '<br /><a class="button-secondary" href="' . esc_url( add_query_arg( array( 'post_title' => 'Front End PM', 'content' => '[front-end-pm]' ), admin_url( 'post-new.php?post_type=page' ) ) ) . '">' . __( 'Create Page', 'front-end-pm' ) . '</a>'; |
| 572 |
} |
| 573 |
$fields = apply_filters( 'fep_settings_fields', $fields ); |
| 574 |
foreach ( $fields as $key => $field ) { |
| 575 |
if ( empty( $field['section'] ) ) { |
| 576 |
$field['section'] = 'general'; |
| 577 |
} |
| 578 |
if ( $section != $field['section'] ) { |
| 579 |
unset( $fields[ $key ] ); |
| 580 |
continue; |
| 581 |
} |
| 582 |
$this->priority++; |
| 583 |
$type = ! empty( $field['type'] ) ? $field['type'] : 'text'; |
| 584 |
$defaults = array( |
| 585 |
'key' => $key, |
| 586 |
'type' => $type, |
| 587 |
'name' => $key, |
| 588 |
'class' => ( 'number' == $type ) ? 'small-text' : 'regular-text', |
| 589 |
'id' => $key, |
| 590 |
'label' => '', |
| 591 |
'cb_label' => '', |
| 592 |
'value' => '', |
| 593 |
'placeholder' => '', |
| 594 |
'description' => '', |
| 595 |
'priority' => $this->priority, |
| 596 |
); |
| 597 |
$fields[ $key ] = wp_parse_args( $fields[ $key ], $defaults ); |
| 598 |
} |
| 599 |
uasort( $fields, 'fep_sort_by_priority' ); |
| 600 |
return $fields; |
| 601 |
} |
| 602 |
|
| 603 |
function settings_output() { |
| 604 |
//register_setting( $option_group, $option_name, $sanitize_callback = '' ); |
| 605 |
register_setting( 'fep_settings', 'FEP_admin_options', array( $this, 'options_sanitize' ) ); |
| 606 |
foreach ( $this->tabs() as $slug => $tab ) { |
| 607 |
//add_settings_section( $id, $title, $callback, $page ); |
| 608 |
add_settings_section( $tab['section_id'], $tab['section_title'], $tab['section_callback'], $tab['section_page'] ); |
| 609 |
foreach ( $this->form_fields( str_replace( 'fep_settings_', '', $tab['section_id'] ) ) as $key => $field ) { |
| 610 |
if ( function_exists( 'fep_settings_field_output_callback_' . $field['type'] ) ) { |
| 611 |
$callback = 'fep_settings_field_output_callback_' . $field['type']; |
| 612 |
} else { |
| 613 |
$callback = array( $this, 'field_output' ); |
| 614 |
} |
| 615 |
//add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ); |
| 616 |
add_settings_field( $field['id'], $field['label'], $callback, $tab['section_page'], $tab['section_id'], $field ); |
| 617 |
} |
| 618 |
} |
| 619 |
} |
| 620 |
|
| 621 |
function field_output( $field ) { |
| 622 |
$attrib = ''; |
| 623 |
if ( ! empty( $field['required'] ) ) { |
| 624 |
$attrib .= 'required = "required" '; |
| 625 |
} |
| 626 |
if ( ! empty( $field['readonly'] ) ) { |
| 627 |
$attrib .= 'readonly = "readonly" '; |
| 628 |
} |
| 629 |
if ( ! empty( $field['disabled'] ) ) { |
| 630 |
$attrib .= 'disabled = "disabled" '; |
| 631 |
} |
| 632 |
if ( ! empty( $field['minlength'] ) ) { |
| 633 |
$attrib .= 'minlength = "' . absint( $field['minlength'] ) . '" '; |
| 634 |
} |
| 635 |
if ( ! empty( $field['maxlength'] ) ) { |
| 636 |
$attrib .= 'maxlength = "' . absint( $field['maxlength'] ) . '" '; |
| 637 |
} |
| 638 |
if ( ! empty( $field['class'] ) ) { |
| 639 |
$field['class'] = fep_sanitize_html_class( $field['class'] ); |
| 640 |
} |
| 641 |
switch ( $field['type'] ) { |
| 642 |
case has_action( 'fep_admin_settings_field_output_' . $field['type'] ): |
| 643 |
do_action( 'fep_admin_settings_field_output_' . $field['type'], $field ); |
| 644 |
break; |
| 645 |
case 'text': |
| 646 |
case 'email': |
| 647 |
case 'url': |
| 648 |
case 'number': |
| 649 |
?><input id="<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo $field['class']; ?>" type="<?php echo esc_attr( $field['type'] ); ?>" name="<?php echo esc_attr( $field['name'] ); ?>" placeholder="<?php echo esc_attr( $field['placeholder'] ); ?>" value="<?php echo esc_attr( stripslashes( $field['value' ] ) ); ?>" <?php echo $attrib; ?> /><?php |
| 650 |
break; |
| 651 |
case 'color_picker': |
| 652 |
?><input type="text" name="<?php echo esc_attr( $field['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $field['value' ] ) ); ?>" class="fep-color-picker" data-default-color="<?php echo esc_attr( $field['default_value'] ); ?>" ><?php |
| 653 |
break; |
| 654 |
case 'textarea': |
| 655 |
?><textarea id="<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo $field['class']; ?>" cols="50" name="<?php echo esc_attr( $field['name'] ); ?>" placeholder="<?php echo esc_attr( $field['placeholder'] ); ?>" <?php echo $attrib; ?>><?php echo wp_kses_post( stripslashes( $field['value' ] ) ); ?></textarea><?php |
| 656 |
break; |
| 657 |
case 'wp_editor': |
| 658 |
wp_editor( wp_kses_post( stripslashes( $field['value' ] ) ), $field['id'], array( 'textarea_name' => $field['name'], 'editor_class' => $field['class'], 'media_buttons' => false) ); |
| 659 |
break; |
| 660 |
case 'teeny': |
| 661 |
wp_editor( wp_kses_post( stripslashes( $field['value' ] ) ), $field['id'], array( 'textarea_name' => $field['name'], 'editor_class' => $field['class'], 'teeny' => true, 'media_buttons' => false) ); |
| 662 |
break; |
| 663 |
case 'checkbox': |
| 664 |
if ( ! empty( $field['multiple' ] ) ) { |
| 665 |
foreach( $field['options' ] as $key => $name ) { |
| 666 |
?><label><input id="<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo $field['class']; ?>" name="<?php echo esc_attr( $field['name'] ); ?>[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" <?php if ( in_array( $key, $field['value' ] ) ) { echo 'checked="checked"';} ?> /> <?php echo esc_attr( $name ); ?></label><br /><?php |
| 667 |
} |
| 668 |
} else { |
| 669 |
?><label><input id="<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo $field['class']; ?>" name="<?php echo esc_attr( $field['name'] ); ?>" type="checkbox" value="1" <?php checked( '1', $field['value' ] ); ?> /> <?php echo esc_attr( $field['cb_label'] ); ?></label><?php |
| 670 |
} |
| 671 |
break; |
| 672 |
case 'select': |
| 673 |
?><select id="<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo $field['class']; ?>" name="<?php echo esc_attr( $field['name'] ); ?>"><?php |
| 674 |
foreach( $field['options'] as $key => $name ) { |
| 675 |
?><option value="<?php echo esc_attr( $key ); ?>" <?php selected( $field['value' ], $key ); ?>><?php echo esc_attr( $name ); ?></option><?php } |
| 676 |
?></select><?php |
| 677 |
break; |
| 678 |
case 'radio': |
| 679 |
foreach( $field['options'] as $key => $name ) { |
| 680 |
?><label><input type="radio" class="<?php echo $field['class']; ?>" name="<?php echo esc_attr( $field['name'] ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( $field['posted-value' ], $key ); ?> /> <?php echo esc_attr( $name ); ?></label><br /><?php |
| 681 |
} |
| 682 |
break; |
| 683 |
case 'html': |
| 684 |
echo wp_kses_post( $field['value'] ); |
| 685 |
break; |
| 686 |
default: |
| 687 |
printf( __( 'No Function or Hook defined for %s field type', 'front-end-pm' ), $field['type'] ); |
| 688 |
break; |
| 689 |
} |
| 690 |
if ( ! empty( $field['description'] ) ) { |
| 691 |
?><p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p><?php |
| 692 |
} |
| 693 |
} |
| 694 |
|
| 695 |
function posted_value_sanitize( $value, $field ) { |
| 696 |
$sanitized = $value; |
| 697 |
switch ( $field['type'] ) { |
| 698 |
case 'text': |
| 699 |
$sanitized = sanitize_text_field( trim( $value ) ); |
| 700 |
break; |
| 701 |
case 'email': //sanitize_email() |
| 702 |
if ( ! is_email( $value ) ) { |
| 703 |
add_settings_error( 'fep-settings', $field['id'], sprintf( __( 'Provide valid email address for %s', 'front-end-pm' ), $field['label'] ) ); |
| 704 |
$sanitized = $field['value']; |
| 705 |
} |
| 706 |
break; |
| 707 |
case 'color_picker': |
| 708 |
if ( ! preg_match( '/^#[a-f0-9]{6}$/i', $value ) ) { // if user insert a HEX color with # |
| 709 |
add_settings_error( 'fep-settings', $field['id'], sprintf( __( 'Provide valid color for %s', 'front-end-pm' ), $field['label'] ) ); |
| 710 |
$sanitized = $field['value']; |
| 711 |
} |
| 712 |
break; |
| 713 |
case 'url': |
| 714 |
$sanitized = esc_url( $value ); |
| 715 |
break; |
| 716 |
case 'number': |
| 717 |
$sanitized = absint( $value ); |
| 718 |
break; |
| 719 |
case 'textarea': |
| 720 |
case 'wp_editor': |
| 721 |
case 'teeny': |
| 722 |
$sanitized = wp_kses_post( $value ); |
| 723 |
break; |
| 724 |
case 'checkbox': |
| 725 |
if ( ! empty( $field['multiple' ] ) ) { |
| 726 |
$sanitized = is_array( $value ) ? $value : array(); |
| 727 |
foreach( $sanitized as $p_value ) { |
| 728 |
if ( ! array_key_exists( $p_value, $field['options'] ) ) { |
| 729 |
add_settings_error( 'fep-settings', $field['id'], sprintf( __( 'Invalid value for %s', 'front-end-pm' ), $field['label'] ) ); |
| 730 |
$sanitized = $field['value']; |
| 731 |
} |
| 732 |
} |
| 733 |
} else { |
| 734 |
$sanitized = absint( $value ); |
| 735 |
} |
| 736 |
break; |
| 737 |
case 'select': |
| 738 |
if ( ! array_key_exists( $value, $field['options'] ) ) { |
| 739 |
add_settings_error( 'fep-settings', $field['id'], sprintf( __( 'Invalid value for %s', 'front-end-pm' ), $field['label'] ) ); |
| 740 |
$sanitized = $field['value']; |
| 741 |
} |
| 742 |
break; |
| 743 |
default: |
| 744 |
$sanitized = apply_filters( 'fep_settings_field_sanitize_filter_' . $field['type'], $value, $field ); |
| 745 |
break; |
| 746 |
} |
| 747 |
return apply_filters( 'fep_settings_field_sanitize_filter', $sanitized, $field, $value ); |
| 748 |
} |
| 749 |
|
| 750 |
function options_sanitize( $value ) { |
| 751 |
if ( empty( $_POST['_wp_http_referer'] ) ) { |
| 752 |
return $value; |
| 753 |
} |
| 754 |
global $wp_settings_sections; |
| 755 |
wp_parse_str( parse_url( $_POST['_wp_http_referer'], PHP_URL_QUERY ), $referrer ); |
| 756 |
$tab = ! empty( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
| 757 |
if ( empty( $referrer['page'] ) || 'fep_settings' != $referrer['page'] ) { |
| 758 |
return $value; |
| 759 |
} |
| 760 |
if ( empty( $wp_settings_sections['fep_settings_' . $tab] ) ) { |
| 761 |
//return /** $value */ get_option( 'FEP_admin_options' ); |
| 762 |
return $value; |
| 763 |
} |
| 764 |
$posted_value = array(); |
| 765 |
foreach ( (array) $wp_settings_sections['fep_settings_' . $tab] as $section ) { |
| 766 |
$section_tab = str_replace( 'fep_settings_', '', $section['id'] ); |
| 767 |
$sanitized = apply_filters( "fep_settings_section_sanitize_filter_{$section_tab}", $this->sanitize( $section_tab ), $section ); |
| 768 |
$sanitized = apply_filters( 'fep_settings_section_sanitize_filter', $sanitized, $section ); |
| 769 |
$posted_value = wp_parse_args( $sanitized, $posted_value ); |
| 770 |
} |
| 771 |
|
| 772 |
// Merge our new settings with the existing |
| 773 |
$settings = wp_parse_args( $posted_value, get_option( 'FEP_admin_options' ) ); |
| 774 |
$settings = apply_filters( 'fep_filter_before_admin_options_save', $settings, $tab ); |
| 775 |
|
| 776 |
//Do not use this action hook |
| 777 |
do_action( 'fep_action_before_admin_options_save', $settings, $tab ); |
| 778 |
return $settings; |
| 779 |
} |
| 780 |
|
| 781 |
function sanitize( $section ) { |
| 782 |
$posted_value = array(); |
| 783 |
foreach ( (array) $this->form_fields( $section ) as $key => $field ) { |
| 784 |
$posted_value[ $field['name'] ] = isset( $_POST[ $field['name'] ] ) ? $_POST[ $field['name'] ] : ''; |
| 785 |
$posted_value[ $field['name'] ] = $this->posted_value_sanitize( $posted_value[ $field['name'] ], $field ); |
| 786 |
} |
| 787 |
return $posted_value; |
| 788 |
} |
| 789 |
|
| 790 |
function tabs() { |
| 791 |
$tabs = array( |
| 792 |
'general' => array( |
| 793 |
'tab_title' => __( 'General', 'front-end-pm' ), |
| 794 |
'priority' => 5, |
| 795 |
), |
| 796 |
'appearance' => array( |
| 797 |
'tab_title' => __( 'Appearance', 'front-end-pm' ), |
| 798 |
'priority' => 6, |
| 799 |
), |
| 800 |
'recipient' => array( |
| 801 |
'tab_title' => __( 'Recipient', 'front-end-pm' ), |
| 802 |
'priority' => 7, |
| 803 |
), |
| 804 |
/*'message' => array( |
| 805 |
'tab_title' => __( 'Message', 'front-end-pm' ), |
| 806 |
'priority' => 10, |
| 807 |
), |
| 808 |
'announcement' => array( |
| 809 |
'tab_title' => __( 'Announcement', 'front-end-pm' ), |
| 810 |
'priority' => 15, |
| 811 |
),*/ |
| 812 |
'privacy' => array( |
| 813 |
'tab_title' => __( 'Privacy', 'front-end-pm' ), |
| 814 |
'priority' => 16, |
| 815 |
), |
| 816 |
'emails' => array( |
| 817 |
'tab_title' => __( 'Emails', 'front-end-pm' ), |
| 818 |
'priority' => 20, |
| 819 |
), |
| 820 |
'security' => array( |
| 821 |
'tab_title' => __( 'Security', 'front-end-pm' ), |
| 822 |
'priority' => 25, |
| 823 |
), |
| 824 |
'misc' => array( |
| 825 |
'tab_title' => __( 'Misc', 'front-end-pm' ), |
| 826 |
'priority' => 27, |
| 827 |
), |
| 828 |
'privacy_export' => array( |
| 829 |
'section_title' => __( 'Export', 'front-end-pm' ), |
| 830 |
'section_page' => 'fep_settings_privacy', |
| 831 |
'priority' => 10, |
| 832 |
'tab_output' => false, |
| 833 |
), |
| 834 |
'privacy_erase' => array( |
| 835 |
'section_title' => __( 'Erase', 'front-end-pm' ), |
| 836 |
'section_page' => 'fep_settings_privacy', |
| 837 |
'priority' => 15, |
| 838 |
'tab_output' => false, |
| 839 |
), |
| 840 |
'notification' => array( |
| 841 |
'section_title' => __( 'Notification', 'front-end-pm' ), |
| 842 |
'section_page' => 'fep_settings_misc', |
| 843 |
'priority' => 10, |
| 844 |
'tab_output' => false, |
| 845 |
), |
| 846 |
'message_box' => array( |
| 847 |
'section_title' => __( 'Message Box', 'front-end-pm' ), |
| 848 |
'section_page' => 'fep_settings_misc', |
| 849 |
'priority' => 15, |
| 850 |
'tab_output' => false, |
| 851 |
), |
| 852 |
); |
| 853 |
$tabs = apply_filters( 'fep_admin_settings_tabs', $tabs ); |
| 854 |
foreach ( $tabs as $key => $tab ) { |
| 855 |
$defaults = array( |
| 856 |
'section_id' => 'fep_settings_' . $key, |
| 857 |
'section_title' => '', |
| 858 |
'section_callback' => '', |
| 859 |
'section_page' => 'fep_settings_' . $key, |
| 860 |
'tab_output' => true, |
| 861 |
'tab_title' => '', |
| 862 |
'tab_slug' => $key, |
| 863 |
'priority' => 10, |
| 864 |
); |
| 865 |
$tabs[ $key ] = wp_parse_args( $tabs[ $key ], $defaults ); |
| 866 |
} |
| 867 |
uasort( $tabs, 'fep_sort_by_priority' ); |
| 868 |
return $tabs; |
| 869 |
} |
| 870 |
|
| 871 |
function settings_page() { |
| 872 |
$active_tab = ! empty( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general'; |
| 873 |
$args = array( |
| 874 |
'page' => 'fep_settings', |
| 875 |
); |
| 876 |
?> |
| 877 |
<div class="wrap"> |
| 878 |
<div id="poststuff"> |
| 879 |
<div id="post-body" class="metabox-holder columns-2"> |
| 880 |
<div id="post-body-content"> |
| 881 |
<h2 class="nav-tab-wrapper"> |
| 882 |
<?php |
| 883 |
foreach ( $this->tabs() as $key => $tab ) : |
| 884 |
if ( empty( $tab['tab_output'] ) ) { |
| 885 |
continue; |
| 886 |
} |
| 887 |
$args['tab'] = $tab['tab_slug']; |
| 888 |
?> |
| 889 |
<a href="<?php echo esc_url( add_query_arg( $args, admin_url( 'admin.php' ) ) ); ?>" class="nav-tab<?php if ( $active_tab == $tab['tab_slug'] ) echo ' nav-tab-active'; ?>"><?php echo $tab['tab_title']; ?></a> |
| 890 |
<?php endforeach; ?> |
| 891 |
</h2> |
| 892 |
<div id="tab_container"> |
| 893 |
<?php settings_errors( /** 'fep-settings' */ ); ?> |
| 894 |
<form method="post" action="options.php"> |
| 895 |
<?php |
| 896 |
settings_fields( 'fep_settings' ); |
| 897 |
do_settings_sections( "fep_settings_{$active_tab}" ); |
| 898 |
submit_button(); |
| 899 |
?> |
| 900 |
</form> |
| 901 |
</div><!-- #tab_container--> |
| 902 |
</div><!-- #post-body-content--> |
| 903 |
<div id="postbox-container-1" class="postbox-container"> |
| 904 |
<?php echo $this->fep_admin_sidebar(); ?> |
| 905 |
</div><!-- #postbox-container-1 --> |
| 906 |
</div><!-- #post-body --> |
| 907 |
<br class="clear" /> |
| 908 |
</div><!-- #poststuff --> |
| 909 |
</div><!-- .wrap --> |
| 910 |
<?php |
| 911 |
} |
| 912 |
|
| 913 |
function fep_admin_sidebar() { |
| 914 |
return '<div class="postbox"> |
| 915 |
<h3 class="hndle" style="text-align:center;"> |
| 916 |
<span>' . __( 'Plugin Author', 'front-end-pm' ) . '</span> |
| 917 |
</h3> |
| 918 |
<div class="inside"> |
| 919 |
<div style="text-align:center;margin:auto"> |
| 920 |
<strong>Shamim Hasan</strong><br /> |
| 921 |
Know PHP, MySQL, CSS, JavaScript, HTML. Expert in WordPress.<br /><br /> |
| 922 |
|
| 923 |
You can hire for plugin customization, build custom plugin or any kind of WordPress job via <br /> |
| 924 |
<a href="https://www.shamimsplugins.com/contact-us/?utm_campaign=admin&utm_source=sidebar&utm_medium=author" target="_blank"><strong>Contact Form</strong></a> |
| 925 |
</div> |
| 926 |
</div><!-- .inside --> |
| 927 |
</div> |
| 928 |
<div class="postbox"> |
| 929 |
<h3 class="hndle" style="text-align:center;"> |
| 930 |
<span>' . __( 'Some Useful Links', 'front-end-pm' ) . '</span> |
| 931 |
</h3> |
| 932 |
<div class="inside"> |
| 933 |
<div style="text-align:center;margin:auto"> |
| 934 |
<p>Some useful links are bellow to work with this plugin.</p> |
| 935 |
<ul> |
| 936 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm/getting-started/basic-admin-settings/?utm_campaign=admin&utm_source=sidebar&utm_medium=useful_links" target="_blank">' . __( 'Basic Admin Settings', 'front-end-pm' ) . '</a></li> |
| 937 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm/getting-started/basic-front-end-walkthrough/?utm_campaign=admin&utm_source=sidebar&utm_medium=useful_links" target="_blank">' . __( 'Walkthrough', 'front-end-pm' ) . '</a></li> |
| 938 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm/customization/remove-minlength-message-title/?utm_campaign=admin&utm_source=sidebar&utm_medium=useful_links" target="_blank">' . __( 'Remove minlength', 'front-end-pm' ) . '</a></li> |
| 939 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm/customization/remove-settings-menu-button/?utm_campaign=admin&utm_source=sidebar&utm_medium=useful_links" target="_blank">' . __( 'Remove menu', 'front-end-pm' ) . '</a></li> |
| 940 |
<li><a href="https://www.shamimsplugins.com/docs/category/front-end-pm/shortcode/?utm_campaign=admin&utm_source=sidebar&utm_medium=useful_links" target="_blank">' . __( 'Shortcodes', 'front-end-pm' ) . '</a></li> |
| 941 |
</ul> |
| 942 |
</div> |
| 943 |
</div><!-- .inside --> |
| 944 |
</div><!-- .postbox --> |
| 945 |
<div class="postbox"> |
| 946 |
<h3 class="hndle" style="text-align: center;"> |
| 947 |
<span>' . __( "Front End PM PRO", "front-end-pm" ) . '</span> |
| 948 |
</h3> |
| 949 |
<div class="inside"> |
| 950 |
<div style="text-align:center;margin:auto"> |
| 951 |
<p>Some useful links are bellow to work with this plugin.</p> |
| 952 |
<ul> |
| 953 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/email-piping/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Email Piping', 'front-end-pm' ) . '</a></li> |
| 954 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/multiple-recipients/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Multiple Recipient', 'front-end-pm' ) . '</a></li> |
| 955 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/only-admin/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Only Admin', 'front-end-pm' ) . '</a></li> |
| 956 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/group-messaging/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Group Messaging', 'front-end-pm' ) . '</a></li> |
| 957 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/email-beautify/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Email Beautify', 'front-end-pm' ) . '</a></li> |
| 958 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/read-receipt/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Read Receipt', 'front-end-pm' ) . '</a></li> |
| 959 |
<li><a href="https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/role-to-role-block/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank">' . __( 'Role to Role Block', 'front-end-pm' ) . '</a></li> |
| 960 |
<li><a href="https://www.shamimsplugins.com/products/front-end-pm-pro/?utm_campaign=admin&utm_source=sidebar&utm_medium=pro" target="_blank"><strong>' . __( 'View More', 'front-end-pm' ) . '</strong></a></li> |
| 961 |
</ul> |
| 962 |
</div> |
| 963 |
</div><!-- .inside --> |
| 964 |
</div><!-- .postbox -->'; |
| 965 |
} |
| 966 |
|
| 967 |
/** |
| 968 |
* Admin notices for review |
| 969 |
* |
| 970 |
* @access public |
| 971 |
* @return void |
| 972 |
*/ |
| 973 |
public function notice_review() { |
| 974 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 975 |
return; |
| 976 |
} |
| 977 |
if ( fep_is_pro() ) { |
| 978 |
return; |
| 979 |
} |
| 980 |
if ( fep_get_option( 'dismissed-review' ) ) { |
| 981 |
return; |
| 982 |
} |
| 983 |
$dismissed_time = get_user_meta( get_current_user_id(), 'fep_review_notice_dismiss', true ); |
| 984 |
if( ! $dismissed_time || ! is_numeric( $dismissed_time ) ){ |
| 985 |
update_user_meta( get_current_user_id(), 'fep_review_notice_dismiss', time() ); |
| 986 |
return; |
| 987 |
} |
| 988 |
if ( $dismissed_time && time() < ( $dismissed_time + WEEK_IN_SECONDS ) ) { |
| 989 |
return; |
| 990 |
} |
| 991 |
?> |
| 992 |
<div class="notice notice-info inline fep-review-notice"> |
| 993 |
<p><?php printf( __( 'Like %s plugin? Please consider review in WordPress.org and give 5★ rating.', 'front-end-pm' ), 'Front End PM' ); ?></p> |
| 994 |
<p> |
| 995 |
<a href="https://wordpress.org/support/plugin/front-end-pm/reviews/?filter=5#new-post" class="button button-primary fep-review-notice-dismiss" data-fep_click="sure" target="_blank" rel="noopener"><?php _e( 'Sure, deserve it', 'front-end-pm' ); ?></a> |
| 996 |
<button class="button-secondary fep-review-notice-dismiss" data-fep_click="later"><?php _e( 'Maybe later', 'front-end-pm' ); ?></button> |
| 997 |
<button class="button-secondary fep-review-notice-dismiss" data-fep_click="did"><?php _e( 'Already did', 'front-end-pm' ); ?></button> |
| 998 |
</p> |
| 999 |
</div> |
| 1000 |
<?php |
| 1001 |
} |
| 1002 |
|
| 1003 |
function add_settings_link( $links ) { |
| 1004 |
//add settings link in plugins page |
| 1005 |
$settings_link = '<a href="' . admin_url( 'admin.php?page=fep_settings' ) . '">' . __( 'Settings', 'front-end-pm' ) . '</a>'; |
| 1006 |
array_unshift( $links, $settings_link ); |
| 1007 |
return $links; |
| 1008 |
} |
| 1009 |
|
| 1010 |
function set_page_id( $id, $post ) { |
| 1011 |
if ( ! fep_get_option( 'page_id' ) && false !== strpos( $post->post_content, '[front-end-pm' ) ) { |
| 1012 |
fep_update_option( 'page_id', $id ); |
| 1013 |
} |
| 1014 |
} |
| 1015 |
} //END CLASS |
| 1016 |
add_action( 'init', array(Fep_Admin_Settings::init(), 'actions_filters' ) ); |
| 1017 |
|