includes(); add_filter( 'set-screen-option', array( $this, 'save_screen_options' ), 10, 3 ); // Add a column in users list to show if it's a service provider add_filter( 'manage_users_custom_column', array( $this, 'render_provider_user_column' ), 10, 3 ); add_filter( 'manage_users_columns', array( $this, 'add_users_columns' ) ); add_action( 'admin_menu', array( $this, 'admin_init' ) ); // Creates admin settings window add_action( 'admin_notices', array( $this, 'admin_notices' ) ); // Warns admin add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); // Load scripts add_action( 'admin_enqueue_scripts', array( $this, 'edit_posts_scripts' ) ); add_action( 'admin_print_styles', array( $this, 'admin_css' ) ); add_action( 'admin_notices', array( $this, 'admin_notices_new' ) ); add_action( 'wp_ajax_appointments_dismiss_notice', array( $this, 'dismiss_notice' ) ); // Add quick link to plugin settings from plugins list page. add_filter( 'plugin_action_links_' . plugin_basename( APP_PLUGIN_FILE ), array( $this, 'add_settings_link' ) ); new Appointments_Admin_Dashboard_Widget(); $this->user_profile = new Appointments_Admin_User_Profile(); include( APP_PLUGIN_DIR . '/admin/admin-helpers.php' ); } private function includes() { include_once( appointments_plugin_dir() . 'admin/class-app-list-table.php' ); include_once( appointments_plugin_dir() . 'admin/widgets/class-app-dashboard-widget.php' ); include_once( appointments_plugin_dir() . 'admin/class-app-admin-user-profile.php' ); } public function save_screen_options( $status, $option, $value ) { if ( 'appointments_records_per_page' == $option ) { return $value; } return $status; } public function add_users_columns( $columns ) { $columns['provider'] = __( 'Appointments Provider', 'appointments' ); return $columns; } public function render_provider_user_column( $content, $column, $user_id ) { if ( 'provider' === $column && appointments_is_worker( $user_id ) && App_Roles::get_capability( 'manage_options', App_Roles::CTX_PAGE_SHORTCODES ) ) { $link = admin_url( 'admin.php?page=app_settings&tab=workers' ); $content = ' ' . __( 'Edit', 'appointments' ) . ''; } return $content; } public function admin_notices_new() { $notices = _appointments_get_admin_notices(); $noticed = false; foreach ( $notices as $notice_slug => $notice ) { if ( ! current_user_can( $notice['cap'] ) ) { continue; } $user_dismissed_notices = _appointments_get_user_dismissed_notices( get_current_user_id() ); if ( $notice_text = _appointments_get_admin_notice( $notice_slug ) ) { if ( in_array( $notice_slug, $user_dismissed_notices ) ) { continue; } $noticed = true; ?>

Appointments +:

plugin_url . '/css/admin.css', false, $appointments->version ); $screen = get_current_screen(); $title = sanitize_title( __( 'Appointments', 'appointments' ) ); $allow_profile = ! empty( $appointments->options['allow_worker_wh'] ) && 'yes' == $appointments->options['allow_worker_wh']; if ( empty( $screen->base ) || ( ! preg_match( '/(^|\b|_)appointments($|\b|_)/', $screen->base ) && ! preg_match( '/(^|\b|_)' . preg_quote( $title, '/' ) . '($|\b|_)/', $screen->base ) // Super-weird admin screen base being translatable!!! && ( ! $allow_profile || ! preg_match( '/profile/', $screen->base ) || ! (defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE)) ) ) { return; } wp_enqueue_style( 'jquery-colorpicker-css', $appointments->plugin_url . '/css/colorpicker.css', false, $appointments->version ); wp_enqueue_style( 'jquery-datepick', $appointments->plugin_url . '/css/jquery.datepick.css', false, $appointments->version ); wp_enqueue_style( 'jquery-multiselect', $appointments->plugin_url . '/css/jquery.multiselect.css', false, $appointments->version ); do_action( 'app-admin-admin_styles' ); } function edit_posts_scripts() { $screen = get_current_screen(); if ( $screen->base === 'post' || $screen->base === 'edit' ) { _appointments_enqueue_jquery_ui_datepicker(); } } // Enqeue js on admin pages function admin_scripts() { global $appointments; $screen = get_current_screen(); $title = sanitize_title( __( 'Appointments', 'appointments' ) ); $allow_profile = ! empty( $appointments->options['allow_worker_wh'] ) && 'yes' == $appointments->options['allow_worker_wh']; if ( empty( $screen->base ) ) { return false; } if ( ! preg_match( '/(^|\b|_)appointments($|\b|_)/', $screen->base ) && ! preg_match( '/(^|\b|_)' . preg_quote( $title, '/' ) . '($|\b|_)/', $screen->base ) // Super-weird admin screen base being translatable!!! && ( ! $allow_profile || ! preg_match( '/profile/', $screen->base ) || ! ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) ) && 'user-edit' !== $screen->base ) { return false; } _appointments_enqueue_jquery_ui_datepicker(); wp_enqueue_script( 'jquery-colorpicker', $appointments->plugin_url . '/js/colorpicker.js', array( 'jquery' ), $appointments->version ); wp_enqueue_script( 'app-multi-datepicker', appointments_plugin_url() . 'admin/js/admin-multidatepicker.js', array( 'jquery-ui-datepicker' ), appointments_get_db_version(), true ); wp_enqueue_script( 'jquery-multiselect', $appointments->plugin_url . '/bower_components/jquery-ui-multiselect-widget/src/jquery.multiselect.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), $appointments->version ); // Make a locale check to update locale_error flag if ( empty( $appointments->options['disable_js_check_admin'] ) ) { wp_enqueue_script( 'app-js-check', $appointments->plugin_url . '/js/js-check.js', array( 'jquery' ), $appointments->version ); } wp_enqueue_script( 'appointments-admin', $appointments->plugin_url . '/admin/js/admin.js', array( 'jquery' ), $appointments->version ); wp_localize_script('appointments-admin', '_app_admin_data', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'strings' => array( 'preparing_export' => __( 'Preparing for export, please hold on...', 'appointments' ), ), )); do_action( 'app-admin-admin_scripts' ); } /** * Dismiss warning messages for the current user for the session * @since 1.1.7 */ function dismiss() { global $current_user; $keys = array( 'app_dismiss', 'app_dismiss_google', 'app_dismiss_confirmation_lacking', 'app_dismiss_app_paypal_lacking' ); foreach ( $keys as $key ) { if ( isset( $_REQUEST[ $key ] ) ) { update_user_meta( $current_user->ID, $key, true ); ?>

dismiss(); global $current_user; $r = false; $results = appointments_get_services(); if ( ! $results ) { echo '

' . __( '[Appointments+] You must define at least once service.', 'appointments' ) . '

'; $r = true; } else { foreach ( $results as $result ) { if ( $result->duration < $appointments->get_min_time() ) { echo '

' . __( '[Appointments+] One of your services has a duration smaller than time base. Please visit Services tab and after making your corrections save new settings.', 'appointments' ) . '

'; $r = true; break; } if ( $result->duration % $appointments->get_min_time() != 0 ) { echo '

' . __( '[Appointments+] One of your services is not divisible by the time base. Please visit Services tab and after making your corrections save new settings.', 'appointments' ) . '

'; $r = true; break; } if ( $result->duration > 1440 ) { echo '

' . __( '[Appointments+] One of your services has a duration greater than 24 hours. Appointments+ does not support services exceeding 1440 minutes (24 hours). ', 'appointments' ) . '

'; $r = true; break; } $dismissed = false; $dismiss_id = get_user_meta( $current_user->ID, 'app_dismiss', true ); if ( $dismiss_id ) { $dismissed = true; } if ( appointments_get_workers() && ! appointments_get_workers_by_service( $result->ID ) && ! $dismissed ) { echo '

' . __( '[Appointments+] One of your services does not have a service provider assigned. Delete services you are not using.', 'appointments' ) . '     '.__( 'Dismiss', 'appointments' ).''. '

'; $r = true; break; } } } if ( ! $appointments->db_version || version_compare( $appointments->db_version, '1.2.2', '<' ) ) { echo '

' . __( '[Appointments+] Appointments+ database tables need to be updated. Please deactivate and reactivate the plugin (DO NOT DELETE the plugin). You will not lose any saved information.', 'appointments' ) . '

'; $r = true; } // Check for duplicate shortcodes for a visited page if ( isset( $_GET['post'] ) && $_GET['post'] && $this->has_duplicate_shortcode( $_GET['post'] ) ) { echo '

' . __( '[Appointments+] More than one instance of services, service providers, confirmation, Paypal or login shortcodes on the same page may cause problems.

', 'appointments' ). '
'; } // Check for missing confirmation shortcode $dismissed_c = false; $dismiss_id_c = get_user_meta( $current_user->ID, 'app_dismiss_confirmation_lacking', true ); if ( $dismiss_id_c ) { $dismissed_c = true; } if ( ! $dismissed_c && isset( $_GET['post'] ) && $_GET['post'] && $this->confirmation_shortcode_missing( $_GET['post'] ) ) { echo '

' . __( '[Appointments+] Confirmation shortcode [app_confirmation] is always required to complete an appointment.', 'appointments' ) . '     '.__( 'Dismiss', 'appointments' ).''. '

'; $r = true; } // Check for missing app_paypal shortcode $dismissed_p = false; $dismiss_id_p = get_user_meta( $current_user->ID, 'app_dismiss_app_paypal_lacking', true ); if ( $dismiss_id_p ) { $dismiss_id_p = true; } if ( ! $dismiss_id_p && isset( $_GET['post'] ) && $_GET['post'] && $this->app_paypal_shortcode_missing( $_GET['post'] ) ) { echo '

' . __( '[Appointments+] Paypal shortcode [app_paypal] is always required to complete an appointment with pending status.', 'appointments' ) . '     '.__( 'Dismiss', 'appointments' ).''. '

'; $r = true; } return $r; } function faq_page() { global $appointments; ?>

page_id ); new Appointments_Admin_Import_Export_Settings_Page(); $this->pages = $appointments_pages; // Read Location, Service, Worker $appointments->get_lsw(); } /** * Check if there are more than one shortcodes for certain shortcode types * @since 1.0.5 * @return bool */ function has_duplicate_shortcode( $post_id ) { $post = get_post( $post_id ); if ( is_object( $post ) && $post && strpos( $post->post_content, '[app_' ) !== false ) { if ( substr_count( $post->post_content, '[app_services' ) > 1 || substr_count( $post->post_content, '[app_service_providers' ) > 1 || substr_count( $post->post_content, '[app_confirmation' ) > 1 || substr_count( $post->post_content, '[app_paypal' ) > 1 || substr_count( $post->post_content, '[app_login' ) > 1 ) { return true; } } return false; } /** * Check if confirmation shortcode missing * @since 1.2.5 * @return bool */ function confirmation_shortcode_missing( $post_id ) { $post = get_post( $post_id ); if ( is_object( $post ) && $post && strpos( $post->post_content, '[app_' ) !== false ) { if ( ! substr_count( $post->post_content, '[app_confirmation' ) && ( substr_count( $post->post_content, '[app_monthly' ) || substr_count( $post->post_content, '[app_schedule' ) ) ) { return true; } } return false; } /** * Check if app_paypal shortcode missing * @since 1.2.5 * @return bool */ function app_paypal_shortcode_missing( $post_id ) { $post = get_post( $post_id ); if ( is_object( $post ) && $post && strpos( $post->post_content, '[app_' ) !== false ) { if ( ! substr_count( $post->post_content, '[app_paypal' ) && preg_match( '/\[app_my_appointments[^\]]+status[^\]]+pending/', $post->post_content ) ) { return true; } } return false; } /** * Add quick link to plugin settings page. * * @param $links Links array. * * @return array */ public function add_settings_link( $links ) { $plugin_links = array( '' . __( 'Settings', 'appointments' ) . '', ); return array_merge( $plugin_links, $links ); } }