example of wordpress user query with meta key and value

$user_query = new WP_User_Query( array( 'meta_key' => 'round', 'meta_value' => get_the_author_meta('round', $queried_auther->ID) ) );
$args = array(
	'meta_query' => array(
		'relation' => 'AND',
		0 => array(
			'key'     => 'round',
			'value'   => get_the_author_meta('round', $queried_auther->ID),
			'compare' => '='
		),
		1 => array(
			'key'     => 'Time',
			'value'   => 0,
			'type'    => 'numeric',
			'compare' => '>'
		)
	),
	'meta_key' => 'Time',
    'orderby'   => 'meta_value_num',
	'order' => 'DESC',
	'fields' => 'ID'
 );

 

get certain submenu in wordpress menus

function submenu_get_children_ids( $id, $items ) {

    $ids = wp_filter_object_list( $items, array( 'menu_item_parent' => $id ), 'and', 'object_id' );

    foreach ( $ids as $id ) {

        $ids = array_merge( $ids, submenu_get_children_ids( $id, $items ) );
    }

    return $ids;
}

 $menu_name = 'primary-menu';

    if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
	$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );

	$menu_items = wp_get_nav_menu_items($menu->term_id);

$parent_id = array_pop( wp_filter_object_list( $menu_items, array( 'classes' => array('filter_this') ), 'and', 'ID' ) );
$children  = submenu_get_children_ids( $parent_id, $menu_items );

 

add social buttons to WordPress Embeds

php code: functions.php

<?php
add_filter('embed_oembed_html', 'add_social_share_buttons', 10, 3);

function add_social_share_buttons($data, $url, $args = array()) {

$app_id = '408929209210377';
$thanks_id = al_get_page_by_template('page-thank-you.php');

global $post;
 if (has_post_thumbnail( $post->ID ) ){
	$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
 }

    ob_start();
    ?>
<div class="share_vid_buttons">
    <div class="share" id="shareTop">
        <a data-type="facebook" href="https://www.facebook.com/dialog/feed?app_id=<?php echo $app_id; ?>&name=<?php echo get_the_title($post->ID); ?>&display=popup&link=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&picture='.$image[0];} ?>&redirect_uri=<?php echo get_permalink($thanks_id); ?>" class="btn btn-share facebook_button"  target="_blank" title="Share on Facebook">
		<span class="textNode icon"><span class="hidden-phone">Share On</span>Facebook</span>
		</a>
		<a href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>" class="btn btn-share twitter_button" target="_blank" title="Share on Twitter">
		<span class="textNode icon">Twitter</span>
		</a>
		<a class="pin_it_btn" href="//www.pinterest.com/pin/create/button/?url=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&media='.$image[0];} ?>&description=<?php echo get_the_title($post->ID); ?>"  target="_blank" ><i class="fa fa-pinterest"></i> Pin It</a>
		</div>
    <div class="vid_cont_social">
        <ul class="share hidden-phone" id="shareOverlay">
            <li class="facebook">
                <a href="https://www.facebook.com/dialog/feed?app_id=<?php echo $app_id; ?>&name=<?php echo get_the_title($post->ID); ?>&display=popup&link=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&picture='.$image[0];} ?>&redirect_uri=<?php echo get_permalink($post->ID); ?>" class="btn btn-share facebook_button" target="_blank" title="Share on Facebook">Facebook</a>
            </li>
            <li class="twitter">
                <a class="btn btn-share twitter_button" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>" class="btn btn-share twitter_button" target="_blank" title="Share on Twitter">Twitter</a>
            </li>
        </ul>

        <?php
        echo wp_oembed_get( $url, $args );
        ?>

    </div>
    <div id="shareRowBottom">
        <a href="https://www.facebook.com/dialog/feed?app_id=<?php echo $app_id; ?>&name=<?php echo get_the_title($post->ID); ?>&display=popup&link=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&picture='.$image[0];} ?>&redirect_uri=<?php echo get_permalink($thanks_id); ?>" target="_blank" class="btn btn-share facebook_button" title="Share on Facebook">
            <span class="textNode icon"><span class="preface">Share on</span> Facebook</span>
        </a>
        <a class="btn btn-share twitter_button" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>" class="btn btn-share twitter_button" target="_blank" title="Share on Twitter">
            <span class="textNode icon"><span class="preface">Share on</span> Twitter</span>
        </a>
    </div>

	<!-- modal content -->
		<div id="basic-modal-content">

<div class="content">
  <div class="postShareSocial" style="text-align:center;">
    <h3>Want More Stuff Like This?</h3>
    <div class="message facebook">
      <p>Help us strengthen our country by spreading our culture far and wide.</p> 
<p>Like us on Facebook to add daily Awesomeness to your feed.</p>
      <p>
        <iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FBahamianTube&amp;width&amp;layout=button_count&amp;action=like&amp;show_faces=true&amp;share=false&amp;height=21&amp;appId=408929209210377" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px;width: 95px;" allowTransparency="true"></iframe>

		<a href="https://twitter.com/BahamianTube" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @BahamianTube</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

      </p>
    </div>
  </div>
</div><!-- /content -->

		</div>

		<!-- preload the images -->
		<div style='display:none'>
			<img src='<?php echo dirname( get_bloginfo('stylesheet_url') ) ?>/img/basic/x.png' alt='' />
		</div>

</div>
    <?php
    $out = ob_get_contents();

    ob_end_clean();

$output = str_replace(array("rn", "r", "n"), "", $out);

    return $output;
}

function theme_name_scripts() {
	wp_enqueue_style( 'jquery-tabs', dirname( get_bloginfo('stylesheet_url') ) . '/css/jquery-tabs.css');
	wp_enqueue_style( 'font-awesome', dirname( get_bloginfo('stylesheet_url') ) . '/css/font-awesome.min.css' );
	wp_enqueue_script( 'popupwindow', dirname( get_bloginfo('stylesheet_url') ) . '/js/jquery.popupwindow.js', array( 'jquery' ), '1.0', false);
	wp_enqueue_script( 'jquery-tabs-js', dirname( get_bloginfo('stylesheet_url') ) . '/js/jquery-tabs.js', array( 'jquery'), '1.0', false);
	wp_enqueue_script( 'jquery.simplemodal.js', dirname( get_bloginfo('stylesheet_url') ) . '/js/jquery.simplemodal.js', array( 'jquery'), '1.0', false);
	//wp_enqueue_script( 'pinit', '//assets.pinterest.com/js/pinit.js', array(), '1.0', true);
	wp_enqueue_script( 'custom-js', dirname( get_bloginfo('stylesheet_url') ) . '/js/custom.js', array( 'jquery', 'popupwindow', 'jquery-tabs-js' ), '1.0', true);

}

add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

function share_buttons_above( $atts ){

$app_id = '408929209210377';
$thanks_id = al_get_page_by_template('page-thank-you.php');
global $post;
 if (has_post_thumbnail( $post->ID ) ){
	$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
 }

    ob_start();
    ?>
<div class="share_vid_buttons">
    <div class="share" id="shareTop">
        <a data-type="facebook" href="https://www.facebook.com/dialog/feed?app_id=<?php echo $app_id; ?>&name=<?php echo get_the_title($post->ID); ?>&display=popup&link=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&picture='.$image[0];} ?>&redirect_uri=<?php echo get_permalink($thanks_id); ?>" class="btn btn-share facebook_button"  target="_blank" title="Share on Facebook">
		<span class="textNode icon"><span class="hidden-phone">Share On</span>Facebook</span>
		</a>
		<a href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>" class="btn btn-share twitter_button" target="_blank" title="Share on Twitter">
		<span class="textNode icon">Twitter</span>
		</a>
		<a class="pin_it_btn" href="//www.pinterest.com/pin/create/button/?url=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&media='.$image[0];} ?>&description=<?php echo get_the_title($post->ID); ?>"  target="_blank" ><i class="fa fa-pinterest"></i> Pin It</a>
		</div>
</div>

	<!-- modal content -->
		<div id="basic-modal-content">

<div class="content">
  <div class="postShareSocial" style="text-align:center;">
    <h3>Want More Stuff Like This?</h3>
    <div class="message facebook">
      <p>Help us strengthen our country by spreading our culture far and wide.</p> 
<p>Like us on Facebook to add daily Awesomeness to your feed.</p>
      <p>
        <iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FBahamianTube&amp;width&amp;layout=button_count&amp;action=like&amp;show_faces=true&amp;share=false&amp;height=21&amp;appId=408929209210377" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px;width: 95px;" allowTransparency="true"></iframe>

		<iframe frameborder="0" scrolling="no" id="twitter-widget-0" allowtransparency="true" src="http://platform.twitter.com/widgets/follow_button.1387492107.html#_=1389504017106&amp;id=twitter-widget-0&amp;lang=en&amp;screen_name=BahamianTube&amp;show_count=false&amp;show_screen_name=false&amp;size=m" class="twitter-follow-button twitter-follow-button" title="Twitter Follow Button" data-twttr-rendered="true" style="width: 60px; height: 20px;"></iframe>

      </p>
    </div>
  </div>
</div><!-- /content -->

		</div>

		<!-- preload the images -->
		<div style='display:none'>
			<img src='<?php echo dirname( get_bloginfo('stylesheet_url') ) ?>/img/basic/x.png' alt='' />
		</div>

    <?php
    $out = ob_get_contents();

    ob_end_clean();

$output = str_replace(array("rn", "r", "n"), "", $out);

    return $output;

}
add_shortcode( 'share_buttons_above', 'share_buttons_above' );

function share_buttons_below( $atts ){

$app_id = '408929209210377';
$thanks_id = al_get_page_by_template('page-thank-you.php');
global $post;
 if (has_post_thumbnail( $post->ID ) ){
	$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
 }

    ob_start();
    ?>
<div class="share_vid_buttons">
    <div id="shareRowBottom">
        <a href="https://www.facebook.com/dialog/feed?app_id=<?php echo $app_id; ?>&name=<?php echo get_the_title($post->ID); ?>&display=popup&link=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&picture='.$image[0];} ?>&redirect_uri=<?php echo get_permalink($thanks_id); ?>" target="_blank" class="btn btn-share facebook_button" title="Share on Facebook">
            <span class="textNode icon"><span class="preface">Share on</span> Facebook</span>
        </a>
        <a class="btn btn-share twitter_button" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>" class="btn btn-share twitter_button" target="_blank" title="Share on Twitter">
            <span class="textNode icon"><span class="preface">Share on</span> Twitter</span>
        </a>
    </div>
</div>
    <?php
    $out = ob_get_contents();

    ob_end_clean();

$output = str_replace(array("rn", "r", "n"), "", $out);

    return $output;

}
add_shortcode( 'share_buttons_below', 'share_buttons_below' );

function share_buttons_over_video( $atts, $content = null ) {
$app_id = '408929209210377';
$thanks_id = al_get_page_by_template('page-thank-you.php');
global $post;
 if (has_post_thumbnail( $post->ID ) ){
	$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
 }

    ob_start();
    ?>
<div class="share_vid_buttons">
    <div class="vid_cont_social">
        <ul class="share hidden-phone" id="shareOverlay">
            <li class="facebook">
                <a href="https://www.facebook.com/dialog/feed?app_id=<?php echo $app_id; ?>&name=<?php echo get_the_title($post->ID); ?>&display=popup&link=<?php echo get_permalink($post->ID); ?><?php if($image){echo '&picture='.$image[0];} ?>&redirect_uri=<?php echo get_permalink($thanks_id); ?>" class="btn btn-share facebook_button" target="_blank" title="Share on Facebook">Facebook</a>
            </li>
            <li class="twitter">
                <a class="btn btn-share twitter_button" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>" class="btn btn-share twitter_button" target="_blank" title="Share on Twitter">Twitter</a>
            </li>
        </ul>

        <?php
        echo wp_oembed_get( $content, $args = array() );
        ?>

    </div>
</div>
    <?php
    $out = ob_get_contents();

    ob_end_clean();
/*array("rn", "r", "n")*/
$output = str_replace(array("rn", "r", "n"), "", $out);

    return $output;
}
add_shortcode( 'share_buttons_over_video', 'share_buttons_over_video' );

function wpb_set_post_views($postID) {
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

function wpb_track_post_views ($post_id) {
    if ( !is_single() ) return;
    if ( empty ( $post_id) ) {
        global $post;
        $post_id = $post->ID;    
    }
    wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');

function wpb_get_post_views($postID){
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' Views';
}

add_image_size( 'featured-thumb', 75, 50, true );

function al_get_page_by_template($template_name) {
    $pages = get_posts(array(
        'post_type' => 'page',
        'meta_key' => '_wp_page_template',
        'meta_value' => $template_name
    ));
    $pagepid = $pages[0]->ID;
    return $pagepid;
}

 

css style code: style.css

/*  share button css */

.share_vid_buttons #shareTop
            {
                list-style: none;
                padding: 0;
                position: relative;
                z-index: 4;
                margin: 0;
                *zoom: 1;
            }

            .share_vid_buttons #shareTop:before, .share_vid_buttons #shareTop:after
            {
                display: table;
                content: "";
                line-height: 0;
            }

            .share_vid_buttons #shareTop:after
            {
                clear: both;
            }

            .share_vid_buttons #shareTop a
            {
                -webkit-user-select: none;
                -moz-user-select: none;
                -ms-user-select: none;
                -o-user-select: none;
                user-select: none;
                display: -moz-inline-stack;
                display: inline-block;
                zoom: 1;
                *display: inline;
                vertical-align: top;
                padding: 9px 18px;
                margin-right: 2px;
				line-height: 15px;
            }

            .share_vid_buttons #shareTop a .textNode
            {
                display: -moz-inline-stack;
                display: inline-block;
                zoom: 1;
                *display: inline;
                vertical-align: top;
                vertical-align: middle;
                line-height: 1em;
                height: 1em;
            }

            .share_vid_buttons #shareTop a.facebook_button .icon:before
            {
                content: 'f09a';
                color: #fff;
                font-size: 1.2em;
                padding: 0;
                line-height: 1em;
                vertical-align: middle;
                position: relative;
                top: -1px;
                margin-right: 6px;
                margin-left: -5px;
                padding-top: 0;
                margin-right: 8px;
            }

            .share_vid_buttons #shareTop a.twitter_button .icon:before
            {
                content: 'f099';
                color: #fff;
                font-size: 1.2em;
                padding: 0;
                line-height: 1em;
                vertical-align: middle;
                position: relative;
                top: -1px;
                margin-right: 6px;
                margin-left: -5px;
                padding-top: 0;
            }

            .share_vid_buttons a.facebook_button
            {
                border-color: #37538d #37538d #213256;
                border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
                color: #ffffff;
                text-shadow: 0 0px 1px #283d68;
                background-color: #3e5ea1;
                background-image: -moz-linear-gradient(top, #4466ae, #37538d);
                background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#4466ae), to(#37538d));
                background-image: -webkit-linear-gradient(top, #4466ae, #37538d);
                background-image: -o-linear-gradient(top, #4466ae, #37538d);
                background-image: linear-gradient(to bottom, #4466ae, #37538d);
                background-repeat: repeat-x;
                filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff4466ae', endColorstr='#ff37538d', GradientType=0);
                border-color: #283d68;
                *background-color: #37538d;
                filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
                -webkit-user-select: none;
                -moz-user-select: none;
                -ms-user-select: none;
                -o-user-select: none;
                user-select: none;
                border-color: #37538d;
                -webkit-box-shadow: inset 0px 1px 1px rgba(255,255,255,.2);
                -moz-box-shadow: inset 0px 1px 1px rgba(255,255,255,.2);
                box-shadow: inset 0px 1px 1px rgba(255,255,255,.2);
            }

            .share_vid_buttons a.facebook_button:hover, .share_vid_buttons a.facebook_button:focus, .share_vid_buttons a.facebook_button:active,  .share_vid_buttons a.facebook_button.active, .share_vid_buttons a.facebook_button.disabled, .share_vid_buttons a.facebook_button[disabled]
            {
                color: #ffffff;
                background-color: #37538d;
                *background-color: #30487b;
            }

            .share_vid_buttons  a.facebook_button:active, .share_vid_buttons a.facebook_button.active
            {
                background-color: #283d68 9;
            }

            .share_vid_buttons a.facebook_button:hover, .share_vid_buttons a.facebook_button:focus
            {
                -webkit-box-shadow: inset 0 1px 1px rgba(255,255,255,.1), 0 1px 1px rgba(5,15,30,.3);
                -moz-box-shadow: inset 0 1px 1px rgba(255,255,255,.1), 0 1px 1px rgba(5,15,30,.3);
                box-shadow: inset 0 1px 1px rgba(255,255,255,.1), 0 1px 1px rgba(5,15,30,.3);
                border-color: #30487b;
                text-shadow: 0px 1px 1px #213256;
            }

            .share_vid_buttons a.facebook_button:active
            {
                border-color: #2d4373;
                -webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
                -moz-box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
                box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
            }

            .share_vid_buttons a.twitter_button
            {
                border-color: #00a6d4 #00a6d4 #006a87;
                border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
                color: #ffffff;
                text-shadow: 0 0px 1px #007ea1;
                background-color: #01bbee;
                background-image: -moz-linear-gradient(top, #02c9ff, #00a6d4);
                background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#02c9ff), to(#00a6d4));
                background-image: -webkit-linear-gradient(top, #02c9ff, #00a6d4);
                background-image: -o-linear-gradient(top, #02c9ff, #00a6d4);
                background-image: linear-gradient(to bottom, #02c9ff, #00a6d4);
                background-repeat: repeat-x;
                filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff02c9ff', endColorstr='#ff00a6d4', GradientType=0);
                border-color: #007ea1;
                *background-color: #00a6d4;
                filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
                -webkit-user-select: none;
                -moz-user-select: none;
                -ms-user-select: none;
                -o-user-select: none;
                user-select: none;
                border-color: #00a6d4;
                -webkit-box-shadow: inset 0px 1px 1px rgba(255,255,255,.2);
                -moz-box-shadow: inset 0px 1px 1px rgba(255,255,255,.2);
                box-shadow: inset 0px 1px 1px rgba(255,255,255,.2);
            }

            .share_vid_buttons  a.twitter_button:hover, .share_vid_buttons a.twitter_button:focus, .share_vid_buttons a.twitter_button:active, .share_vid_buttons a.twitter_button.active, .share_vid_buttons a.twitter_button.disabled, .share_vid_buttons a.twitter_button[disabled]
            {
                color: #ffffff;
                background-color: #00a6d4;
                *background-color: #0092ba;
            }

            .share_vid_buttons a.twitter_button:active, .share_vid_buttons a.twitter_button.active
            {
                background-color: #007ea1 9;
            }

            .share_vid_buttons a.twitter_button:hover, .share_vid_buttons a.twitter_button:focus
            {
                -webkit-box-shadow: inset 0 1px 1px rgba(255,255,255,.1), 0 1px 1px rgba(5,15,30,.3);
                -moz-box-shadow: inset 0 1px 1px rgba(255,255,255,.1), 0 1px 1px rgba(5,15,30,.3);
                box-shadow: inset 0 1px 1px rgba(255,255,255,.1), 0 1px 1px rgba(5,15,30,.3);
                border-color: #0092ba;
                text-shadow: 0px 1px 1px #006a87;
            }

            .share_vid_buttons a.twitter_button:active
            {
                border-color: #008ab0;
                -webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
                -moz-box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
                box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
            }

            .share_vid_buttons .icon:before, .share_vid_buttons .icon:after
            {
                font-family: 'FontAwesome' !important;
                display: -moz-inline-stack;
                display: inline-block;
                zoom: 1;
                *display: inline;
                vertical-align: top;
                font-weight: normal !important;
                text-align: center;
                text-transform: none;
                font-weight: normal;
                vertical-align: middle;
            }

            .share_vid_buttons .btn
            {
                display: inline-block;
                *display: inline;
                *zoom: 1;
                padding: 4px 12px;
                margin-bottom: 0;
                font-size: 16px;
                line-height: 22px;
                text-align: center;
                vertical-align: middle;
                cursor: pointer;
                border-color: #e6e6e6 #e6e6e6 #bfbfbf;
                border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
                color: #333333;
                text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
                background-color: #f5f5f5;
                background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
                background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
                background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
                background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
                background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
                background-repeat: repeat-x;
                filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
                border-color: #cccccc;
                *background-color: #e6e6e6;
                filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
                border: 1px solid #cccccc;
                *border: 0;
                border-bottom-color: #b3b3b3;
                -webkit-border-radius: 4px;
                -moz-border-radius: 4px;
                border-radius: 4px;
                *margin-left: .3em;
                -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
                -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
                box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
            }

            .share_vid_buttons .btn:hover, .share_vid_buttons .btn:focus, .share_vid_buttons .btn:active, .share_vid_buttons .btn.active, .share_vid_buttons .btn.disabled,.btn[disabled]
            {
                color: #333333;
                background-color: #e6e6e6;
                *background-color: #d9d9d9;
            }

            .share_vid_buttons .btn:active, .share_vid_buttons .btn.active
            {
                background-color: #cccccc 9;
            }

            .share_vid_buttons .btn:first-child
            {
                *margin-left: 0;
            }

            .share_vid_buttons .btn:hover,.btn:focus
            {
                color: #333333;
                text-decoration: none;
                background-position: 0 -15px;
                -webkit-transition: background-position 0.1s linear;
                -moz-transition: background-position 0.1s linear;
                -o-transition: background-position 0.1s linear;
                transition: background-position 0.1s linear;
            }

            .share_vid_buttons .btn:focus
            {
                outline: thin dotted #333;
                outline: 5px auto -webkit-focus-ring-color;
                outline-offset: -2px;
            }

            .share_vid_buttons .btn.active, .share_vid_buttons .btn:active
            {
                background-image: none;
                outline: 0;
                -webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
                -moz-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
                box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
            }

            .share_vid_buttons .btn.disabled, .share_vid_buttons .btn[disabled]
            {
                cursor: default;
                background-image: none;
                opacity: 0.65;
                filter: alpha(opacity=65);
                -webkit-box-shadow: none;
                -moz-box-shadow: none;
                box-shadow: none;
            }

            .share_vid_buttons a.btn-share
            {
                cursor: pointer;
                font-weight: normal;
            }

            .share_vid_buttons #shareRowBottom
            {
                text-align: center;
                position: relative;
                padding: 0 0 1em;
                *zoom: 1;
            }

            .share_vid_buttons #shareRowBottom:before, .share_vid_buttons #shareRowBottom:after
            {
                display: table;
                content: "";
                line-height: 0;
            }

            .share_vid_buttons #shareRowBottom:after
            {
                clear: both;
            }

            .share_vid_buttons #shareRowBottom h3
            {
                font-size: 1.5em;
                line-height: 1.2em;
                margin-top: 20px;
                margin-bottom: 10px;
                font-weight: normal;
                color: #333333;
            }

            .share_vid_buttons #shareRowBottom a.btn-share
            {
                width: 49.65%;
                float: left;
                padding: 9px;
            }

            .share_vid_buttons #shareRowBottom a.btn-share.twitter_button
            {
                float: right;
            }

            .share_vid_buttons #shareRowBottom a.btn-share.twitter_button .icon:before
            {
                content: 'f099';
                color: #fff;
                font-size: 1.2em;
                padding: 0;
                line-height: 1em;
                vertical-align: middle;
                position: relative;
                top: -1px;
                margin-right: 6px;
                margin-left: -5px;
                padding-top: 0;
            }

            .share_vid_buttons #shareRowBottom a.btn-share.facebook_button .icon:before
            {
                content: 'f09a';
                color: #fff;
                font-size: 1.2em;
                padding: 0;
                line-height: 1em;
                vertical-align: middle;
                position: relative;
                top: -1px;
                margin-right: 6px;
                margin-left: -5px;
                padding-top: 0;
            }

            .share_vid_buttons #shareRowBottom a.btn-share .textNode
            {
                display: -moz-inline-stack;
                display: inline-block;
                zoom: 1;
                *display: inline;
                vertical-align: top;
            }

            .share_vid_buttons #shareRowBottom *, .share_vid_buttons #shareRowBottom *:before, .share_vid_buttons #shareRowBottom *:after
            {
                -webkit-box-sizing: border-box;
                -moz-box-sizing: border-box;
                box-sizing: border-box;
            }

            .share_vid_buttons .vid_cont_social
            {
                position: relative;
                z-index: 1;
                padding-top: 10px;
            }

            .vid_cont_social #shareOverlay+p
            {
                margin-top: 0;
            }

            .share_vid_buttons #shareOverlay
            {
                list-style: none;
                margin: 0;
                padding: 0;
                position: absolute;
                margin-left: -13px;
                margin-top: 1em;
                top: 7.5em;
                z-index: 500;
                opacity: 0;
                filter: alpha(opacity=0);
                -webkit-transition: opacity .4s, top .25s;
                -moz-transition: opacity .4s, top .25s;
                -o-transition: opacity .4s, top .25s;
                transition: opacity .4s, top .25s;
            }

            .share_vid_buttons #shareOverlay.visible
            {
                opacity: 1;
                filter: alpha(opacity=100);
            }

            .share_vid_buttons #shareOverlay li
            {
                margin-bottom: -1px;
            }

            .share_vid_buttons #shareOverlay li a
            {
                text-decoration: none;
                border: 1px solid #fff;
                -webkit-border-radius: 0 4px 4px 0;
                -moz-border-radius: 0 4px 4px 0;
                border-radius: 0 4px 4px 0;
                -webkit-box-shadow: 3px 3px 4px rgba(58, 45, 30, 0.7);
                -moz-box-shadow: 3px 3px 4px rgba(58, 45, 30, 0.7);
                box-shadow: 3px 3px 4px rgba(58, 45, 30, 0.7);
            }

            .share_vid_buttons #shareOverlay li.email img
            {
                display: none;
            }

            .share_vid_buttons #shareOverlay:after
            {
                content: ' ';
                width: 12px;
                height: 30px;
                background: #ffffff url(img/share.png) no-repeat right top;
                display: block;
                position: absolute;
                left: 0;
                bottom: -31px;
            }

            .share_vid_buttons  ul.share li
            {
                vertical-align: middle;
                margin: 0;
                padding: 0;
                display: block;
            }

            .share_vid_buttons ul.share li a
            {
                font-size: 1em;
                display: -moz-inline-stack;
                display: inline-block;
                zoom: 1;
                *display: inline;
                vertical-align: top;
                padding: 13px 15px;
                -webkit-border-radius: 4px;
                -moz-border-radius: 4px;
                border-radius: 4px;
                color: #fff;
            }

.widget_two_tabs {
  padding: 0;
}
.widget_two_tabs .tabs {
  border: 0 none;
  height: 50px;
}
.widget_two_tabs .tabs li {
  border-radius: 0;
  font-family: 'Oswald',sans-serif;
  font-size: 20px;
  height: 50px;
  line-height: 50px;
  margin: 0;
    width: 50%;
  	-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
	-moz-box-sizing: border-box;    /* Firefox, other Gecko */
	box-sizing: border-box;         /* Opera/IE 8+ */
	border: 0 none;
}
.widget_two_tabs .tabs_active {
  background: none repeat scroll 0 0 #7DDBF5;
}
.widget_two_tabs div.tabs_active {
  background: none repeat scroll 0 0 #F5F4F7;
}
.widget_two_tabs div.tabs-panes a:hover, .widget_two_tabs div.tabs-panes a.current {
  background: none repeat scroll 0 0 #D0EBF6;
  color: #7F7E80;
}
.widget_two_tabs .tabs-panes {
  padding: 0;
}
.widget_two_tabs .featured_thumb {
  float: left;
  margin-right: 15px;
}
.widget_two_tabs a {
  display: block;
  overflow: hidden;
  padding: 15px;
}
.widget_two_tabs ul li {
  margin: 0;
}

a.pin_it_btn { cursor: pointer; display: inline-block; text-align: center; font-family: "Helvetica Neue", Helvetica, sans-serif; text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.33); font-size: 18px; border: 1px solid #980b0e; border-radius: 3px; padding: 0 18px; background: -moz-linear-gradient(top, #FF0303 0%, #D40000 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #FF0303), color-stop(100%, #D40000)); background: -webkit-linear-gradient(top, #FF0303 0%, #D40000 100%); background: -o-linear-gradient(top, #FF0303 0%, #D40000 100%); background: -ms-linear-gradient(top, #FF0303 0%, #D40000 100%); background: linear-gradient(to bottom, #FF0303 0%, #D40000 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF0303', endColorstr='#D40000',GradientType=0 ); color: #fff; }

a.pin_it_btn:hover { box-shadow: 0 1px 3px #aaaaaa; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); background: -moz-linear-gradient(top, #de4348 0%, #D40000 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #de4348), color-stop(100%, #D40000)); background: -webkit-linear-gradient(top, #de4348 0%, #D40000 100%); background: -o-linear-gradient(top, #de4348 0%, #D40000 100%); background: -ms-linear-gradient(top, #de4348 0%, #D40000 100%); background: linear-gradient(to bottom, #de4348 0%, #D40000 100%); color: #fff; }

a.pin_it_btn:active { box-shadow: 0 1px 3px #aaaaaa; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); background: -moz-linear-gradient(top, #961519 0%, #D40000 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #961519), color-stop(100%, #D40000)); background: -webkit-linear-gradient(top, #961519 0%, #D40000 100%); background: -o-linear-gradient(top, #961519 0%, #D40000 100%); background: -ms-linear-gradient(top, #961519 0%, #D40000 100%); background: linear-gradient(to bottom, #961519 0%, #D40000 100%); color: #fff; }

/*
 * SimpleModal Basic Modal Dialog
 * http://simplemodal.com
 *
 * Copyright (c) 2013 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */

#basic-modal-content {display:none;}

/* Overlay */
#simplemodal-overlay {background-color:#000;}

/* Container */
#simplemodal-container {height:360px; width:600px; color:#bbb; background-color:#4CC6F4; border:4px solid #444; padding:12px;}
#simplemodal-container {
  color: #000000;
}
#simplemodal-container .simplemodal-data {padding:8px;}
#simplemodal-container code {background:#141414; border-left:3px solid #65B43D; color:#bbb; display:block; font-size:12px; margin-bottom:12px; padding:4px 6px 6px;}
#simplemodal-container a {color:#ddd;}
#simplemodal-container a.modalCloseImg {background:url(img/basic/x.png) no-repeat; width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-15px; right:-16px; cursor:pointer;}
#simplemodal-container h3 {
  color: #EFF15B;
  font-weight: bold;
  margin-bottom: 20px;
}
.message.facebook {
  background: none repeat scroll 0 0 #FFFFFF;
  border-radius: 10px;
  padding: 15px;
}

#navigation {background: rgba(76, 198, 244, 0.8); z-index:9999; width:100%; top:0; position:fixed;}

#footer-widget-area-top .wysija-paragraph {
  display: inline-block;
  margin: 10px;
  width: 39%;
}

#footer-widget-area-top .wysija-paragraph input {
  	-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
	-moz-box-sizing: border-box;    /* Firefox, other Gecko */
	box-sizing: border-box;         /* Opera/IE 8+ */
  border: 4px solid #0196A6;
  color: #000000;
  height: 40px;
  padding: 4px 8px;
  width: 100%;
}
#footer-widget-area-top .widget_wysija_cont .wysija-submit {
  background: none repeat scroll 0 0 #2298A6;
  display: inline-block;
}
#footer-widget-area-top {
  background: none repeat scroll 0 0 #22CEE0;
  overflow: hidden;
  padding-bottom: 20px;
  padding-top: 10px;
  text-align: center;
}
#footer-widget-area-top h3 span {
  color: #006873;
  font-size: 0.7em;
  font-weight: normal;
  margin-left: 12px;
}
#footerwidgets .newsletter {
  background: none repeat scroll 0 0 #22CEE0;
}

 

thank you page to close facebook share window:

<?php /* Template Name: close window */ ?>
<script type='text/javascript'>
       window.open('','_self','');
       window.close();

       // if the window did not close (e.g. in Facebook's IOS native browser) then redirect to homepage
       window.location = '<?php echo get_home_url(); ?>';
     </script>"

javascript code for buttons: custom.js

jQuery(function() {
        jQuery('a.facebook_button, a.twitter_button, a.pin_it_btn').live('click', function(event) {
          event.preventDefault();
		  var link = jQuery(this).attr('href');
		  var link_index = jQuery(this).data('type');
          jQuery.popupWindow(link, {
	onUnload: function() { // callback when window closes

		jQuery('#basic-modal-content').modal();
    } 
});
        });
		});
		jQuery(document).ready(function(){

				 jQuery( ".vid_cont_social" ).hover(
function() {
jQuery('#shareOverlay').addClass('visible');
}, function() {
jQuery('#shareOverlay').removeClass('visible');
}
);

jQuery('.tab_widget').tabs({panes_wrap: '.tab_widget_panes'});

		});

 

str_replace(array(“rn”, “r”, “n”), “”, $out)  to remove all new lines.

 

 

 

awpcp_split_payments.php

<?php

/**
 * Plugin Name: AWPCP custom split payment
 * Plugin URI: http://alhoseany.com
 * Description: A plugin that adds the ability to split payment between admin and region managers by states in AWPCP plugin.
 * Version: 1.0
 * Author: alhoseany
 * Author URI: http://alhoseany.com
 * License: GPL2
 */
//register settings
function awpcp_csp_settings_init() {
    register_setting('awpcp_csp_settings', 'awpcp_csp_settings');
}

//add settings page to menu
function add_awpcp_csp_settings_page() {
    add_menu_page(__('Split Payments Options'), __('Split Payments'), 'manage_options', 'awpcp_csp_settings', 'awpcp_csp_options');
}

//add actions
add_action('admin_init', 'awpcp_csp_settings_init');
add_action('admin_menu', 'add_awpcp_csp_settings_page');

//start settings page
function awpcp_csp_options() {
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }

    if (!function_exists('awpcp_regions_api')) {
        wp_die(__('This plugin needs the AWPCP plugin and the regions manager module to work.'));
    }

    if (!isset($_REQUEST['settings-updated']))
        $_REQUEST['settings-updated'] = false;

    $all_regions = awpcp_regions_api();
    $states = $all_regions->get_children(191);

    ?>

    <style>
        table {
            padding: 20px;
        }
        tr:hover {
            background: none repeat scroll 0 0 #F0F0FF;
        }
        td {
            vertical-align: middle !important;
        }
    </style>

    <div>

        <div id="icon-options-general"></div>
        <h2><?php _e('Split Payments Options') //your admin panel title     ?></h2>

        <?php
//show saved options message
        if (false !== $_REQUEST['settings-updated']) :
            ?>
            <div class="updated settings-error" id="setting-error-settings_updated"> 
                <p><strong>Settings saved.</strong></p></div><br>
        <?php endif; ?>

        <form method="post" action="options.php">

            <?php settings_fields('awpcp_csp_settings'); ?>
            <?php $options = get_option('awpcp_csp_settings'); ?>

            <table class="wp-list-table widefat fixed pages" cellspacing="0">
                <thead>
                    <tr>
                        <th>State</th>
                        <th>Paypal Email</th>
                        <th>Percentage (without %)</th>	
                    </tr>
                </thead>
                <tbody>

                    <?php
                    $c = 0;

                    foreach ($states as $state) {

                        $this_state = $all_regions->find_by_id($state)->region_name;
						$this_state_id = $all_regions->find_by_id($state)->region_id;
						if($this_state){
                        ?>

                        <tr class="<?= ($c++ % 2 == 1) ? '' : 'alternate' ?>">
                            <td><strong><?php echo $this_state; ?></strong></td>
                            <td>

                                <input id="awpcp_csp_settings[<?php echo $this_state; ?>_email]" type="email" size="36" name="awpcp_csp_settings[<?php echo $this_state; ?>_email]" value="<?php esc_attr_e($options[$this_state . '_email']); ?>" />
                            </td>
                            <td>

                                <input id="awpcp_csp_settings[<?php echo $this_state; ?>_percentage]" type="number" size="10" name="awpcp_csp_settings[<?php echo $this_state; ?>_percentage]" value="<?php
                                       if ($options[$this_state . '_percentage']) {
                                           esc_attr_e($options[$this_state . '_percentage']);
                                       } else {
                                           echo '10';
                                       }
                                       ?>" />
                            </td>
                        </tr>

                        <?php
						}
                    }
                    ?>

            </table>
            <?php submit_button(); ?>
        </form>

    </div><!-- END wrap -->

    <?php
}

// Use this class to construct the NVP calls to the paypal service

class PayPal_CallerService {

    public $API_UserName;
    public $API_Password;
    public $API_Signature;
    public $API_Endpoint;
    public $last_request;
    public $last_response;
    public $version;
    public $subject;

    public function __construct($credentials) {

        if (is_array($credentials)) {

            $this->API_UserName = (isset($credentials['API_USERNAME']) && !empty($credentials['API_USERNAME'])) ? $credentials['API_USERNAME'] : '';
            $this->API_Password = (isset($credentials['API_PASSWORD']) && !empty($credentials['API_PASSWORD'])) ? $credentials['API_PASSWORD'] : '';
            $this->API_Signature = (isset($credentials['API_SIGNATURE']) && !empty($credentials['API_SIGNATURE'])) ? $credentials['API_SIGNATURE'] : '';
            $this->API_Endpoint = (isset($credentials['API_ENDPOINT']) && !empty($credentials['API_ENDPOINT'])) ? $credentials['API_ENDPOINT'] : 'https://api-3t.sandbox.paypal.com/nvp';
            $this->version = (isset($credentials['VERSION']) && !empty($credentials['VERSION'])) ? $credentials['VERSION'] : '60.0';
            $this->subject = (isset($credentials['SUBJECT']) && !empty($credentials['SUBJECT'])) ? $credentials['SUBJECT'] : '';
        } else {

            throw new Exception('You must pass in an array of credentials to instantiate this class.');
        }
    }

    public function callPayPal($methodName, $base_call = NULL) {

        $header_call = "&PWD=" . urlencode($this->API_Password) .
                "&USER=" . urlencode($this->API_UserName) .
                "&SIGNATURE=" . urlencode($this->API_Signature) .
                "&SUBJECT=" . urlencode($this->subject) .
                "&VERSION=" . urlencode($this->version);

        $call = $header_call . $base_call;

//setting the curl parameters.
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->API_Endpoint);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);

//Turning off the server and peer verification(TrustManager Concept).
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);

//If USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
        /* if(USE_PROXY)
          curl_setopt ($ch, CURLOPT_PROXY, PROXY_HOST.":".PROXY_PORT); */

//Check if version is included in $nvpStr else include the version.
        if (strlen(str_replace('VERSION=', '', strtoupper($call))) == strlen($call)) {

            $nvpStr = "&VERSION=" . urlencode($this->version) . $call;
        }

        $nvpreq = "METHOD=" . urlencode($methodName) . $call;

        $this->last_request = $nvpreq;

//Setting the nvpreq as POST FIELD to curl
        curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

//Getting response from server
        $response = curl_exec($ch);

//Converting NVPResponse to an Associative Array
        $nvpResArray = $this->deformatNVP($response);
        $nvpReqArray = $this->deformatNVP($nvpreq);
        $_SESSION['nvpReqArray'] = $nvpReqArray;

        if (curl_errno($ch)) {

            throw new Exception('Curl error: ' . curl_errno($ch) . ' - ' . curl_error($ch));
        } else {
//Closing the curl
            curl_close($ch);
        }

        $this->last_response = $nvpResArray;

        return $nvpResArray;
    }

    /**
     * This function will take NVPString and convert it to an Associative Array and it will decode the response.
     * It is usefull to search for a particular key and displaying arrays.
     *
     * @nvpstr is NVPString.
     * @nvpArray is Associative Array.
     */
    public static function deformatNVP($nvpstr) {

        $intial = 0;
        $nvpArray = array();

        while (strlen($nvpstr)) {
//postion of Key
            $keypos = strpos($nvpstr, '=');
//position of value
            $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr);

            /* getting the Key and Value values and storing in a Associative Array */
            $keyval = substr($nvpstr, $intial, $keypos);
            $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1);
//decoding the respose
            $nvpArray[urldecode($keyval)] = urldecode($valval);
            $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr));
        }

        return $nvpArray;
    }

}

function awpcp_split_payments_plugin($transaction) {

    if ($transaction->is_completed() && $transaction->was_payment_successful() && !awpcp_current_user_is_admin()) {

        if ($transaction->get('ad-id') && class_exists('AWPCP_Ad')) {

            $regions = AWPCP_Ad::get_ad_regions($transaction->get('ad-id'));
            $options = get_option('awpcp_csp_settings');

			if($options[$regions[0][city] . '_email'] && $options[$regions[0][city] . '_percentage'] > 0 ){
				$pay_email = $options[$regions[0][city] . '_email'];
				$pay_percent = $options[$regions[0][city] . '_percentage'];
			}elseif($options[$regions[0][state] . '_email'] && $options[$regions[0][state] . '_percentage'] > 0 ){
				$pay_email = $options[$regions[0][state] . '_email'];
				$pay_percent = $options[$regions[0][state] . '_percentage'];
			}else{
				$pay_email = false;
				$pay_percent = false;
			}

            if ($pay_email && $pay_percent && $transaction->get_total_amount() > 0) {
                $region_manager_amount = ($pay_percent / 100) * $transaction->get_total_amount();
                // pay the user

                $credentials['API_USERNAME'] = 'sales_api1.areamusicscene.com';
                $credentials['API_PASSWORD'] = 'FHJZ4DNEV2CCCJ8L';
                $credentials['API_SIGNATURE'] = 'AY4Ri-uV76WllFKd2cxduagZQFOEApdsk9MMP3r8cKGRbCtOtOnClQFs';
                $credentials['API_ENDPOINT'] = 'https://api-3t.paypal.com/nvp';

                $amount = urlencode($region_manager_amount);
                $id = urlencode($transaction->get('ad-id'));
                $note = urlencode('Comission payment for new ad.');
                $subject = urlencode("Payment from areamusicscene.com");
                $type = urlencode('EmailAddress');
                $currency = urlencode('USD');
                $customer_email = urlencode($pay_email);

                $base_call = "&L_EMAIL0=" . $customer_email .
                        "&L_AMT0=" . $amount .
                        "&L_UNIQUEID0=" . $id .
                        "&L_NOTE0=" . $refund_note .
                        "&EMAILSUBJECT=" . $subject .
                        "&RECEIVERTYPE=" . $type .
                        "&CURRENCYCODE=" . $currency;

                $PayPal = new PayPal_CallerService($credentials);

                $status = $PayPal->callPayPal("MassPay", $base_call);

                //Do something if it is successfully sent
                if ($status) {

                    if ($status['ACK'] == "Success") {

                        $msg = "New ad commision payment has been made.rn";
                        $msg .= "Commision Info : rn";
                        $msg .= "ad : " . url_showad($transaction->get('ad-id')) . " rn";
                        $msg .= "State : " . $regions[0][state] . " rn";
						$msg .= "City : " . $regions[0][city] . " rn";
                        $msg .= "paypal email : " . $pay_email . " rn";
                        $msg .= "commission percentage : " . $pay_percent . "% rn";
                        $msg .= "commission amount : $" . $region_manager_amount . " rn";
                        $msg .= "--------------------------------------------------------------- rn";

                        //$admin_email = get_option( 'admin_email' );
                        $admin_email = 'sales@areamusicscene.com';
                        mail($admin_email, 'New ad commision payment ', $msg, 'From: "areamusicscene.com" <' . $admin_email . '>');
                    } else if ($status['ACK'] == "Failure") {

                        $msg = "New ad commision payment has failed to be sent.rn";
                        $msg .= "Commision Info : rn";
                        $msg .= "ad : " . url_showad($transaction->get('ad-id')) . " rn";
                        $msg .= "State : " . $regions[0][state] . " rn";
						$msg .= "City : " . $regions[0][city] . " rn";
                        $msg .= "paypal email : " . $pay_email . " rn";
                        $msg .= "commission percentage : " . $pay_percent . "% rn";
                        $msg .= "commission amount : $" . $region_manager_amount . " rn";
                        $msg .= "--------------------------------------------------------------- rn".var_dump($status);

                        //$admin_email = get_option( 'admin_email' );
                        $admin_email = 'sales@areamusicscene.com';
                        mail($admin_email, 'ad commision payment failed', $msg, 'From: "areamusicscene.com" <' . $admin_email . '>');

                        //var_dump($status);
                    }
                }
            }
        }

// end payment code
    }
}

add_action('awpcp-transaction-status-updated', 'awpcp_split_payments_plugin');