- base default shortcodes;

This commit is contained in:
nikitozzzzzzz
2018-10-22 21:53:43 +03:00
parent f4d4d48a98
commit 9e6cea911a
8 changed files with 181 additions and 15 deletions
@@ -5,6 +5,7 @@
.um-admin.post-type-um_form .manage-column.column-id {width: 60px}
.um-admin.post-type-um_form .manage-column.column-mode {width: 100px}
.um-admin.post-type-um_form .manage-column.column-is_default {width: 60px}
.um-admin.post-type-um_form .manage-column.column-title {width: 200px}
.um-admin.post-type-um_form .manage-column.column-shortcode {width: 200px}
.um-admin.post-type-um_form .manage-column.column-impressions {width: 100px}
+11 -5
View File
@@ -90,11 +90,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
*/
function manage_edit_um_form_columns( $columns ) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = __( 'Title', 'ulitmatemember' );
$new_columns['id'] = __('ID', 'ulitmatemember' );
$new_columns['mode'] = __( 'Type', 'ulitmatemember' );
$new_columns['shortcode'] = __( 'Shortcode', 'ulitmatemember' );
$new_columns['date'] = __( 'Date', 'ulitmatemember' );
$new_columns['title'] = __( 'Title', 'ulitmate-member' );
$new_columns['id'] = __('ID', 'ulitmate-member' );
$new_columns['mode'] = __( 'Type', 'ulitmate-member' );
$new_columns['is_default'] = __( 'Default', 'ulitmate-member' );
$new_columns['shortcode'] = __( 'Shortcode', 'ulitmate-member' );
$new_columns['date'] = __( 'Date', 'ulitmate-member' );
return $new_columns;
}
@@ -134,6 +135,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
echo UM()->shortcodes()->get_shortcode( $id );
break;
case 'is_default':
$is_default = UM()->query()->get_attr( 'is_default', $id );
echo empty( $is_default ) ? __( 'No', 'ultimate-member' ) : __( 'Yes', 'ultimate-member' );
break;
case 'mode':
$mode = UM()->query()->get_attr( 'mode', $id );
echo UM()->form()->display_form_type( $mode, $id );
+12 -2
View File
@@ -1121,8 +1121,18 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
// save
delete_post_meta( $post_id, '_um_profile_metafields' );
foreach ( $_POST['form'] as $k => $v ) {
if ( strstr( $k, '_um_' ) ){
update_post_meta( $post_id, $k, $v);
if ( strstr( $k, '_um_' ) ) {
if ( $k === '_um_is_default' ) {
$mode = UM()->query()->get_attr( 'mode', $post_id );
if ( ! empty( $mode ) ) {
$posts = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_um_mode' AND meta_value = %s", $mode ) );
foreach ( $posts as $p_id ) {
delete_post_meta( $p_id, '_um_is_default' );
}
}
}
update_post_meta( $post_id, $k, $v );
}
}
+3 -3
View File
@@ -298,11 +298,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
ob_start(); ?>
<p>
<?php printf( __( 'One or more of your %s pages are not correctly setup. Please visit <strong>%s > Settings</strong> to re-assign your missing pages.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_plugin_name ); ?>
<?php printf( __( '%s needs to create several pages (User Profiles, Account, Registration, Login, Password Reset, Logout, Member Directory) to function correctly.', 'ultimate-member' ), ultimatemember_plugin_name ); ?>
</p>
<p>
<a href="<?php echo esc_attr( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Setup Pages', 'ultimate-member' ) ?></a>
<a href="<?php echo esc_attr( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Create Pages', 'ultimate-member' ) ?></a>
&nbsp;
<a href="javascript:void(0);" class="button-secondary um_secondary_dimiss"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
</p>
@@ -531,7 +531,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
ob_start(); ?>
<p>
<?php printf( __( 'Thanks for installing <strong>%s</strong>! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions. If you subscribe to our mailing list we will send you a 20%% discount code for our <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
<?php printf( __( 'Thanks for installing <strong>%s</strong>! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions. If you subscribe to our mailing list we will send you a 20%% discount code for our <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
</p>
<p>
@@ -1,3 +1,24 @@
<div class="um-admin-metabox">
<?php UM()->admin_forms( array(
'class' => 'um-form-shortcode um-top-label',
'prefix_id' => 'form',
'fields' => array(
array(
'id' => '_um_is_default',
'type' => 'select',
'label' => __( 'Default Form', 'ultimate-member' ),
'tooltip' => sprintf( __( 'If you set this form as default you will have an ability to use %s shortcode for the displaying form at the page. Otherwise you will have to use %s', 'ultimate-member' ), UM()->shortcodes()->get_default_shortcode( get_the_ID() ), UM()->shortcodes()->get_shortcode( get_the_ID() ) ),
'value' => UM()->query()->get_meta_value( '_um_is_default' ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
)
) )->render_form(); ?>
<div class="um-admin-clear"></div>
<p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
<p><?php echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?></p>
</div>
+128 -3
View File
@@ -26,6 +26,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
add_shortcode( 'ultimatemember', array( &$this, 'ultimatemember' ) );
add_shortcode( 'ultimatemember_login', array( &$this, 'ultimatemember_login' ) );
add_shortcode( 'ultimatemember_register', array( &$this, 'ultimatemember_register' ) );
add_shortcode( 'ultimatemember_profile', array( &$this, 'ultimatemember_profile' ) );
add_shortcode( 'ultimatemember_directory', array( &$this, 'ultimatemember_directory' ) );
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' ) );
@@ -375,8 +380,14 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
return $output;
}
/***
*** @Logged-out only content
/**
* Logged-out only content
*
* @param array $args
* @param string $content
*
* @return string
*/
function um_loggedout($args = array(), $content = "") {
ob_start();
@@ -393,6 +404,94 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_login( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_login = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'login' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_login;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_register( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_register = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'register' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_register;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_profile( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_profile = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'profile' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_profile;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* Shortcode
*
@@ -813,7 +912,33 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
* @return string
*/
function get_shortcode( $post_id ) {
$shortcode = '[ultimatemember form_id=' . $post_id . ']';
$shortcode = '[ultimatemember form_id="' . $post_id . '"]';
return $shortcode;
}
/**
* Get Shortcode for given form ID
*
* @param $post_id
*
* @return string
*/
function get_default_shortcode( $post_id ) {
$mode = UM()->query()->get_attr( 'mode', $post_id );
switch ( $mode ) {
case 'login':
$shortcode = '[ultimatemember_login]';
break;
case 'profile':
$shortcode = '[ultimatemember_profile]';
break;
case 'register':
$shortcode = '[ultimatemember_register]';
break;
}
return $shortcode;
}
+1 -1
View File
@@ -2,7 +2,7 @@
<div class="um-postmessage">
<?php echo $this->custom_message; ?>
<?php printf( __( '%s', 'ultimate-member' ), $this->custom_message ); ?>
</div>
+4 -1
View File
@@ -192,6 +192,9 @@
if ( um_is_on_edit_profile() ) { ?>
</form>
<?php } ?>
<?php }
do_action( 'um_profile_footer', $args ); ?>
</div>
</div>