old_extensions_notice(); $this->main_notices(); $this->localize_note(); $this->show_update_messages(); $this->check_wrong_install_folder(); $this->admin_notice_tracking(); $this->need_upgrade(); $this->check_wrong_licenses(); $this->reviews_notice(); //$this->future_changed(); /** * UM hook * * @type action * @title um_admin_create_notices * @description Add notices to wp-admin * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_create_notices', 'function_name', 10 ); * @example * */ do_action( 'um_admin_create_notices' ); } /** * @return array */ function get_admin_notices() { return $this->list; } /** * @param $admin_notices */ function set_admin_notices( $admin_notices ) { $this->list = $admin_notices; } /** * @param $a * @param $b * * @return mixed */ function notice_priority_sort( $a, $b ) { if ( $a['priority'] == $b['priority'] ) { return 0; } return ( $a['priority'] < $b['priority'] ) ? -1 : 1; } /** * Add notice to UM notices array * * @param string $key * @param array $data * @param int $priority */ function add_notice( $key, $data, $priority = 10 ) { $admin_notices = $this->get_admin_notices(); if ( empty( $admin_notices[ $key ] ) ) { $admin_notices[ $key ] = array_merge( $data, array( 'priority' => $priority ) ); $this->set_admin_notices( $admin_notices ); } } /** * Remove notice from UM notices array * * @param string $key */ function remove_notice( $key ) { $admin_notices = $this->get_admin_notices(); if ( ! empty( $admin_notices[ $key ] ) ) { unset( $admin_notices[ $key ] ); $this->set_admin_notices( $admin_notices ); } } /** * Render all admin notices */ function render_notices() { if ( ! current_user_can( 'manage_options' ) ) { return; } $admin_notices = $this->get_admin_notices(); $hidden = get_user_meta( get_current_user_id(), 'um_hidden_admin_notices', true ); $hidden = empty( $hidden ) ? array() : $hidden; uasort( $admin_notices, array( &$this, 'notice_priority_sort' ) ); foreach ( $admin_notices as $key => $admin_notice ) { if ( empty( $hidden ) || ! in_array( $key, $hidden ) ) { $this->display_notice( $key ); } } /** * UM hook * * @type action * @title um_admin_after_main_notices * @description Insert some content after main admin notices * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_after_main_notices', 'function_name', 10 ); * @example * */ do_action( 'um_admin_after_main_notices' ); } /** * Display single admin notice * * @param string $key * @param bool $echo * * @return void|string */ function display_notice( $key, $echo = true ) { $admin_notices = $this->get_admin_notices(); if ( empty( $admin_notices[ $key ] ) ) { return; } $notice_data = $admin_notices[ $key ]; $class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated'; $dimissible = ! empty( $admin_notices[ $key ]['dimissible'] ); ob_start(); ?>
files()->upload_basedir; $path = str_replace( '/uploads/ultimatemember', '', $path ); $path = $path . '/languages/plugins/'; $path = str_replace( '//', '/', $path ); if ( ! file_exists( $path ) ) { $old = umask(0); @mkdir( $path, 0777, true ); umask( $old ); } } /** * Show notice for customers with old extension's versions */ function old_extensions_notice() { $show = false; $old_extensions = array( 'bbpress', 'followers', 'friends', 'instagram', 'mailchimp', 'messaging', 'mycred', 'notices', 'notifications', 'online', 'private-content', 'profile-completeness', 'recaptcha', 'reviews', 'social-activity', 'social-login', 'terms-conditions', 'user-tags', 'verified-users', 'woocommerce', ); $slugs = array_map( function( $item ) { return 'um-' . $item . '/um-' . $item . '.php'; }, $old_extensions ); $active_plugins = UM()->dependencies()->get_active_plugins(); foreach ( $slugs as $slug ) { if ( in_array( $slug, $active_plugins ) ) { $plugin_data = get_plugin_data( um_path . '..' . DIRECTORY_SEPARATOR . $slug ); if ( version_compare( '2.0', $plugin_data['Version'], '>' ) ) { $show = true; break; } } } if ( ! $show ) { return; } $this->add_notice( 'old_extensions', array( 'class' => 'error', 'message' => '

' . sprintf( __( '%s %s requires 2.0 extensions. You have pre 2.0 extensions installed on your site.
Please update %s extensions to latest versions. For more info see this doc.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '

', ), 0 ); } /** * Show main notices */ function main_notices() { $hide_exif_notice = get_option( 'um_hide_exif_notice' ); if ( ! extension_loaded( 'exif' ) && ! $hide_exif_notice ) { $this->add_notice( 'exif_disabled', array( 'class' => 'updated', 'message' => '

' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. Hide this notice', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '

', ), 10 ); } // Regarding page setup $pages = UM()->config()->permalinks; if ( $pages && is_array( $pages ) ) { $err = false; foreach ( $pages as $slug => $page_id ) { $page = get_post( $page_id ); if ( ! isset( $page->ID ) && in_array( $slug, array( 'user', 'account', 'members', 'register', 'login', 'logout', 'password-reset' ) ) ) { $err = true; } } if ( $err ) { $this->add_notice( 'wrong_pages', array( 'class' => 'updated', 'message' => '

' . __( 'One or more of your Ultimate Member pages are not correctly setup. Please visit Ultimate Member > Settings to re-assign your missing pages.', 'ultimate-member' ) . '

', ), 20 ); } if ( isset( $pages['user'] ) ) { $test = get_post( $pages['user'] ); if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { $this->add_notice( 'wrong_user_page', array( 'class' => 'updated', 'message' => '

' . __( 'Ultimate Member Setup Error: User page can not be a child page.', 'ultimate-member' ) . '

', ), 25 ); } } if ( isset( $pages['account'] ) ) { $test = get_post( $pages['account'] ); if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { $this->add_notice( 'wrong_account_page', array( 'class' => 'updated', 'message' => '

' . __( 'Ultimate Member Setup Error: Account page can not be a child page.', 'ultimate-member' ) . '

', ), 30 ); } } } } /** * Localization notice */ function localize_note() { $locale = get_option( 'WPLANG' ); if ( ! $locale || strstr( $locale, 'en_' ) ) { return; } if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) { return; } $hide_locale_notice = get_option( 'um_hide_locale_notice' ); if ( $hide_locale_notice ) { return; } if ( isset( UM()->available_languages[ $locale ] ) ) { $download_uri = add_query_arg( 'um_adm_action', 'um_language_downloader' ); $this->add_notice( 'locale', array( 'class' => 'updated', 'message' => '

' . sprintf( __( 'Your site language is %1$s. Good news! Ultimate Member is already available in %2$s language. Download the translation files and start using the plugin in your language now. Hide this notice','ultimate-member'), $locale, UM()->available_languages[ $locale ], $download_uri, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '

', ), 40 ); } else { $this->add_notice( 'locale', array( 'class' => 'updated', 'message' => '

' . sprintf( __( 'Ultimate Member has not yet been translated to your language: %1$s. If you have translated the plugin you need put these files ultimatemember-%1$s.po and ultimatemember-%1$s.mo in /wp-content/languages/plugins/ for the plugin to be translated in your language. Hide this notice', 'ultimate-member' ), $locale, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '

', ), 40 ); } } /** * Updating users */ function show_update_messages() { if ( ! isset( $_REQUEST['update'] ) ) { return; } $update = $_REQUEST['update']; switch( $update ) { case 'confirm_delete': $confirm_uri = admin_url( 'users.php?' . http_build_query( array( 'um_adm_action' => 'delete_users', 'user' => array_map( 'intval', (array) $_REQUEST['user'] ), 'confirm' => 1 ) ) ); $users = ''; if ( isset( $_REQUEST['user'] ) ){ foreach ( $_REQUEST['user'] as $user_id ) { $user = get_userdata( $user_id ); $users .= '#' . $user_id . ': ' . $user->user_login . '
'; } } $ignore = admin_url('users.php'); $messages[0]['err_content'] = sprintf( __( 'Are you sure you want to delete the selected user(s)? The following users will be deleted:

%s

This cannot be undone!','ultimate-member'), $users); $messages[0]['err_content'] .= '

' . __( 'Remove', 'ultimate-member' ) . '  ' . __('Undo','ultimate-member') . '

'; break; case 'language_updated': $messages[0]['content'] = __( 'Your translation files have been updated successfully.', 'ultimate-member' ); break; case 'purged_temp': $messages[0]['content'] = __( 'Your temp uploads directory is now clean.', 'ultimate-member' ); break; case 'cleared_cache': $messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' ); break; case 'got_updates': $messages[0]['content'] = __( 'You got the latest upgrades.', 'ultimate-member' ); break; case 'often_updates': $messages[0]['err_content'] = __( 'Try again later. You can run this action once daily.', 'ultimate-member' ); break; case 'form_duplicated': $messages[0]['content'] = __( 'The form has been duplicated successfully.', 'ultimate-member' ); break; case 'user_updated': $messages[0]['content'] = __( 'User has been updated.', 'ultimate-member' ); break; case 'users_updated': $messages[0]['content'] = __( 'Users have been updated.', 'ultimate-member' ); break; case 'users_role_updated': $messages[0]['content'] = __( 'Changed roles.', 'ultimate-member' ); break; case 'err_users_updated': $messages[0]['err_content'] = __( 'Super administrators cannot be modified.', 'ultimate-member' ); $messages[1]['content'] = __( 'Other users have been updated.', 'ultimate-member' ); } if ( ! empty( $messages ) ) { foreach ( $messages as $message ) { if ( isset( $message['err_content'] ) ) { $this->add_notice( 'actions', array( 'class' => 'error', 'message' => '

' . $message['err_content'] . '

', ), 50 ); } else { $this->add_notice( 'actions', array( 'class' => 'updated', 'message' => '

' . $message['content'] . '

', ), 50 ); } } } } /** * Check if plugin is installed with correct folder */ function check_wrong_install_folder() { $invalid_folder = false; $slug_array = explode( '/', um_plugin ); if ( $slug_array[0] != 'ultimate-member' ) { $invalid_folder = true; } if ( $invalid_folder ) { $this->add_notice( 'invalid_dir', array( 'class' => 'error', 'message' => '

' . sprintf( __( 'You have installed %s with wrong folder name. Correct folder name is "ultimate-member".', 'ultimate-member' ), ultimatemember_plugin_name ) . '

', ), 1 ); } } /** * Show admin notices */ public function admin_notice_tracking() { if ( ! current_user_can( 'manage_options' ) ) { return; } $hide_notice = get_option( 'um_tracking_notice' ); if ( $hide_notice ) { return; } $optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_into_tracking' ) ); $optout_url = esc_url( add_query_arg( 'um_adm_action', 'opt_out_of_tracking' ) ); ob_start(); ?>

%s! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions for %s via our website. If you subscribe to our mailing list we will immediately email you a 20%% discount code for our extensions bundle (you\'ll need to confirm your subscription via email).', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>

 

privacy policy', 'ultimate-member' ), 'https://ultimatemember.com/support/policy/' ); ?>

add_notice( 'tracking_notice', array( 'class' => 'updated', 'message' => $message, ), 2 ); } function check_wrong_licenses() { $invalid_license = 0; $arr_inactive_license_keys = array(); if ( empty( UM()->admin_settings()->settings_structure['licenses']['fields'] ) ) { return; } foreach ( UM()->admin_settings()->settings_structure['licenses']['fields'] as $field_data ) { $license = get_option( "{$field_data['id']}_edd_answer" ); if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) continue; if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) { $arr_inactive_license_keys[ ] = $license->item_name; } $invalid_license++; } if ( ! empty( $arr_inactive_license_keys ) ) { $this->add_notice( 'license_key', array( 'class' => 'error', 'message' => '

' . sprintf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on www.UltimateMember.com.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) . '

', ), 3 ); } if ( $invalid_license ) { $this->add_notice( 'license_key', array( 'class' => 'error', 'message' => '

' . sprintf( __( 'You have %d invalid or expired license keys for %s. Please go to the Licenses page to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) . '

', ), 3 ); } } function need_upgrade() { if ( ! empty( UM()->admin_upgrade()->necessary_packages ) ) { $url = add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) ); ob_start(); ?>

%s version %s needs to be updated to work correctly.
It is necessary to update the structure of the database and options that are associated with %s %s.
Please visit "Upgrade" page and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, ultimatemember_version, $url ); ?>

 

add_notice( 'upgrade', array( 'class' => 'error', 'message' => $message, ), 4 ); } else { if ( isset( $_GET['msg'] ) && 'updated' == $_GET['msg'] ) { $this->add_notice( 'upgrade', array( 'class' => 'updated', 'message' => '

' . sprintf( __( '%s %s Successfully Upgraded', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version ) . '

', ), 4 ); } } } /** * */ function reviews_notice() { $first_activation_date = get_option( 'um_first_activation_date', false ); if ( empty( $first_activation_date ) ) { return; } if ( $first_activation_date + MONTH_IN_SECONDS > time() ) { return; } ob_start(); ?>

    |         |    

add_notice( 'reviews_notice', array( 'class' => 'updated', 'message' => $message, 'dimissible' => true ), 1 ); } /** * Check Future Changes notice */ function future_changed() { ob_start(); ?>

%s future plans! Detailed future list is here', 'ultimate-member' ), ultimatemember_plugin_name, '#' ); ?>

add_notice( 'future_changes', array( 'class' => 'updated', 'message' => $message, //'dimissible' => true, ), 2 ); } function dismiss_notice() { if ( empty( $_POST['key'] ) ) { wp_send_json_error( __( 'Wrong Data', 'ultimate-member' ) ); } $hidden_notices = get_user_meta( get_current_user_id(), 'um_hidden_admin_notices', true ); $hidden_notices = empty( $hidden_notices ) ? array() : $hidden_notices; $hidden_notices[] = $_POST['key']; update_user_meta( get_current_user_id(), 'um_hidden_admin_notices', $hidden_notices ); wp_send_json_success(); } } }