If the shortcode is not designed to accept certain data, you’d need to customize the shortcode handler function itself. It might be a tall order for a non-programmer, though if you at least have coding aptitude you might be able to cobble something together.
You shouldn’t modify theme or plugin code directly though. Some code has action or filter hooks with which you can extend functionality. Otherwise, copy the function code into your own plugin and assign new names for your version of the handler function.
I was told I could use switch_to_blog function within my script. I want to switch to blog 5.
This is the shortcode I use to fetch the user_id, just need to get the site_id passed through it. Would I use switch_to_blog in this case?
add_shortcode('user_id_favorite_images', 'user_id_favorite_imagesCBF');
function user_id_favorite_imagesCBF($atts){
if (is_admin())
return;
extract(
shortcode_atts(
array(
'uid' => ''
),
$atts
)
);
if ( $uid == '' || !($uid > 0) || !($uid >= 1) )
return;
$curUserID = $uid;
$mam_my_favorite_images_arr = get_metadata('user',$curUserID, 'mam_my_favorite_images_arr', true);
$mam_my_favorite_images_arr = $mam_my_favorite_images_arr ? $mam_my_favorite_images_arr : array();
$media_cats_terms = get_terms( 'media-category');
if(count($mam_my_favorite_images_arr) > 0 && !empty( $media_cats_terms ) && !is_wp_error( $media_cats_terms ) ){
foreach($media_cats_terms as $media_cat_term){
$image_posts = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'attachment',
'tax_query' => array(
array(
'taxonomy' => 'media-category',
'field' => 'term_id',
'terms' => $media_cat_term->term_id,
)
)
)
); // image_posts
//echo '<pre>'; print_r($image_posts); echo '</pre>';
if(isset($image_posts[0])){
$gray_counter = 1;
foreach($image_posts as $image_post){
if( false !== array_search($image_post->ID,$mam_my_favorite_images_arr)){
$image_id = $image_post->ID;
$flag_wrt_img_uid = get_metadata('user',$curUserID, 'favorites_wrt_imageid_'.$image_id.'_uid_'.$curUserID.'_flag', true);
$count = get_metadata('post',$image_id, 'simplefavorites_count', true);
if($flag_wrt_img_uid && $flag_wrt_img_uid == 'adding_one'){
$gray_counter++;
$approveArgs = array('status' => 'approve', 'post_id' => $image_id,'user_id' => $curUserID, 'order'=>'ASC');
$approveComments = get_comments($approveArgs);
//echo '<pre>'; print_r($image_posts); echo '</pre>'
if(isset($category_name) && $category_name == $media_cat_term->name){
} else {
$category_name = $media_cat_term->name;
echo '<h3>'.($media_cat_term->name).'</h3>';
echo '<ul class="favorites-list">';
}
?>
<li class="div_table_li_wrapper" <?php echo ( ($gray_counter % 2 == 0) ? 'style="background-color:#f1f1f1"' : '')?>>
<div class="div_table" style="margin-left: 20px;">
<div class="table_row">
<div class="table_demention_1" valign="top">
<a>" class="mam_mas_fancybox" rel="example_group" href="<?php echo wp_get_attachment_url($image_id)?>"><img />" height="100" width="100" /></a>
</div>
<div class="table_demention_2" valign="top">
<div><?php echo get_the_title($image_id) ?></div>
<div> </div>
<div>
<span id="ufi_mam_favorit_wrapper">
<span class="sf-icon-spinner-wrapper">
<span class="ufi_mam_favorit_count" style="background: #ff7400;color: white;padding: 9px 9px 9px 9px; margin-top: -4px;"><?php echo $count?></span><span style="display:none;" class="sf-icon-spinner"></span></span><span type="button" name="ufi_mam_favorit_clicked" value="<?php echo $image_id?>" class="sf-icon-love ufi_mam_favorit_clicked" style="background: black;padding: 9px 9px 9px 9px;border: none;margin-top: -7px;color: #f87f94;position: absolute"></span>
</span>
</div>
</div>
</div>
</div>
<button style="<?php echo ($approveComments && count($approveComments) > 0 ? '' : 'display:none')?>" class="vc_general vc_btn3 vc_btn3-size-sm vc_btn3-shape-round vc_btn3-style-custom favorites_comments_show_hide">Show/ Hide Comments</button>
<div id="comments" class="comments-area favorites_comments_area_block" style="display:none;">
<div class="comment-list">
<?php if(shortcode_exists('sc_divider')) { echo do_shortcode('[sc_divider style="1" color="'.esc_attr(scalia_get_option('divider_default_color') ? scalia_get_option('divider_default_color') : '').'"]'); } ?>
<?php
wp_list_comments( array(
'style' => 'div',
'short_ping' => true,
'avatar_size'=> 50
),$approveComments );
?>
</div><!-- .comment-list --
</div><!-- #comments -->
</li>
Not sure where it’d go.
-
This reply was modified 6 years, 4 months ago by
haltek18.
-
This reply was modified 6 years, 4 months ago by
haltek18.