mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
+32
-1
@@ -189,6 +189,8 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
// include hook files
|
||||
add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
|
||||
|
||||
//add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
|
||||
|
||||
//run activation
|
||||
register_activation_hook( um_plugin, array( &$this, 'activation' ) );
|
||||
|
||||
@@ -203,6 +205,36 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
}
|
||||
|
||||
|
||||
function old_extensions_notice() {
|
||||
if ( ! is_admin() ) return;
|
||||
|
||||
$show = false;
|
||||
|
||||
$slugs = array_map( function( $item ) {
|
||||
return 'um-' . $item . '/um-' . $item . '.php';
|
||||
}, array_keys( $this->dependencies()->ext_required_version ) );
|
||||
|
||||
$active_plugins = $this->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;
|
||||
|
||||
/*global $um_woocommerce;
|
||||
remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
|
||||
$um_woocommerce->plugin_inactive = true;*/
|
||||
|
||||
echo '<div class="error"><p>' . sprintf( __( '<strong>ATTENTION!</strong> You have pre-2.0 version activated <strong>%s</strong> extensions. Please install the latest versions.', 'ultimate-member' ), ultimatemember_plugin_name ) . '</p></div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autoload UM classes handler
|
||||
*
|
||||
@@ -1077,7 +1109,6 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
require_once 'core/um-filters-files.php';
|
||||
require_once 'core/um-filters-navmenu.php';
|
||||
require_once 'core/um-filters-avatars.php';
|
||||
require_once 'core/um-filters-arguments.php';
|
||||
require_once 'core/um-filters-user.php';
|
||||
require_once 'core/um-filters-members.php';
|
||||
require_once 'core/um-filters-profile.php';
|
||||
|
||||
@@ -10,23 +10,27 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
function __construct() {
|
||||
|
||||
$this->message_mode = false;
|
||||
$this->custom_message = '';
|
||||
|
||||
$this->loop = array();
|
||||
|
||||
add_shortcode( 'ultimatemember', array( &$this, 'ultimatemember' ) );
|
||||
|
||||
add_shortcode('um_loggedin', array(&$this, 'um_loggedin'));
|
||||
add_shortcode('um_loggedout', array(&$this, 'um_loggedout'));
|
||||
add_shortcode('um_show_content', array(&$this, 'um_shortcode_show_content_for_role') );
|
||||
add_shortcode('ultimatemember_searchform', array(&$this, 'ultimatemember_searchform') );
|
||||
add_shortcode( 'um_loggedin', array( &$this, 'um_loggedin' ) );
|
||||
add_shortcode( 'um_loggedout', array( &$this, 'um_loggedout' ) );
|
||||
add_shortcode( 'um_show_content', array( &$this, 'um_shortcode_show_content_for_role' ) );
|
||||
add_shortcode( 'ultimatemember_searchform', array( &$this, 'ultimatemember_searchform' ) );
|
||||
|
||||
|
||||
add_filter('body_class', array(&$this, 'body_class'), 0);
|
||||
add_filter( 'body_class', array( &$this, 'body_class' ), 0 );
|
||||
|
||||
$base_uri = apply_filters('um_emoji_base_uri', 'https://s.w.org/images/core/emoji/');
|
||||
add_filter( 'um_shortcode_args_filter', array( &$this, 'display_logout_form' ), 99 );
|
||||
add_filter( 'um_shortcode_args_filter', array( &$this, 'parse_shortcode_args' ), 99 );
|
||||
|
||||
$this->emoji[':)'] = $base_uri . '72x72/1f604.png';
|
||||
$this->emoji[':smiley:'] = $base_uri . '72x72/1f603.png';
|
||||
$base_uri = apply_filters( 'um_emoji_base_uri', 'https://s.w.org/images/core/emoji/' );
|
||||
|
||||
$this->emoji[':)'] = $base_uri . '72x72/1f604.png';
|
||||
$this->emoji[':smiley:'] = $base_uri . '72x72/1f603.png';
|
||||
$this->emoji[':D'] = $base_uri . '72x72/1f600.png';
|
||||
$this->emoji[':$'] = $base_uri . '72x72/1f60a.png';
|
||||
$this->emoji[':relaxed:'] = $base_uri . '72x72/263a.png';
|
||||
@@ -86,6 +90,59 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Conditional logout form
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function display_logout_form( $args ) {
|
||||
if ( is_user_logged_in() && isset( $args['mode'] ) && $args['mode'] == 'login' ) {
|
||||
|
||||
if ( get_current_user_id() != um_user( 'ID' ) ) {
|
||||
um_fetch_user( get_current_user_id() );
|
||||
}
|
||||
|
||||
$args['template'] = 'logout';
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter shortcode args
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function parse_shortcode_args( $args ) {
|
||||
if ( $this->message_mode == true ) {
|
||||
|
||||
if ( ! empty( $_REQUEST['um_role'] ) ) {
|
||||
$args['template'] = 'message';
|
||||
$roleID = esc_attr( $_REQUEST['um_role'] );
|
||||
$role = UM()->roles()->role_data( $roleID );
|
||||
|
||||
if ( ! empty( $role ) && ! empty( $role["status"] ) ) {
|
||||
$message_key = $role["status"] . '_message';
|
||||
$this->custom_message = ! empty( $role[ $message_key ] ) ? $role[ $message_key ] : '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ( $args as $k => $v ) {
|
||||
$args[ $k ] = maybe_unserialize( $args[ $k ] );
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @emoji support
|
||||
*/
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
/***
|
||||
*** @conditional logout form
|
||||
***/
|
||||
add_filter('um_shortcode_args_filter', 'um_display_logout_form', 99);
|
||||
function um_display_logout_form( $args ) {
|
||||
if ( is_user_logged_in() && isset( $args['mode'] ) && $args['mode'] == 'login' ) {
|
||||
|
||||
if ( get_current_user_id() != um_user('ID' ) ) {
|
||||
um_fetch_user( get_current_user_id() );
|
||||
}
|
||||
|
||||
$args['template'] = 'logout';
|
||||
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @filter for shortcode args
|
||||
***/
|
||||
add_filter('um_shortcode_args_filter', 'um_shortcode_args_filter', 99);
|
||||
function um_shortcode_args_filter( $args ) {
|
||||
|
||||
if ( UM()->shortcodes()->message_mode == true ) {
|
||||
|
||||
$args['template'] = 'message';
|
||||
$roleID = esc_attr( $_REQUEST['um_role'] );
|
||||
$role = UM()->roles()->role_data( $roleID );
|
||||
$status = $role["status"];
|
||||
$message = $role["{$status}_message"];
|
||||
UM()->shortcodes()->custom_message = $message;
|
||||
|
||||
}
|
||||
|
||||
foreach( $args as $k => $v ) {
|
||||
$args[$k] = maybe_unserialize( $args[$k] );
|
||||
}
|
||||
|
||||
return $args;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user