Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Shortcode is displaying at the top of the post WordPress

  • SOLVED

My shortcode is displaying at the top of the post and not within the content of the foreach statement. I am attaching a screenshot showing this. Here is a link to the page in http://mswp-temp.movementforlife.com/about/meet-our-team

Here is the block of code I think needs the work:


///Start Read More Shortcode

ob_start();
echo do_shortcode( '[wpex more="Read more" less="Read less"]'.$member['_tmm_comp_text'].'[/wpex]'); $tempval = ob_get_contents();
ob_end_clean();

echo $tempval;

///End Read More Shortcode



And here is all of the code


<?php
/**
* Plugin Name: Team Members PRO
* Plugin URI: http://wpdarko.com/items/team-members-pro/
* Description: A responsive, simple and clean way to display your team. Create new members, add their positions, bios, social links (and much more) and copy-paste the shortcode into any post/page. Find support and information on the <a href="http://wpdarko.com/items/team-members-pro/">plugin's page</a>.
* Version: 2.1.1
* Author: WP Darko
* Author URI: http://wpdarko.com
* License: GPL2
*/


//Checking for updates
define( 'tmm_STORE_URL', 'https://wpdarko.com' );
define( 'tmm_ITEM_NAME', 'Team Members' );

if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) {
include( dirname( __FILE__ ) . '/darko_updater/darko_updater.php' );
}

function tmm_sl_plugin_updater() {

$license_key = trim( get_option( 'tmm_license_key' ) );

$tmm_updater = new EDD_SL_Plugin_Updater( tmm_STORE_URL, __FILE__, array(
'version' => '2.1',
'license' => $license_key,
'item_name' => tmm_ITEM_NAME,
'author' => 'WP Darko'
)
);

}
add_action( 'admin_init', 'tmm_sl_plugin_updater', 0 );

//Adding license menu
function tmm_license_menu() {
add_submenu_page( 'edit.php?post_type=tmm', 'Team Members PRO', 'License activation', 'manage_options', 'team-members-license', 'tmm_license_page' );
}
add_action('admin_menu', 'tmm_license_menu');

function tmm_license_page() {
$license = get_option( 'tmm_license_key' );
$status = get_option( 'tmm_license_status' );
?>
<div class="wrap">
<div style="background:white; padding:0px 20px; margin-top:20px; padding-top:10px;">
<h2>Team Members </h2>
<h3 style="color:lightgrey;"><span style="color:lightgrey;" class="dashicons dashicons-admin-network"></span>&nbsp; License activation </h2>
<p style="color:grey;">Activating your license allows you to receive automatic updates for a year.<br/>This is <strong>NOT</strong> required for the plugin to work correctly.</p>
<form method="post" action="options.php">

<?php settings_fields('tmm_license'); ?>

<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" valign="top">
<?php _e('License Key'); ?>
</th>
<td>
<input id="tmm_license_key" name="tmm_license_key" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" />
<label class="description" for="tmm_license_key"></label>
</td>
</tr>
<?php if( false !== $license ) { ?>
<tr valign="top">
<th scope="row" valign="top">
<?php _e('Activate License'); ?>
</th>
<td>
<?php if( $status !== false && $status == 'valid' ) { ?>
<span style="color:green; line-height:29px; margin-right:20px;"><?php _e('<span style="line-height:30px;" class="dashicons dashicons-yes"></span> Activated'); ?></span>
<?php wp_nonce_field( 'tmm_nonce', 'tmm_nonce' ); ?>
<input type="submit" class="button-secondary" name="tmm_license_deactivate" value="<?php _e('Deactivate License'); ?>"/>
<?php } else {
wp_nonce_field( 'tmm_nonce', 'tmm_nonce' ); ?>
<input type="submit" class="button-secondary" name="tmm_license_activate" value="<?php _e('Activate License'); ?>"/>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php submit_button(); ?>

</form>
</div>
<?php
}

function tmm_register_option() {
register_setting('tmm_license', 'tmm_license_key', 'tmm_sanitize_license' );
}
add_action('admin_init', 'tmm_register_option');

function tmm_sanitize_license( $new ) {
$old = get_option( 'tmm_license_key' );
if( $old && $old != $new ) {
delete_option( 'tmm_license_status' );
}
return $new;
}

function tmm_activate_license() {

if( isset( $_POST['tmm_license_activate'] ) ) {

if( ! check_admin_referer( 'tmm_nonce', 'tmm_nonce' ) )
return;

$license = trim( get_option( 'tmm_license_key' ) );

$api_params = array(
'edd_action'=> 'activate_license',
'license' => $license,
'item_name' => urlencode( tmm_ITEM_NAME ),
'url' => home_url()
);

$response = wp_remote_get( add_query_arg( $api_params, tmm_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );

if ( is_wp_error( $response ) )
return false;

$license_data = json_decode( wp_remote_retrieve_body( $response ) );

update_option( 'tmm_license_status', $license_data->license );
}
}
add_action('admin_init', 'tmm_activate_license');

function tmm_deactivate_license() {

if( isset( $_POST['tmm_license_deactivate'] ) ) {

if( ! check_admin_referer( 'tmm_nonce', 'tmm_nonce' ) )
return;

$license = trim( get_option( 'tmm_license_key' ) );

$api_params = array(
'edd_action'=> 'deactivate_license',
'license' => $license,
'item_name' => urlencode( tmm_ITEM_NAME ),
'url' => home_url()
);

$response = wp_remote_get( add_query_arg( $api_params, tmm_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );

if ( is_wp_error( $response ) )
return false;

$license_data = json_decode( wp_remote_retrieve_body( $response ) );

if( $license_data->license == 'deactivated' )
delete_option( 'tmm_license_status' );

}
}
add_action('admin_init', 'tmm_deactivate_license');


/* Recover old data if there is */
add_action( 'init', 'tmmp_old_data' );

function tmmp_old_data() {

if(!get_option('tmm_is_updated_yn9090')){

global $post;
$args = array(
'post_type' => 'tmm',
'posts_per_page' => 9999,
);

$get_old = get_posts( $args );
foreach ( $get_old as $post ) : setup_postdata( $post );

$current_id = get_the_id();
$old_data_teams = get_post_meta( $current_id, 'tmm_head', false );

foreach ($old_data_teams as $key => $odata) {

$test_man[$key]['_tmm_firstname'] = $odata['tmm_firstname'];
$test_man[$key]['_tmm_lastname'] = $odata['tmm_lastname'];
$test_man[$key]['_tmm_job'] = $odata['tmm_job'];
$test_man[$key]['_tmm_photo'] = wp_get_attachment_url($odata['tmm_photo']);
$test_man[$key]['_tmm_desc'] = $odata['tmm_desc'];
$test_man[$key]['_tmm_sc_type1'] = $odata['tmm_sc_type1'];
$test_man[$key]['_tmm_sc_title1'] = $odata['tmm_sc_title1'];
$test_man[$key]['_tmm_sc_url1'] = $odata['tmm_sc_url1'];
$test_man[$key]['_tmm_sc_type2'] = $odata['tmm_sc_type2'];
$test_man[$key]['_tmm_sc_title2'] = $odata['tmm_sc_title2'];
$test_man[$key]['_tmm_sc_url2'] = $odata['tmm_sc_url2'];
$test_man[$key]['_tmm_sc_type3'] = $odata['tmm_sc_type3'];
$test_man[$key]['_tmm_sc_title3'] = $odata['tmm_sc_title3'];
$test_man[$key]['_tmm_sc_url3'] = $odata['tmm_sc_url3'];
$test_man[$key]['_tmm_sc_type4'] = $odata['tmm_sc_type4'];
$test_man[$key]['_tmm_sc_title4'] = $odata['tmm_sc_title4'];
$test_man[$key]['_tmm_sc_url4'] = $odata['tmm_sc_url4'];
$test_man[$key]['_tmm_sc_type5'] = $odata['tmm_sc_type5'];
$test_man[$key]['_tmm_sc_title5'] = $odata['tmm_sc_title5'];
$test_man[$key]['_tmm_sc_url5'] = $odata['tmm_sc_url5'];

update_post_meta($current_id, '_tmm_head', $test_man);
wp_reset_postdata();

}

$test_man = '';
$old_data_settings = get_post_meta( $current_id, 'tmm_settings_head', false );

foreach ($old_data_settings as $key => $odata) {

$var1 = $odata['tmm_columns'];
$var2 = $odata['tmm_color'];
$var3 = $odata['picture_shape'];
$var4 = $odata['picture_border'];
$var5 = $odata['picture_position'];
$var6 = $odata['picture_filter'];
$var7 = $odata['tp_border_size'];

update_post_meta($current_id, '_tmm_columns', $var1);
update_post_meta($current_id, '_tmm_color', $var2);
update_post_meta($current_id, '_tmm_picture_shape', $var3);
update_post_meta($current_id, '_tmm_picture_border', $var4);
update_post_meta($current_id, '_tmm_picture_position', $var5);
update_post_meta($current_id, '_tmm_picture_filter', $var6);
update_post_meta($current_id, '_tmm_picture_size', $var7);

}

endforeach;

update_option('tmm_is_updated_yn9090', 'old_data_recovered');

}

}

/* Enqueue scripts & styles */
add_action( 'wp_enqueue_scripts', 'add_tmmp_scripts' );
function add_tmmp_scripts() {
wp_enqueue_style( 'tmm', plugins_url('css/tmm_custom_style.min.css', __FILE__));
}

/* Enqueue admin styles */
add_action( 'admin_enqueue_scripts', 'add_admin_tmmp_style' );

function add_admin_tmmp_style() {
wp_enqueue_style( 'tmm', plugins_url('css/admin_de_style.min.css', __FILE__));
}

/* Create the Team post type */
add_action( 'init', 'create_tmmp_type' );

function create_tmmp_type() {
register_post_type( 'tmm',
array(
'labels' => array(
'name' => 'Teams',
'singular_name' => 'Team'
),
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'capability_type' => 'post',
'supports' => array( 'title' ),
'menu_icon' => 'dashicons-plus',
)
);
}

/* Hide View/Preview since it's a shortcode */
function tmmp_admin_css() {
global $post_type;
$post_types = array(
'tmm',
);
if(in_array($post_type, $post_types))
echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
}

function remove_view_link_tmmp( $action ) {

unset ($action['view']);
return $action;
}

add_filter( 'post_row_actions', 'remove_view_link_tmmp' );
add_action( 'admin_head-post-new.php', 'tmmp_admin_css' );
add_action( 'admin_head-post.php', 'tmmp_admin_css' );

// Adding the CMB2 Metabox class
if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) {
require_once dirname( __FILE__ ) . '/cmb2/init.php';
} elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) {
require_once dirname( __FILE__ ) . '/CMB2/init.php';
}

// Registering Teams metaboxes
function tmmp_register_group_metabox() {

$prefix = '_tmm_';

// Tables group
$main_group = new_cmb2_box( array(
'id' => $prefix . 'team_metabox',
'title' => '<span class="dashicons dashicons-welcome-add-page"></span> Manage Members <span style="color:#a4d55c; font-weight:400; float:right; padding-right:14px;"><span class="dashicons dashicons-admin-network"></span> PRO version</span>',
'object_types' => array( 'tmm' ),
));

$main_group->add_field( array(
'name' => '<span style="font-weight:400;">Getting started / Instructions</span>',
'desc' => 'Edit your members (see below), add more, reorder them and play around with the settings on the right. If you have trouble understanding how this works, click the "Help & Support tab on the right."',
'id' => $prefix . 'instructions',
'type' => 'title',
'row_classes' => 'de_hundred de_instructions',
) );

$tmm_group = $main_group->add_field( array(
'id' => $prefix . 'head',
'type' => 'group',
'options' => array(
'group_title' => 'Member {#}',
'add_button' => 'Add another member',
'remove_button' => 'Remove member',
'sortable' => true,
'single' => false,
),
));

$main_group->add_group_field( $tmm_group, array(
'name' => 'Member details',
'id' => $prefix . 'member_header',
'type' => 'title',
'row_classes' => 'de_hundred de_heading',
));


$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-edit"></span> Firstname</span>',
'id' => $prefix . 'firstname',
'type' => 'text',
'row_classes' => 'de_first de_twentyfive de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-edit"></span> Lastname</span>',
'id' => $prefix . 'lastname',
'type' => 'text',
'row_classes' => 'de_twentyfive de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-edit"></span> Job/role</span>',
'id' => $prefix . 'job',
'type' => 'text',
'row_classes' => 'de_fifty de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-edit"></span> Description/bio',
'id' => $prefix . 'desc',
'type' => 'textarea',
'attributes' => array(
'rows' => 6,
),
'row_classes' => 'de_first de_fifty de_textarea de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => 'Tips & Tricks',
'desc' => '<span class="dashicons dashicons-yes"></span> Add links<br/><span style="color:#bbb;">&lt;a href="http://you.com/member-page"&gt;View member page&lt;/a&gt;</span>',
'id' => $prefix . 'desc_desc',
'type' => 'title',
'row_classes' => 'de_fifty de_info',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Complementary info title</span>',
'desc' => 'This adds a little link below the description/bio, it will reveal the complementary info text when a visitor hovers over it.',
'id' => $prefix . 'comp_title',
'type' => 'text',
'row_classes' => 'de_first de_fifty de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Complementary info text</span>',
'id' => $prefix . 'comp_text',
'type' => 'textarea',
'attributes' => array(
'rows' => 1,
),
'row_classes' => 'de_fifty de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Color (per member)</span>',
'id' => $prefix . 'color',
'type' => 'colorpicker',
'row_classes' => 'de_first de_hundred de_color de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => 'Member links',
'id' => $prefix . 'member_links_header',
'type' => 'title',
'row_classes' => 'de_hundred de_heading',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-admin-generic"></span> Link type (icon)',
'id' => $prefix . 'sc_type1',
'type' => 'select',
'options' => array(
'nada' => '-',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'googleplus' => 'Google+',
'facebook' => 'Facebook',
'instagram' => 'Instagram',
'tumblr' => 'Tumblr',
'pinterest' => 'Pinterest',
'email' => 'Email',
'website' => 'Website',
'customlink' => 'Other links',
),
'default' => 'nada',
'row_classes' => 'de_first de_twentyfive de_select de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-edit"></span> Link title',
'id' => $prefix . 'sc_title1',
'type' => 'text',
'row_classes' => 'de_twentyfive de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-admin-links"></span> Link URL',
'id' => $prefix . 'sc_url1',
'type' => 'text',
'row_classes' => 'de_fifty de_text de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_type2',
'type' => 'select',
'options' => array(
'nada' => '-',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'googleplus' => 'Google+',
'facebook' => 'Facebook',
'instagram' => 'Instagram',
'tumblr' => 'Tumblr',
'pinterest' => 'Pinterest',
'email' => 'Email',
'website' => 'Website',
'customlink' => 'Other links',
),
'default' => 'nada',
'row_classes' => 'de_first de_twentyfive de_select de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_title2',
'type' => 'text',
'row_classes' => 'de_twentyfive de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_url2',
'type' => 'text',
'row_classes' => 'de_fifty de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_type3',
'type' => 'select',
'options' => array(
'nada' => '-',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'googleplus' => 'Google+',
'facebook' => 'Facebook',
'instagram' => 'Instagram',
'tumblr' => 'Tumblr',
'pinterest' => 'Pinterest',
'email' => 'Email',
'website' => 'Website',
'customlink' => 'Other links',
),
'default' => 'nada',
'row_classes' => 'de_first de_twentyfive de_select de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_title3',
'type' => 'text',
'row_classes' => 'de_twentyfive de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_url3',
'type' => 'text',
'row_classes' => 'de_fifty de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_type4',
'type' => 'select',
'options' => array(
'nada' => '-',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'googleplus' => 'Google+',
'facebook' => 'Facebook',
'instagram' => 'Instagram',
'tumblr' => 'Tumblr',
'pinterest' => 'Pinterest',
'email' => 'Email',
'website' => 'Website',
'customlink' => 'Other links',
),
'default' => 'nada',
'row_classes' => 'de_first de_twentyfive de_select de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_title4',
'type' => 'text',
'row_classes' => 'de_twentyfive de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_url4',
'type' => 'text',
'row_classes' => 'de_fifty de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_type5',
'type' => 'select',
'options' => array(
'nada' => '-',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'googleplus' => 'Google+',
'facebook' => 'Facebook',
'instagram' => 'Instagram',
'tumblr' => 'Tumblr',
'pinterest' => 'Pinterest',
'email' => 'Email',
'website' => 'Website',
'customlink' => 'Other links',
),
'default' => 'nada',
'row_classes' => 'de_first de_twentyfive de_select de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_title5',
'type' => 'text',
'row_classes' => 'de_twentyfive de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '',
'id' => $prefix . 'sc_url5',
'type' => 'text',
'row_classes' => 'de_fifty de_text de_input de_nomtop',
));

$main_group->add_group_field( $tmm_group, array(
'name' => 'Member photo',
'id' => $prefix . 'member_styling_header',
'type' => 'title',
'row_classes' => 'de_hundred de_heading',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-format-image"></span> Upload Photo',
'id' => $prefix . 'photo',
'desc' => 'This is your member\'s main photo.',
'type' => 'file',
'attributes' => array(
'placeholder' => 'Recommended size: 250x250px',
),
'options' => array(
'add_upload_file_text' => __( 'Upload', 'jt_cmb2' ),
),
'row_classes' => 'de_first de_fifty de_upload de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Upload hover photo',
'desc' => 'Add another photo that will replace the first one on hover.',
'id' => $prefix . 'photo2',
'type' => 'file',
'attributes' => array(
'placeholder' => 'Recommended size: 250x250px',
),
'options' => array(
'add_upload_file_text' => __( 'Upload', 'jt_cmb2' ),
),
'row_classes' => 'de_fifty de_upload de_input',
));

$main_group->add_group_field( $tmm_group, array(
'name' => '<span class="dashicons dashicons-admin-links"></span> Photo link URL',
'desc' => 'If a URL is added here, the member\'s photo will be clickable.',
'id' => $prefix . 'photo_url',
'type' => 'text',
'row_classes' => 'de_first de_hundred de_text de_input de_nomtop',
'attributes' => array(
'placeholder' => 'http://anything.com',
),
));

// Settings group
$side_group = new_cmb2_box( array(
'id' => $prefix . 'settings_head',
'title' => '<span class="dashicons dashicons-admin-tools"></span> Team Settings',
'object_types' => array( 'tmm' ),
'context' => 'side',
'priority' => 'high',
'closed' => true,
));

$side_group->add_field( array(
'name' => 'General settings',
'id' => $prefix . 'other_settings_desc',
'type' => 'title',
'row_classes' => 'de_hundred_side de_heading_side',
));

$side_group->add_field( array(
'name' => '<span class="dashicons dashicons-arrow-down"></span> Members to show per line',
'id' => $prefix . 'columns',
'type' => 'select',
'options' => array(
'1' => 'One member per line',
'2' => 'Two members per line',
'3' => 'Three members per line',
'4' => 'Four members per line',
'5' => 'Five members per line',
),
'default' => '3',
'row_classes' => 'de_hundred_side de_text_side',
));

$side_group->add_field( array(
'name' => '<span class="dashicons dashicons-admin-generic"></span> Force original fonts',
'desc' => 'By default this plugin will use your theme\'s font, check this to force the use of the plugin\'s original fonts.',
'id' => $prefix . 'original_font',
'type' => 'checkbox',
'row_classes' => 'de_hundred_side de_checkbox_side',
'default' => false,
));

$side_group->add_field( array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Pictures\' shape</span>',
'id' => $prefix . 'picture_shape',
'type' => 'select',
'options' => array(
'round' => 'Rounded pictures',
'square' => 'Squared pictures',
),
'default' => '3',
'row_classes' => 'de_hundred_side de_text_side',
));

$side_group->add_field( array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Pictures\' borders</span>',
'id' => $prefix . 'picture_border',
'type' => 'select',
'options' => array(
'yes' => 'Yes',
'no' => 'No',
),
'default' => 'yes',
'row_classes' => 'de_hundred_side de_text_side',
));

$side_group->add_field( array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Pictures\' position</span>',
'id' => $prefix . 'picture_position',
'type' => 'select',
'options' => array(
'floating' => 'Floating at the top',
'inbox' => 'Inside the box',
),
'default' => 'floating',
'row_classes' => 'de_hundred_side de_text_side',
));

$side_group->add_field( array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Pictures\' filter</span>',
'id' => $prefix . 'picture_filter',
'type' => 'select',
'options' => array(
'classic' => 'Classic filter',
'vintage' => 'Vintage filter',
'blackandwhite' => 'Black & White filter',
'saturated' => 'Saturated filter',
),
'default' => 'classic',
'row_classes' => 'de_hundred_side de_text_side',
));

$side_group->add_field( array(
'name' => '<span style="color:#a4d55c;"><span class="dashicons dashicons-admin-network"></span> PRO Top border\'s size</span>',
'desc' => 'In pixels, without the "px".',
'id' => $prefix . 'tp_border_size',
'type' => 'text',
'default' => '5',
'row_classes' => 'de_hundred_side de_text_side de_input',
));

// Help group
$help_group = new_cmb2_box( array(
'id' => $prefix . 'help_metabox',
'title' => '<span class="dashicons dashicons-sos"></span> Help & Support',
'object_types' => array( 'tmm' ),
'context' => 'side',
'priority' => 'high',
'closed' => true,
'row_classes' => 'de_hundred de_heading',
));

$help_group->add_field( array(
'name' => '',
'desc' => 'Find help at WPdarko.com<br/><br/><a target="_blank" href="http://wpdarko.com/support/forum/plugins/team-members/"><span class="dashicons dashicons-arrow-right-alt2"></span> Support forum</a><br/><a target="_blank" href="http://wpdarko.com/support/documentation/get-started-team-members/"><span class="dashicons dashicons-arrow-right-alt2"></span> Documentation</a>',
'id' => $prefix . 'help_desc',
'type' => 'title',
'row_classes' => 'de_hundred de_info de_info_side',
));

// Shortcode group
$show_group = new_cmb2_box( array(
'id' => $prefix . 'shortcode_metabox',
'title' => '<span class="dashicons dashicons-visibility"></span> Display my Team',
'object_types' => array( 'tmm' ),
'context' => 'side',
'priority' => 'low',
'closed' => false,
'row_classes' => 'de_hundred de_heading',
));

$show_group->add_field( array(
'name' => '',
'desc' => 'To display your Team on your site, copy-paste the Team\'s [Shortcode] in your post/page. <br/><br/>You can find this shortcode by clicking on the "Teams" tab in the menu on the left.',
'id' => $prefix . 'short_desc',
'type' => 'title',
'row_classes' => 'de_hundred de_info de_info_side',
));

}

add_action( 'cmb2_init', 'tmmp_register_group_metabox' );

//Shortcode columns
add_action( 'manage_tmm_posts_custom_column' , 'dktmmp_custom_columns', 10, 2 );

function dktmmp_custom_columns( $column, $post_id ) {
switch ( $column ) {
case 'shortcode' :
global $post;
$slug = '' ;
$slug = $post->post_name;


$shortcode = '<span style="border: solid 3px lightgray; background:white; padding:2px 7px 5px; font-size:18px; line-height:40px;">[tmm name="'.$slug.'"]</strong>';
echo $shortcode;
break;
}
}

function add_tmmp_columns($columns) {
return array_merge($columns,
array('shortcode' => __('Shortcode'),
));
}
add_filter('manage_tmm_posts_columns' , 'add_tmmp_columns');

//Tmm shortcode
function tmmp_sc($atts) {
extract(shortcode_atts(array(
"name" => ''
), $atts));

global $post;
$args = array('post_type' => 'tmm', 'name' => $name);
$custom_posts = get_posts($args);
foreach($custom_posts as $post) : setup_postdata($post);

$members = get_post_meta( get_the_id(), '_tmm_head', true );
$options = get_post_meta( get_the_id(), '_tmm_settings_head', true );

$tmm_columns = get_post_meta( $post->ID, '_tmm_columns', true );
$tmm_color = get_post_meta( $post->ID, '_tmm_color', true );
$tmm_picture_shape = get_post_meta( $post->ID, '_tmm_picture_shape', true );
$tmm_picture_border = get_post_meta( $post->ID, '_tmm_picture_border', true );
$tmm_picture_position = get_post_meta( $post->ID, '_tmm_picture_position', true );
$tmm_picture_filter = get_post_meta( $post->ID, '_tmm_picture_filter', true );
$tmm_picture_tp_border_size = get_post_meta( $post->ID, '_tmm_tp_border_size', true );

/* checking the PRO options */
if ($tmm_picture_position == 'inbox') {
$picture_pos .= 'tmm-inbox-pic ';
}

$output .= '<div class="tmm tmm_'.$name.' '.$picture_pos.'">';
$output .= '<div class="tmm_'.$tmm_columns.'_columns">';
$output .= '
<div class="tmm_wrap">
';

$counter = 1;
$cols = $tmm_columns;

/* checking the PRO options */

if ($tmm_picture_shape == 'square') {
$picture_classes .= 'tmm_squared-borders ';
}

if ($tmm_picture_border == 'no') {
$picture_classes .= 'tmm_no-borders ';
}

if ($tmm_picture_filter == 'vintage') {
$picture_classes .= 'tmm_filter-vintage ';
}

if ($tmm_picture_filter == 'blackandwhite') {
$picture_classes .= 'tmm_filter-bandw ';
}

if ($tmm_picture_filter == 'saturated') {
$picture_classes .= 'tmm_filter-saturated ';
}

// Forcing original fonts?
$original_font = get_post_meta( $post->ID, '_tmm_original_font', true );
if ($original_font == true){
$ori_f = 'tmm_ori_f';
} else {
$ori_f = '';
}

foreach ($members as $key => $member) {

if($i%$tmm_columns == 0) {
if($i > 0) {
$output .= "</div>";
$output .= '<div class="clearer"></div>';
} // close div if it's not the first


$output .= "<div class='tmm_container'>";
}

$output .= '<div class="tmm_member '.$ori_f.'" style="border-top:'.$member['_tmm_color'].' solid '.$tmm_picture_tp_border_size.'px;">';
if (!empty($member['_tmm_photo_url'])){
$output .= '<a href="'.$member['_tmm_photo_url'].'" title="'.$member['_tmm_firstname'].' '.$member['_tmm_lastname'].'">';
}
if (!empty($member['_tmm_photo'])){
$output .= '<div class="'.$picture_classes.' tmm_photo tmm_phover_'.$name.'_'.$key.'" style="background: url('.$member['_tmm_photo'].'); margin-left: auto; margin-right:auto; background-size:cover !important;"></div>';
if (!empty($member['_tmm_photo2'])){
$output .= '<style>.tmm_phover_'.$name.'_'.$key.':hover {background: url('.$member['_tmm_photo2'].') no-repeat !important;}</style>';
}
}
if (!empty($member['_tmm_photo_url'])){
$output .= '</a>';
}
$output .= '<div class="tmm_textblock">';
$output .= '<div class="tmm_names">';
$output .= '<span class="tmm_fname">'.$member['_tmm_firstname'].'</span>';
$output .= '&nbsp;';
$output .= '<span class="tmm_lname">'.$member['_tmm_lastname'].'</span>';
$output .= '</div>';
$output .= '<div class="tmm_job">'.$member['_tmm_job'].'</div>';

$output .= '<div class="tmm_desc">';
$output .= $member['_tmm_desc'];
$output .= '</div>';


///Start Read More Shortcode

ob_start();
echo do_shortcode( '[wpex more="Read more" less="Read less"]'.$member['_tmm_comp_text'].'[/wpex]'); $tempval = ob_get_contents();
ob_end_clean();

echo $tempval;

///End Read More Shortcode


// $output .= '</div>';
$output .= '<div class="tmm_scblock">';
if ($member['_tmm_sc_type1'] != 'nada') {
if ($member['_tmm_sc_type1'] == 'email') {
$output .= '<a class="tmm_sociallink" href="mailto:'.$member['_tmm_sc_url1'].'" title="'.$member['_tmm_sc_title1'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title1'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type1'].'.png"/>';
$output .= '</a>';
} else {
$output .= '<a class="tmm_sociallink" href="'.$member['_tmm_sc_url1'].'" title="'.$member['_tmm_sc_title1'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title1'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type1'].'.png"/>';
$output .= '</a>';
}
}

if ($member['_tmm_sc_type2'] != 'nada') {
if ($member['_tmm_sc_type2'] == 'email') {
$output .= '<a class="tmm_sociallink" href="mailto:'.$member['_tmm_sc_url2'].'" title="'.$member['_tmm_sc_title2'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title2'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type2'].'.png"/>';
$output .= '</a>';
} else {
$output .= '<a class="tmm_sociallink" href="'.$member['_tmm_sc_url2'].'" title="'.$member['_tmm_sc_title2'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title2'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type2'].'.png"/>';
$output .= '</a>';
}
}

if ($member['_tmm_sc_type3'] != 'nada') {
if ($member['_tmm_sc_type3'] == 'email') {
$output .= '<a class="tmm_sociallink" href="mailto:'.$member['_tmm_sc_url3'].'" title="'.$member['_tmm_sc_title3'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title3'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type3'].'.png"/>';
$output .= '</a>';
} else {
$output .= '<a class="tmm_sociallink" href="'.$member['_tmm_sc_url3'].'" title="'.$member['_tmm_sc_title3'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title3'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type3'].'.png"/>';
$output .= '</a>';
}
}
if (isset($member['_tmm_sc_type4'])) {
if ($member['_tmm_sc_type4'] != 'nada') {
if ($member['_tmm_sc_type4'] == 'email') {
$output .= '<a class="tmm_sociallink" href="mailto:'.$member['_tmm_sc_url4'].'" title="'.$member['_tmm_sc_title4'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title4'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type4'].'.png"/>';
$output .= '</a>';
} else {
$output .= '<a class="tmm_sociallink" href="'.$member['_tmm_sc_url4'].'" title="'.$member['_tmm_sc_title4'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title4'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type4'].'.png"/>';
$output .= '</a>';
}
}}
if (isset($member['_tmm_sc_type4'])) {
if ($member['_tmm_sc_type5'] != 'nada') {
if ($member['_tmm_sc_type5'] == 'email') {
$output .= '<a class="tmm_sociallink" href="mailto:'.$member['_tmm_sc_url5'].'" title="'.$member['_tmm_sc_title5'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title5'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type5'].'.png"/>';
$output .= '</a>';
} else {
$output .= '<a class="tmm_sociallink" href="'.$member['_tmm_sc_url5'].'" title="'.$member['_tmm_sc_title5'].'">';
$output .= '<img alt="'.$member['_tmm_sc_title5'].'" src="'.plugins_url('img/links/', __FILE__).$member['_tmm_sc_type5'].'.png"/>';
$output .= '</a>';
}
}}
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';

$pages_count = count( $members );
if ($key == $pages_count - 1) {
$output .= '<div class="clearer"></div>';
}

$i++;

}

$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';


endforeach; wp_reset_query();

return $output;

}
add_shortcode("tmm", "tmmp_sc");

?>

Answers (3)

2015-05-31

Dbranes answers:

Hi, you could try replacing

echo $tempval;


with

$output .= $tempval;

The shortcode callback <em>tmmp_sc()</em> must <strong>return</strong> the values, not <strong>echo</strong> it, otherwise you get some of its output in wrong place.


Dbranes comments:

You might also try to simplify things.

Instead of:

///Start Read More Shortcode
ob_start();
echo do_shortcode( '[wpex more="Read more" less="Read less"]'.$member['_tmm_comp_text'].'[/wpex]');
$tempval = ob_get_contents();
ob_end_clean();
$output .= $tempval;
///End Read More Shortcode


you could try:


$output .= do_shortcode( '[wpex more="Read more" less="Read less"]'.$member['_tmm_comp_text'].'[/wpex]');


or you could even use the shortcode callback directly for the <em>[wpex]</em>.


konigmedia comments:

Thank you! this did the trick!


Dbranes comments:

@konigmedia

great to hear it worked for you

2015-05-31

Reigel Gallarde answers:

instead of echo, try
$output .= $tempval;

2015-05-31

zebra webdesigns answers:

Instead of echo use return