- removed some deprecated variables;

- changed the structure of the menu item's custom fields;
This commit is contained in:
nikitozzzzzzz
2018-09-17 08:29:33 +03:00
parent e807082059
commit fc298c53b7
8 changed files with 179 additions and 169 deletions
@@ -1,36 +1,34 @@
<?php
namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
/**
* Class UM_Menu_Item_Custom_Fields_Editor
* Class Admin_Navmenu
* @package um\admin\core
*/
class UM_Menu_Item_Custom_Fields_Editor {
class Admin_Navmenu {
/**
* @var array
*/
protected static $fields = array();
/**
* Initialize plugin
*/
public static function init() {
function __construct() {
self::$fields = array(
'um_nav_public' => __( 'Display Mode' ),
'um_nav_roles' => __( 'By Role' )
'um_nav_public' => __( 'Display Mode', 'ultimate-member' ),
'um_nav_roles' => __( 'By Role', 'ultimate-member' )
);
add_action( 'wp_update_nav_menu_item', array( __CLASS__, '_save' ), 10, 3 );
//add_filter( 'manage_nav-menus_columns', array( __CLASS__, '_columns' ), 99 );
add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 );
//add_filter( 'manage_nav-menus_columns', array( &$this, '_columns' ), 99 );
add_action( 'load-nav-menus.php', array( __CLASS__, 'enqueue_nav_menus_scripts' ) );
add_action( 'admin_footer-nav-menus.php', array( __CLASS__, '_wp_template' ) );
add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) );
add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) );
}
@@ -39,7 +37,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
* @param $menu_item_db_id
* @param $menu_item_args
*/
public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
@@ -56,7 +54,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
// Do some checks here...
$value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
} else {
$value = null;
}
@@ -76,7 +74,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
*
* @return array
*/
public static function _columns( $columns ) {
function _columns( $columns ) {
$columns = array_merge( $columns, self::$fields );
return $columns;
@@ -86,20 +84,20 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
/**
*
*/
public static function enqueue_nav_menus_scripts() {
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
function enqueue_nav_menus_scripts() {
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
}
/**
*
*/
public static function admin_enqueue_scripts() {
function admin_enqueue_scripts() {
UM()->admin_enqueue()->load_nav_manus_scripts();
$menus = get_posts( 'post_type=nav_menu_item&numberposts=-1' );
$menu_restriction_data = array();
$menus = get_posts( 'post_type=nav_menu_item&numberposts=-1' );
foreach ( $menus as $data ) {
$_nav_roles_meta = get_post_meta( $data->ID, 'menu-item-um_nav_roles', true );
@@ -117,6 +115,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
'um_nav_roles' => $um_nav_roles,
);
}
wp_localize_script( 'um_admin_nav_manus', 'um_menu_restriction_data', $menu_restriction_data );
}
@@ -124,7 +123,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
/**
*
*/
public static function _wp_template() {
function _wp_template() {
?>
<script type="text/html" id="tmpl-um-nav-menus-fields">
<div class="um-nav-edit">
@@ -139,43 +138,43 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
<select id="edit-menu-item-um_nav_public-{{data.menuItemID}}"
name="menu-item-um_nav_public[{{data.menuItemID}}]" style="width:100%;">
<option value="0" <# if( data.restriction_data.um_nav_public == '0' ){ #>selected="selected"<# } #>>
<?php _e( 'Everyone', 'ultimate-member' ) ?>
<?php _e( 'Everyone', 'ultimate-member' ) ?>
</option>
<option value="1" <# if( data.restriction_data.um_nav_public == '1' ){ #>selected="selected"<# } #>>
<?php _e( 'Logged Out Users', 'ultimate-member' ) ?>
<?php _e( 'Logged Out Users', 'ultimate-member' ) ?>
</option>
<option value="2" <# if( data.restriction_data.um_nav_public == '2' ){ #>selected="selected"<# } #>>
<?php _e( 'Logged In Users', 'ultimate-member' ) ?>
<?php _e( 'Logged In Users', 'ultimate-member' ) ?>
</option>
</select>
</label>
</p>
<p class="description description-wide um-nav-roles" <# if( data.restriction_data.um_nav_public == '2' ){ #>style="display: block;"<# } #>>
<?php _e( "Select the member roles that can see this link", 'ultimate-member' ) ?><br/>
<?php _e( "Select the member roles that can see this link", 'ultimate-member' ) ?><br/>
<?php $options = UM()->roles()->get_roles( false, array( 'administrator' ) );
$i = 0;
$html = '';
$columns = 2;
while ( $i < $columns ) {
$per_page = ceil( count( $options ) / $columns );
$section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
<?php $options = UM()->roles()->get_roles( false, array( 'administrator' ) );
$i = 0;
$html = '';
$columns = 2;
while ( $i < $columns ) {
$per_page = ceil( count( $options ) / $columns );
$section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
foreach ( $section_fields_per_page as $k => $title ) {
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$html .= "<label $for_attr>
foreach ( $section_fields_per_page as $k => $title ) {
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$html .= "<label $for_attr>
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][{$k}]' value='1' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
<span>{$title}</span>
</label>";
}
$html .= '</span>';
$i++;
}
echo $html; ?>
$html .= '</span>';
$i++;
}
echo $html; ?>
</p>
<div class="clear"></div>
@@ -183,9 +182,5 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
</script>
<?php
}
}
}
UM_Menu_Item_Custom_Fields_Editor::init();
}
@@ -2184,7 +2184,6 @@ JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { e
<?php if( is_multisite() ): ?>
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
<?php endif; ?>
Nav Menu Settings: <?php if( UM()->options()->get( 'disable_menu' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
+4 -24
View File
@@ -1,6 +1,4 @@
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'UM_Functions' ) ) {
@@ -11,23 +9,10 @@ if ( ! class_exists( 'UM_Functions' ) ) {
class UM_Functions {
/**
* @var
*/
var $options;
/**
* @var array variable for Flags
*/
var $screenload_flags;
/**
* UM_Functions constructor.
*/
function __construct() {
$this->init_variables();
}
@@ -91,14 +76,6 @@ if ( ! class_exists( 'UM_Functions' ) ) {
}
/**
* Set variables
*/
function init_variables() {
$this->options = get_option( 'um_options' );
}
/**
* Help Tip displaying
*
@@ -344,6 +321,9 @@ if ( ! class_exists( 'UM_Functions' ) ) {
}
/**
* @return mixed|void
*/
function cpt_list() {
/**
* UM hook
+107 -92
View File
@@ -1,4 +1,4 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
<?php if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'UM' ) ) {
@@ -57,11 +57,13 @@ if ( ! class_exists( 'UM' ) ) {
/**
* @var
*/
public $permalinks;
public $is_permalinks;
/**
* @var array Languages
* UM Available Languages
*
* @var array
*/
var $available_languages;
@@ -138,9 +140,9 @@ if ( ! class_exists( 'UM' ) ) {
* @param bool $instance
*/
public function set_class( $class_name, $instance = false ) {
if ( empty( $this->classes[$class_name] ) ) {
if ( empty( $this->classes[ $class_name ] ) ) {
$class = 'UM_' . $class_name;
$this->classes[$class_name] = $instance ? $class::instance() : new $class;
$this->classes[ $class_name ] = $instance ? $class::instance() : new $class;
}
}
@@ -179,16 +181,18 @@ if ( ! class_exists( 'UM' ) ) {
* @since 2.0.18
*/
function _um_construct() {
if ( get_option( 'permalink_structure' ) )
$this->permalinks = true;
//register autoloader for include UM classes
spl_autoload_register( array( $this, 'um__autoloader' ) );
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
if ( get_option( 'permalink_structure' ) ) {
$this->is_permalinks = true;
}
$this->is_filtering = 0;
$this->honeypot = 'request';
$this->available_languages = array(
'en_US' => 'English (US)',
'es_ES' => 'Español',
@@ -214,82 +218,11 @@ if ( ! class_exists( 'UM' ) ) {
'ar' => 'العربية',
);
/**
* UM hook
*
* @type filter
* @title um_language_textdomain
* @description Change UM textdomain
* @input_vars
* [{"var":"$domain","type":"string","desc":"UM Textdomain"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_language_textdomain', 'my_textdomain', 10, 1 );
* function my_textdomain( $domain ) {
* // your code here
* return $domain;
* }
* ?>
*/
$language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' );
$language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
/**
* UM hook
*
* @type filter
* @title um_language_locale
* @description Change UM language locale
* @input_vars
* [{"var":"$locale","type":"string","desc":"UM language locale"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_language_locale', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_language_locale', 'my_language_locale', 10, 1 );
* function my_language_locale( $locale ) {
* // your code here
* return $locale;
* }
* ?>
*/
$language_locale = apply_filters( 'um_language_locale', $language_locale );
$language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo';
/**
* UM hook
*
* @type filter
* @title um_language_file
* @description Change UM language file path
* @input_vars
* [{"var":"$language_file","type":"string","desc":"UM language file path"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_language_file', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_language_file', 'my_language_file', 10, 1 );
* function my_language_file( $language_file ) {
* // your code here
* return $language_file;
* }
* ?>
*/
$language_file = apply_filters( 'um_language_file', $language_file );
load_textdomain( $language_domain, $language_file );
// textdomain loading
$this->localize();
// include UM classes
$this->includes();
$this->plugins_loaded();
// include hook files
add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
@@ -302,7 +235,6 @@ if ( ! class_exists( 'UM' ) ) {
// init widgets
add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
//include short non class functions
require_once 'um-short-functions.php';
require_once 'um-deprecated-functions.php';
@@ -310,18 +242,90 @@ if ( ! class_exists( 'UM' ) ) {
}
public function plugins_loaded() {
//gravity forms
if ( ! function_exists('members_get_capabilities' ) ) {
/**
* Loading UM textdomain
*
* 'ultimate-member' by default
*/
function localize() {
$language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
function members_get_capabilities() {
/**
* UM hook
*
* @type filter
* @title um_language_locale
* @description Change UM language locale
* @input_vars
* [{"var":"$locale","type":"string","desc":"UM language locale"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_language_locale', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_language_locale', 'my_language_locale', 10, 1 );
* function my_language_locale( $locale ) {
* // your code here
* return $locale;
* }
* ?>
*/
$language_locale = apply_filters( 'um_language_locale', $language_locale );
}
}
/**
* UM hook
*
* @type filter
* @title um_language_textdomain
* @description Change UM textdomain
* @input_vars
* [{"var":"$domain","type":"string","desc":"UM Textdomain"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_language_textdomain', 'my_textdomain', 10, 1 );
* function my_textdomain( $domain ) {
* // your code here
* return $domain;
* }
* ?>
*/
$language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' );
$language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo';
/**
* UM hook
*
* @type filter
* @title um_language_file
* @description Change UM language file path
* @input_vars
* [{"var":"$language_file","type":"string","desc":"UM language file path"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_language_file', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_language_file', 'my_language_file', 10, 1 );
* function my_language_file( $language_file ) {
* // your code here
* return $language_file;
* }
* ?>
*/
$language_file = apply_filters( 'um_language_file', $language_file );
load_textdomain( $language_domain, $language_file );
}
/**
* 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades
*/
function old_update_patch() {
global $um_woocommerce, $um_bbpress, $um_followers, $um_friends, $um_mailchimp, $um_messaging, $um_mycred, $um_notices, $um_notifications, $um_online, $um_private_content, $um_profile_completeness, $um_recaptcha, $um_reviews, $um_activity, $um_social_login, $um_user_tags, $um_verified;
@@ -521,6 +525,7 @@ if ( ! class_exists( 'UM' ) ) {
$this->admin_gdpr();
$this->columns();
$this->notices();
$this->admin_navmenu();
} elseif ( $this->is_request( 'admin' ) ) {
$this->admin();
$this->admin_menu();
@@ -534,6 +539,7 @@ if ( ! class_exists( 'UM' ) ) {
$this->dragdrop();
$this->plugin_updater();
$this->admin_gdpr();
$this->admin_navmenu();
} elseif ( $this->is_request( 'frontend' ) ) {
$this->enqueue();
$this->account();
@@ -653,6 +659,19 @@ if ( ! class_exists( 'UM' ) ) {
}
/**
* @since 2.0.26
*
* @return um\admin\core\Admin_Navmenu()
*/
function admin_navmenu() {
if ( empty( $this->classes['admin_navmenu'] ) ) {
$this->classes['admin_navmenu'] = new um\admin\core\Admin_Navmenu();
}
return $this->classes['admin_navmenu'];
}
/**
* @since 2.0
*
@@ -1312,10 +1331,6 @@ if ( ! class_exists( 'UM' ) ) {
ob_start();
if ( $this->options()->get( 'disable_menu' ) == 0 ) {
require_once 'core/um-navmenu.php';
}
require_once 'core/um-actions-form.php';
require_once 'core/um-actions-access.php';
require_once 'core/um-actions-wpadmin.php';
@@ -31,6 +31,23 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
add_filter( 'um_localize_permalink_filter', array( &$this, 'um_localize_permalink_filter' ), 10, 2 );
add_filter( 'icl_ls_languages', array( &$this, 'um_core_page_wpml_permalink' ), 10, 1 );
$this->plugins_loaded();
}
/**
* Gravity forms role capabilities compatibility
*/
public function plugins_loaded() {
//gravity forms
if ( ! function_exists('members_get_capabilities' ) ) {
function members_get_capabilities() {
}
}
}
+1 -1
View File
@@ -81,7 +81,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
function get_download_link( $form_id, $field_key, $user_id ) {
$field_key = urlencode( $field_key );
if ( UM()->permalinks ) {
if ( UM()->is_permalinks ) {
$url = get_site_url( get_current_blog_id() );
$nonce = wp_create_nonce( $user_id . $form_id . 'um-download-nonce' );
return $url . "/um-download/{$form_id}/{$field_key}/{$user_id}/{$nonce}";
@@ -1,6 +1,7 @@
<?php
namespace um\widgets;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
+4 -1
View File
@@ -131,7 +131,10 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
= Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin =
= 2.0.26: September 17, 2018 =
= 2.0.26: September 18, 2018 =
* Enhancements:
- New files/images downloading process
* Bugfixes:
- File/Image email placeholders after registration form submitting