mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge branch 'feature/full-class'
This commit is contained in:
@@ -3,6 +3,16 @@
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.um-admin-notice.upgraded {
|
||||
border-color: #0085ba !important;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.um-admin-notice.error {
|
||||
border-color: #dc3232 !important;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.um-admin-notice a.button-primary {
|
||||
background-color: #0085ba !important;
|
||||
border-color: #0085ba !important;
|
||||
|
||||
@@ -27,7 +27,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
$this->templates_path = um_path . 'includes/admin/templates/';
|
||||
|
||||
add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
|
||||
add_action( 'admin_notices', array( $this, 'check_wrong_install_folder' ), 3 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -54,28 +54,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 ) { ?>
|
||||
|
||||
<div class="error">
|
||||
<p>
|
||||
<?php printf( __( 'You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>"ultimate-member"</strong>.', 'ultimate-member' ), ultimatemember_plugin_name ) ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init admin action/filters + request handlers
|
||||
*/
|
||||
|
||||
@@ -13,88 +13,137 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
*/
|
||||
class Admin_Notices {
|
||||
|
||||
/**
|
||||
* Notices list
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $list = array();
|
||||
|
||||
|
||||
/**
|
||||
* Admin_Notices constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
add_action( 'admin_init', array( &$this, 'create_languages_folder' ) );
|
||||
add_action( 'admin_notices', array( &$this, 'main_notices' ), 1 );
|
||||
add_action( 'admin_notices', array( &$this, 'localize_note' ), 2 );
|
||||
add_action( 'admin_notices', array( &$this, 'show_update_messages' ), 10 );
|
||||
|
||||
add_action( 'admin_init', array( &$this, 'create_list' ), 10 );
|
||||
add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 );
|
||||
}
|
||||
|
||||
|
||||
function create_list() {
|
||||
$this->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();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* <?php
|
||||
* add_action( 'um_admin_create_notices', 'my_admin_create_notices', 10 );
|
||||
* function my_admin_create_notices() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_admin_create_notices' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To store plugin languages
|
||||
* @return array
|
||||
*/
|
||||
function create_languages_folder() {
|
||||
$path = UM()->files()->upload_basedir;
|
||||
$path = str_replace( '/uploads/ultimatemember', '', $path );
|
||||
$path = $path . '/languages/plugins/';
|
||||
$path = str_replace( '//', '/', $path );
|
||||
function get_admin_notices() {
|
||||
return $this->list;
|
||||
}
|
||||
|
||||
if ( ! file_exists( $path ) ) {
|
||||
$old = umask(0);
|
||||
@mkdir( $path, 0777, true );
|
||||
umask( $old );
|
||||
|
||||
/**
|
||||
* @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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show main notices
|
||||
* Remove notice from UM notices array
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
function main_notices() {
|
||||
function remove_notice( $key ) {
|
||||
$admin_notices = $this->get_admin_notices();
|
||||
|
||||
if ( ! defined( 'DOING_AJAX' ) ) {
|
||||
|
||||
$hide_exif_notice = get_option( 'um_hide_exif_notice' );
|
||||
|
||||
if ( !extension_loaded('exif') && !$hide_exif_notice ) {
|
||||
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>';
|
||||
|
||||
echo sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') );
|
||||
|
||||
echo '</p></div>';
|
||||
|
||||
}
|
||||
|
||||
// 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 ) {
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>' . __('One or more of your Ultimate Member pages are not correctly setup. Please visit <strong>Ultimate Member > Settings</strong> to re-assign your missing pages.','ultimate-member') . '</p></div>';
|
||||
}
|
||||
|
||||
if ( isset( $pages['user'] ) ) {
|
||||
$test = get_post( $pages['user'] );
|
||||
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>' . __('Ultimate Member Setup Error: User page can not be a child page.','ultimate-member') . '</p></div>';
|
||||
if ( ! empty( $admin_notices[ $key ] ) ) {
|
||||
unset( $admin_notices[ $key ] );
|
||||
$this->set_admin_notices( $admin_notices );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $pages['account'] ) ) {
|
||||
$test = get_post( $pages['account'] );
|
||||
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>' . __('Ultimate Member Setup Error: Account page can not be a child page.','ultimate-member') . '</p></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' );
|
||||
$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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,6 +166,149 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
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';
|
||||
|
||||
ob_start(); ?>
|
||||
|
||||
<div class="<?php echo esc_attr( $class ) ?> um-admin-notice">
|
||||
<?php echo ! empty( $notice_data['message'] ) ? $notice_data['message'] : '' ?>
|
||||
</div>
|
||||
|
||||
<?php $notice = ob_get_clean();
|
||||
if ( $echo ) {
|
||||
echo $notice;
|
||||
return;
|
||||
} else {
|
||||
return $notice;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To store plugin languages
|
||||
*/
|
||||
function create_languages_folder() {
|
||||
$path = UM()->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;
|
||||
|
||||
$slugs = array_map( function( $item ) {
|
||||
return 'um-' . $item . '/um-' . $item . '.php';
|
||||
}, array_keys( UM()->dependencies()->ext_required_version ) );
|
||||
|
||||
$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' => '<p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '</p>',
|
||||
), 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' => '<p>' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '</p>',
|
||||
), 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' => '<p>' . __( 'One or more of your Ultimate Member pages are not correctly setup. Please visit <strong>Ultimate Member > Settings</strong> to re-assign your missing pages.', 'ultimate-member' ) . '</p>',
|
||||
), 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' => '<p>' . __( 'Ultimate Member Setup Error: User page can not be a child page.', 'ultimate-member' ) . '</p>',
|
||||
), 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' => '<p>' . __( 'Ultimate Member Setup Error: Account page can not be a child page.', 'ultimate-member' ) . '</p>',
|
||||
), 30 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +320,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
if ( ! $locale || strstr( $locale, 'en_' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) {
|
||||
return;
|
||||
}
|
||||
@@ -141,21 +334,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
|
||||
$download_uri = add_query_arg( 'um_adm_action', 'um_language_downloader' );
|
||||
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>';
|
||||
|
||||
echo sprintf(__('Your site language is <strong>%1$s</strong>. Good news! Ultimate Member is already available in <strong>%2$s language</strong>. <a href="%3$s">Download the translation</a> files and start using the plugin in your language now. <a href="%4$s">Hide this notice</a>','ultimate-member'), $locale, UM()->available_languages[$locale], $download_uri, add_query_arg('um_adm_action', 'um_hide_locale_notice') );
|
||||
|
||||
echo '</p></div>';
|
||||
|
||||
$this->add_notice( 'locale', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . sprintf( __( 'Your site language is <strong>%1$s</strong>. Good news! Ultimate Member is already available in <strong>%2$s language</strong>. <a href="%3$s">Download the translation</a> files and start using the plugin in your language now. <a href="%4$s">Hide this notice</a>','ultimate-member'), $locale, UM()->available_languages[ $locale ], $download_uri, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '</p>',
|
||||
), 40 );
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>';
|
||||
|
||||
echo sprintf(__('Ultimate Member has not yet been translated to your langeuage: <strong>%1$s</strong>. If you have translated the plugin you need put these files <code>ultimatemember-%1$s.po and ultimatemember-%1$s.mo</code> in <strong>/wp-content/languages/plugins/</strong> for the plugin to be translated in your language. <a href="%2$s">Hide this notice</a>','ultimate-member'), $locale, add_query_arg('um_adm_action', 'um_hide_locale_notice') );
|
||||
|
||||
echo '</p></div>';
|
||||
$this->add_notice( 'locale', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . sprintf( __( 'Ultimate Member has not yet been translated to your language: <strong>%1$s</strong>. If you have translated the plugin you need put these files <code>ultimatemember-%1$s.po and ultimatemember-%1$s.mo</code> in <strong>/wp-content/languages/plugins/</strong> for the plugin to be translated in your language. <a href="%2$s">Hide this notice</a>', 'ultimate-member' ), $locale, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '</p>',
|
||||
), 40 );
|
||||
|
||||
}
|
||||
|
||||
@@ -233,14 +422,131 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
if ( ! empty( $messages ) ) {
|
||||
foreach ( $messages as $message ) {
|
||||
if ( isset( $message['err_content'] ) ) {
|
||||
echo '<div class="error"><p>' . $message['err_content'] . '</p></div>';
|
||||
$this->add_notice( 'actions', array(
|
||||
'class' => 'error',
|
||||
'message' => '<p>' . $message['err_content'] . '</p>',
|
||||
), 50 );
|
||||
} else {
|
||||
echo '<div class="updated" style="border-color: #0085ba;"><p>' . $message['content'] . '</p></div>';
|
||||
$this->add_notice( 'actions', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . $message['content'] . '</p>',
|
||||
), 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' => '<p>' . sprintf( __( 'You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>"ultimate-member"</strong>.', 'ultimate-member' ), ultimatemember_plugin_name ) . '</p>',
|
||||
), 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(); ?>
|
||||
|
||||
<p>
|
||||
<?php printf( __( 'Thanks for installing <strong>%s</strong>! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="<?php echo esc_url( $optin_url ) ?>" class="button button-primary"><?php _e( 'Subscribe to mailing list', 'ultimate-member' ) ?></a>
|
||||
|
||||
<a href="<?php echo esc_url( $optout_url ) ?>" class="button-secondary"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
|
||||
</p>
|
||||
|
||||
<?php $message = ob_get_clean();
|
||||
|
||||
$this->add_notice( 'invalid_dir', 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' => '<p>' . 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 <a href="%s">www.UltimateMember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) . '</p>',
|
||||
), 3 );
|
||||
}
|
||||
|
||||
if ( $invalid_license ) {
|
||||
$this->add_notice( 'license_key', array(
|
||||
'class' => 'error',
|
||||
'message' => '<p>' . sprintf( __( 'You have %d invalid or expired license keys for %s. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) . '</p>',
|
||||
), 3 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function need_upgrade() {
|
||||
if ( ! empty( UM()->admin_upgrade()->necessary_packages ) ) {
|
||||
$this->add_notice( 'upgrade', array(
|
||||
'class' => 'error',
|
||||
'message' => '<p>' . sprintf( __( '<strong>%s version %s</strong> needs to be updated. Please visit to "Upgrade" page <a href="%s">here</a> and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) ) ) . '</p>',
|
||||
), 4 );
|
||||
} else {
|
||||
if ( isset( $_GET['msg'] ) && 'updated' == $_GET['msg'] ) {
|
||||
$this->add_notice( 'upgrade', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . __( 'Successfully Upgraded', 'ultimate-member' ) . '</p>',
|
||||
), 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
||||
|
||||
//invalid licenses notice
|
||||
add_action( 'admin_notices', array( $this, 'check_wrong_licenses' ) );
|
||||
//add_action( 'admin_notices', array( $this, 'check_wrong_licenses' ) );
|
||||
|
||||
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
||||
|
||||
|
||||
@@ -39,16 +39,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
|
||||
$this->necessary_packages = $this->need_run_upgrades();
|
||||
|
||||
if ( ! empty( $this->necessary_packages ) ) {
|
||||
add_action( 'admin_notices', array( $this, 'need_upgrade' ) );
|
||||
//add_action( 'admin_notices', array( $this, 'need_upgrade' ) );
|
||||
|
||||
$this->init_packages_ajax();
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 0 );
|
||||
|
||||
add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) );
|
||||
add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) );
|
||||
} else {
|
||||
add_action( 'admin_notices', array( $this, 'updated_successfully' ) );
|
||||
}
|
||||
} /*else {
|
||||
//add_action( 'admin_notices', array( $this, 'updated_successfully' ) );
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
||||
|
||||
|
||||
if ( ! class_exists( 'UM' ) ) {
|
||||
|
||||
@@ -14,7 +13,6 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
* @method UM_Followers_API Followers_API()
|
||||
* @method UM_Friends_API Friends_API()
|
||||
* @method UM_Instagram_API Instagram_API()
|
||||
* @method UM_Invitations_API Invitations_API()
|
||||
* @method UM_Mailchimp_API Mailchimp_API()
|
||||
* @method UM_Messaging_API Messaging_API()
|
||||
* @method UM_myCRED_API myCRED_API()
|
||||
@@ -72,8 +70,9 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
* @return UM - Main instance
|
||||
*/
|
||||
static public function instance() {
|
||||
if ( is_null( self::$instance ) )
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
@@ -275,7 +274,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
// include hook files
|
||||
add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
|
||||
|
||||
add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
|
||||
//add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
|
||||
|
||||
//run activation
|
||||
register_activation_hook( um_plugin, array( &$this, 'activation' ) );
|
||||
@@ -294,7 +293,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
/**
|
||||
* Show notice for customers with old extension's versions
|
||||
*/
|
||||
function old_extensions_notice() {
|
||||
/*function old_extensions_notice() {
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
@@ -326,10 +325,10 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
|
||||
/*global $um_woocommerce;
|
||||
remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
|
||||
$um_woocommerce->plugin_inactive = true;*/
|
||||
$um_woocommerce->plugin_inactive = true;*
|
||||
|
||||
echo '<div class="error"><p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '</p></div>';
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
@@ -1250,5 +1249,6 @@ function UM() {
|
||||
return UM::instance();
|
||||
}
|
||||
|
||||
|
||||
// Global for backwards compatibility.
|
||||
$GLOBALS['ultimatemember'] = UM();
|
||||
@@ -448,18 +448,18 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
||||
}
|
||||
|
||||
$output .= '<label for="' . $key . UM()->form()->form_suffix . '">' . __( $label, UM_TEXTDOMAIN ) . '</label>';
|
||||
$output .= '<label for="' . $key . UM()->form()->form_suffix . '">' . __( $label, 'ultimate-member' ) . '</label>';
|
||||
|
||||
if (isset( $data['help'] ) && !empty( $data['help'] ) && $this->viewing == false && !strstr( $key, 'confirm_user_pass' )) {
|
||||
|
||||
if (!UM()->mobile()->isMobile()) {
|
||||
if (!isset( $this->disable_tooltips )) {
|
||||
$output .= '<span class="um-tip um-tip-w" title="' . __( $data['help'], UM_TEXTDOMAIN ) . '"><i class="um-icon-help-circled"></i></span>';
|
||||
$output .= '<span class="um-tip um-tip-w" title="' . __( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
||||
}
|
||||
}
|
||||
|
||||
if (UM()->mobile()->isMobile() || isset( $this->disable_tooltips )) {
|
||||
$output .= '<span class="um-tip-text">' . __( $data['help'], UM_TEXTDOMAIN ) . '</span>';
|
||||
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2561,7 +2561,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$field_value = $v;
|
||||
}
|
||||
|
||||
$output .= '>' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</option>';
|
||||
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
||||
|
||||
|
||||
}
|
||||
@@ -2876,7 +2876,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output .= ' />';
|
||||
|
||||
$output .= '<span class="um-field-radio-state"><i class="' . $class . '"></i></span>';
|
||||
$output .= '<span class="um-field-radio-option">' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</span>';
|
||||
$output .= '<span class="um-field-radio-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
||||
$output .= '</label>';
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
@@ -3030,7 +3030,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* ?>
|
||||
*/
|
||||
$um_field_checkbox_item_title = apply_filters( "um_field_checkbox_item_title", $um_field_checkbox_item_title, $key, $v, $data );
|
||||
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</span>';
|
||||
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
||||
$output .= '</label>';
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
@@ -3075,7 +3075,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
if (!empty( $fields )) {
|
||||
|
||||
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
|
||||
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . __( $label, UM_TEXTDOMAIN ) . '</div>';
|
||||
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . __( $label, 'ultimate-member' ) . '</div>';
|
||||
$output .= '<div class="um-field-group-body"><a href="#" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
|
||||
|
||||
foreach ($fields as $subkey => $subdata) {
|
||||
|
||||
@@ -27,8 +27,6 @@ if ( ! class_exists( 'um\core\Tracking' ) ) {
|
||||
|
||||
$this->schedule_send();
|
||||
|
||||
add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 );
|
||||
|
||||
add_action( 'um_admin_do_action__opt_into_tracking', array( $this, 'um_admin_do_action__opt_into_tracking' ) );
|
||||
add_action( 'um_admin_do_action__opt_out_of_tracking', array( $this, 'um_admin_do_action__opt_out_of_tracking' ) );
|
||||
}
|
||||
@@ -183,33 +181,5 @@ if ( ! class_exists( 'um\core\Tracking' ) ) {
|
||||
add_action( 'um_daily_scheduled_events', array( $this, 'send_checkin' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show admin notices
|
||||
*/
|
||||
public function admin_notices() {
|
||||
|
||||
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' ) );
|
||||
|
||||
echo '<div class="updated um-admin-notice"><p>';
|
||||
|
||||
printf( __( 'Thanks for installing <strong>%s</strong>! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' );
|
||||
|
||||
echo '</p>';
|
||||
|
||||
echo '<p><a href="' . esc_url( $optin_url ) . '" class="button button-primary">' . __( 'Subscribe to mailing list', 'ultimate-member' ) . '</a>';
|
||||
echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'No thanks', 'ultimate-member' ) . '</a></p></div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
/**
|
||||
* Deprecated functions
|
||||
*
|
||||
* Where functions come to die.
|
||||
* Where public functions come to die.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
//Make public functions without class creation
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,13 @@ defined( 'ABSPATH' ) || exit;
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
$plugin_data = get_plugin_data( __FILE__ );
|
||||
|
||||
/**
|
||||
* Textdomain constant backward compatibility will be removed in future releases
|
||||
*
|
||||
* @todo remove in future releases
|
||||
*/
|
||||
define( 'UM_TEXTDOMAIN', 'ultimate-member' );
|
||||
|
||||
define( 'um_url', plugin_dir_url( __FILE__ ) );
|
||||
define( 'um_path', plugin_dir_path( __FILE__ ) );
|
||||
define( 'um_plugin', plugin_basename( __FILE__ ) );
|
||||
|
||||
Reference in New Issue
Block a user